Spaces:
Sleeping
Sleeping
Ubuntu
commited on
Commit
·
5901ece
1
Parent(s):
716fb32
[mod] percent
Browse files
app.py
CHANGED
@@ -36,7 +36,9 @@ if st.button("不審者を検知"):
|
|
36 |
st.title("解析結果")
|
37 |
|
38 |
for a,b in zip(labels, scores):
|
39 |
-
|
|
|
|
|
40 |
|
41 |
if len(indices) != 0:
|
42 |
st.warning('不審者が検知された可能性があります', icon="⚠️")
|
|
|
36 |
st.title("解析結果")
|
37 |
|
38 |
for a,b in zip(labels, scores):
|
39 |
+
prob = float(b) * 100
|
40 |
+
st.write(a)
|
41 |
+
st.write(f"AIの確信度: {prob} %")
|
42 |
|
43 |
if len(indices) != 0:
|
44 |
st.warning('不審者が検知された可能性があります', icon="⚠️")
|
run.py
CHANGED
@@ -61,12 +61,14 @@ def inference(image_pil):
|
|
61 |
num_classes = 5
|
62 |
backbone = resnet_fpn_backbone('resnet18', False)
|
63 |
model = FasterRCNN(backbone, num_classes)
|
64 |
-
model.eval()
|
65 |
state_dict = torch.load('model/model/densenet-model-9-mAp--1.0.pth',map_location=device)
|
66 |
model.load_state_dict(state_dict["model"])
|
|
|
|
|
67 |
_transform = T.Compose([T.ToTensor()])
|
68 |
image = image_pil.convert("RGB")
|
69 |
image = _transform(image)
|
70 |
-
|
|
|
71 |
res = postprocess(image_pil, output)
|
72 |
return output, res
|
|
|
61 |
num_classes = 5
|
62 |
backbone = resnet_fpn_backbone('resnet18', False)
|
63 |
model = FasterRCNN(backbone, num_classes)
|
|
|
64 |
state_dict = torch.load('model/model/densenet-model-9-mAp--1.0.pth',map_location=device)
|
65 |
model.load_state_dict(state_dict["model"])
|
66 |
+
|
67 |
+
model.eval()
|
68 |
_transform = T.Compose([T.ToTensor()])
|
69 |
image = image_pil.convert("RGB")
|
70 |
image = _transform(image)
|
71 |
+
with torch.no_grad():
|
72 |
+
output = model([image])
|
73 |
res = postprocess(image_pil, output)
|
74 |
return output, res
|