Spaces:
Runtime error
Runtime error
Commit
·
43afdb7
1
Parent(s):
7f3a3f1
fix: add gdown for model checkpoints
Browse files- app.py +9 -3
- models/__init__.py +0 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
| 4 |
import wget
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
|
|
|
| 7 |
from argparse import Namespace
|
| 8 |
try:
|
| 9 |
import detectron2
|
|
@@ -33,6 +34,11 @@ lvis_train_cat_info_path = "datasets/metadata/lvis_v1_train_cat_info.json"
|
|
| 33 |
if not os.path.exists(lvis_train_cat_info_path):
|
| 34 |
wget.download("https://docs.google.com/uc?export=download&id=17WmkAJYBK4xT-YkiXLcwIWmtfulSUtmO", out=lvis_train_cat_info_path)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
args = Namespace(
|
| 37 |
base_cat_threshold=0.9,
|
| 38 |
confidence_threshold=0.0,
|
|
@@ -40,13 +46,13 @@ args = Namespace(
|
|
| 40 |
cpu=not torch.cuda.is_available(),
|
| 41 |
custom_vocabulary='headphone,webcam,paper,coffe',
|
| 42 |
input=['.assets/desk.jpg'],
|
| 43 |
-
opts=['MODEL.WEIGHTS',
|
| 44 |
output='out.jpg',
|
| 45 |
pred_all_class=False,
|
| 46 |
video_input=None,
|
| 47 |
vocabulary='custom',
|
| 48 |
webcam=None,
|
| 49 |
-
zeroshot_weight_path=
|
| 50 |
)
|
| 51 |
cfg = setup_cfg(args)
|
| 52 |
ovd_demo = VisualizationDemo(cfg, args)
|
|
@@ -90,7 +96,7 @@ How to use?
|
|
| 90 |
- Simply upload an image and enter comma separated objects (e.g., "dog,cat,headphone") which you want to detect within the image.
|
| 91 |
Parameters:
|
| 92 |
- You can also use the score threshold slider to set a threshold to filter out low probability predictions.
|
| 93 |
-
- adjust alpha and beta value for base and novel classes, respectively. These determine <b>how much importance will you assign to the scores sourced from our proposed detection head which is trained with our proxy-novel classes</b
|
| 94 |
"""
|
| 95 |
demo = gr.Interface(
|
| 96 |
query_image,
|
|
|
|
| 4 |
import wget
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
+
import gdown
|
| 8 |
from argparse import Namespace
|
| 9 |
try:
|
| 10 |
import detectron2
|
|
|
|
| 34 |
if not os.path.exists(lvis_train_cat_info_path):
|
| 35 |
wget.download("https://docs.google.com/uc?export=download&id=17WmkAJYBK4xT-YkiXLcwIWmtfulSUtmO", out=lvis_train_cat_info_path)
|
| 36 |
|
| 37 |
+
# download model
|
| 38 |
+
model_path = "models/proxydet_swinb_w_inl.pth"
|
| 39 |
+
if not os.path.exists(model_path):
|
| 40 |
+
gdown.download("https://docs.google.com/uc?export=download&id=17kUPoi-pEK7BlTBheGzWxe_DXJlg28qF", model_path)
|
| 41 |
+
|
| 42 |
args = Namespace(
|
| 43 |
base_cat_threshold=0.9,
|
| 44 |
confidence_threshold=0.0,
|
|
|
|
| 46 |
cpu=not torch.cuda.is_available(),
|
| 47 |
custom_vocabulary='headphone,webcam,paper,coffe',
|
| 48 |
input=['.assets/desk.jpg'],
|
| 49 |
+
opts=['MODEL.WEIGHTS', model_path],
|
| 50 |
output='out.jpg',
|
| 51 |
pred_all_class=False,
|
| 52 |
video_input=None,
|
| 53 |
vocabulary='custom',
|
| 54 |
webcam=None,
|
| 55 |
+
zeroshot_weight_path=zs_weight_path
|
| 56 |
)
|
| 57 |
cfg = setup_cfg(args)
|
| 58 |
ovd_demo = VisualizationDemo(cfg, args)
|
|
|
|
| 96 |
- Simply upload an image and enter comma separated objects (e.g., "dog,cat,headphone") which you want to detect within the image.
|
| 97 |
Parameters:
|
| 98 |
- You can also use the score threshold slider to set a threshold to filter out low probability predictions.
|
| 99 |
+
- adjust alpha and beta value for base and novel classes, respectively. These determine <b>how much importance will you assign to the scores sourced from our proposed detection head which is trained with our proxy-novel classes</b>.
|
| 100 |
"""
|
| 101 |
demo = gr.Interface(
|
| 102 |
query_image,
|
models/__init__.py
ADDED
|
File without changes
|
requirements.txt
CHANGED
|
@@ -10,3 +10,4 @@ lvis
|
|
| 10 |
wget==3.2
|
| 11 |
nltk<=3.7
|
| 12 |
numpy>=1.18.5
|
|
|
|
|
|
| 10 |
wget==3.2
|
| 11 |
nltk<=3.7
|
| 12 |
numpy>=1.18.5
|
| 13 |
+
gdown==4.7.3
|