Spaces:
Runtime error
Runtime error
Commit
·
199dc75
1
Parent(s):
660fabe
Update app.py
Browse files
app.py
CHANGED
@@ -26,10 +26,12 @@ import numpy as np
|
|
26 |
|
27 |
model_path = "model_final.pth"
|
28 |
|
29 |
-
|
30 |
-
cfg.
|
|
|
|
|
31 |
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
|
32 |
-
|
33 |
st.write("""
|
34 |
# Gun Detection
|
35 |
"""
|
@@ -38,8 +40,9 @@ file = st.file_uploader("Please upload an image file(JPG/PNG/JPEG format)", type
|
|
38 |
|
39 |
st.set_option('deprecation.showfileUploaderEncoding', False)
|
40 |
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
if not torch.cuda.is_available():
|
45 |
cfg.MODEL.DEVICE='cpu'
|
|
|
26 |
|
27 |
model_path = "model_final.pth"
|
28 |
|
29 |
+
ccfg=get_cfg()
|
30 |
+
cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml")) # load the default configuration
|
31 |
+
cfg.MODEL.WEIGHTS = 'model_final.pth'
|
32 |
+
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.8
|
33 |
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
|
34 |
+
|
35 |
st.write("""
|
36 |
# Gun Detection
|
37 |
"""
|
|
|
40 |
|
41 |
st.set_option('deprecation.showfileUploaderEncoding', False)
|
42 |
|
43 |
+
dataset_name="guns"
|
44 |
+
classes=['guns','Gun']
|
45 |
+
MetadataCatalog.get(dataset_name).set(thing_classes=classes)
|
46 |
|
47 |
if not torch.cuda.is_available():
|
48 |
cfg.MODEL.DEVICE='cpu'
|