Ubuntu
[mod] percent
5901ece
import streamlit as st
import numpy as np
with st.sidebar:
st.image("logo/logo_small_EQUES.png")
st.button("カメラと接続")
from PIL import Image
import io
uploaded_file = st.file_uploader('画像をアップロード')
if uploaded_file is not None:
image = Image.open(uploaded_file)
img_array = np.array(image)
st.image(
image, caption='upload images',
use_column_width=True
)
option = st.selectbox(
"テスト画像の使用",
("テスト画像1", "テスト画像2", "テスト画像3"),
index=None,
placeholder="テスト画像を選択してください。",
)
if st.button("不審者を検知"):
if option != None:
image = Image.open(f"img/sample/{option}.JPG")
assert image != None,"画像をアップロードしてください。"
from run import inference
with st.spinner("Operation in progress. Please wait."):
output, (labels, scores, indices) = inference(image)
st.image("img/detected.png")
st.title("解析結果")
for a,b in zip(labels, scores):
prob = float(b) * 100
st.write(a)
st.write(f"AIの確信度: {prob} %")
if len(indices) != 0:
st.warning('不審者が検知された可能性があります', icon="⚠️")
else:
st.info('不審者は検知されませんでした', icon="ℹ️")
st.title("解析結果詳細")
st.write(output)