init
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
os.system('pip install torch==1.9 torchvision')
|
3 |
os.system('pip install detectron2==0.5 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
4 |
os.system('pip install timm opencv-python-headless')
|
@@ -14,7 +15,7 @@ from opendet2 import add_opendet_config
|
|
14 |
model_cfgs = {
|
15 |
"FR-CNN": ["configs/faster_rcnn_R_50_FPN_3x_baseline.yaml", "frcnn_r50.pth"],
|
16 |
"OpenDet-R50": ["configs/faster_rcnn_R_50_FPN_3x_opendet.yaml", "opendet2_r50.pth"],
|
17 |
-
"OpenDet-SwinT": ["configs
|
18 |
}
|
19 |
|
20 |
|
@@ -39,6 +40,7 @@ def inference(input, model):
|
|
39 |
output = visualized_output.get_image()[:, :, ::-1]
|
40 |
return output
|
41 |
|
|
|
42 |
|
43 |
iface = gr.Interface(
|
44 |
inference,
|
@@ -47,6 +49,11 @@ iface = gr.Interface(
|
|
47 |
gr.inputs.Radio(
|
48 |
["FR-CNN", "OpenDet-R50", "OpenDet-SwinT"], default='OpenDet-R50'),
|
49 |
],
|
50 |
-
"image"
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
from pydoc import describe
|
3 |
os.system('pip install torch==1.9 torchvision')
|
4 |
os.system('pip install detectron2==0.5 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
5 |
os.system('pip install timm opencv-python-headless')
|
|
|
15 |
model_cfgs = {
|
16 |
"FR-CNN": ["configs/faster_rcnn_R_50_FPN_3x_baseline.yaml", "frcnn_r50.pth"],
|
17 |
"OpenDet-R50": ["configs/faster_rcnn_R_50_FPN_3x_opendet.yaml", "opendet2_r50.pth"],
|
18 |
+
"OpenDet-SwinT": ["configs/faster_rcnn_Swin_T_FPN_3x_opendet.yaml", "opendet2_swint.pth"],
|
19 |
}
|
20 |
|
21 |
|
|
|
40 |
output = visualized_output.get_image()[:, :, ::-1]
|
41 |
return output
|
42 |
|
43 |
+
examples = [[x, "OpenDet-R50"] for x in os.listdir('demo') if x.endswith(".jpg")]
|
44 |
|
45 |
iface = gr.Interface(
|
46 |
inference,
|
|
|
49 |
gr.inputs.Radio(
|
50 |
["FR-CNN", "OpenDet-R50", "OpenDet-SwinT"], default='OpenDet-R50'),
|
51 |
],
|
52 |
+
"image",
|
53 |
+
examples=examples,
|
54 |
+
title="OpenDet",
|
55 |
+
article="<p style='text-align: center'><a href=https://github.com/csuhan/opendet2' target='_blank'>Github Repo</a> | <a href=https://csuhan.com' target='_blank'>Author Page</a></p>",
|
56 |
+
description="Online demo for: Expanding Low-Density Latent Regions for Open-Set Object Detection. Please upload your image, or click one of the examples to load them",
|
57 |
+
)
|
58 |
+
|
59 |
+
iface.launch(enable_queue=True, cache_examples=True)
|