Spaces:
Build error
Build error
Commit
·
d1d6e36
1
Parent(s):
b29f27d
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,13 +19,13 @@ cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
|
|
| 19 |
# cfg.MODEL.WEIGHTS = "checkpoints_model_final_imagenet_40k_synthetic.pth"
|
| 20 |
|
| 21 |
def predict(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
):
|
| 25 |
if model=="40k_synthetic":
|
| 26 |
weights = "checkpoints_model_final_imagenet_40k_synthetic.pth"
|
| 27 |
else:
|
| 28 |
-
weights = "
|
| 29 |
cfg.MODEL.WEIGHTS=model
|
| 30 |
predictor = DefaultPredictor(cfg)
|
| 31 |
im = cv2.imread(img.name)
|
|
@@ -35,10 +35,10 @@ def predict(
|
|
| 35 |
|
| 36 |
title = "Pet Detection"
|
| 37 |
description = "Demo for Indoor Pet Detection"
|
| 38 |
-
examples = [['example.jpg']]
|
| 39 |
|
| 40 |
|
| 41 |
-
gr.Interface(predict,
|
| 42 |
description=description,
|
| 43 |
# article=article,
|
| 44 |
-
examples=examples).launch()
|
|
|
|
| 19 |
# cfg.MODEL.WEIGHTS = "checkpoints_model_final_imagenet_40k_synthetic.pth"
|
| 20 |
|
| 21 |
def predict(
|
| 22 |
+
model,
|
| 23 |
+
img
|
| 24 |
):
|
| 25 |
if model=="40k_synthetic":
|
| 26 |
weights = "checkpoints_model_final_imagenet_40k_synthetic.pth"
|
| 27 |
else:
|
| 28 |
+
weights = "checkpoints_model_final_imagenet_100k_synthetic.pth"
|
| 29 |
cfg.MODEL.WEIGHTS=model
|
| 30 |
predictor = DefaultPredictor(cfg)
|
| 31 |
im = cv2.imread(img.name)
|
|
|
|
| 35 |
|
| 36 |
title = "Pet Detection"
|
| 37 |
description = "Demo for Indoor Pet Detection"
|
| 38 |
+
examples = [["100k_synthetic", 'example.jpg']]
|
| 39 |
|
| 40 |
|
| 41 |
+
gr.Interface(predict, [gr.inputs.Dropdown(["40k_synthetic", "100k_synthetic"]), gr.inputs.Image(type="file")], outputs=gr.outputs.Image(type="pil"),enable_queue=True, title=title,
|
| 42 |
description=description,
|
| 43 |
# article=article,
|
| 44 |
+
examples=examples).launch(debug=True)
|