Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,8 @@ coco_metadata = MetadataCatalog.get("coco_2017_val_panoptic")
|
|
30 |
# import Mask2Former project
|
31 |
from mask2former import add_maskformer2_config
|
32 |
|
|
|
|
|
33 |
cfg = get_cfg()
|
34 |
cfg.MODEL.DEVICE='cpu'
|
35 |
add_deeplab_config(cfg)
|
@@ -41,6 +43,8 @@ cfg.MODEL.MASK_FORMER.TEST.INSTANCE_ON = True
|
|
41 |
cfg.MODEL.MASK_FORMER.TEST.PANOPTIC_ON = True
|
42 |
predictor = DefaultPredictor(cfg)
|
43 |
|
|
|
|
|
44 |
def inference(img):
|
45 |
im = cv2.imread(img)
|
46 |
outputs = predictor(im)
|
@@ -57,7 +61,7 @@ title = "Detectron 2"
|
|
57 |
description = "Gradio demo for Detectron 2: A PyTorch-based modular object detection library. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|
58 |
article = "<p style='text-align: center'><a href='https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-/' target='_blank'>Detectron2: A PyTorch-based modular object detection library</a> | <a href='https://github.com/facebookresearch/detectron2' target='_blank'>Github Repo</a></p>"
|
59 |
|
60 |
-
examples = [['
|
61 |
|
62 |
gr.Interface(inference, inputs=gr.inputs.Image(type="filepath"), outputs=[gr.outputs.Image(label="Panoptic segmentation",type="pil"),gr.outputs.Image(label="instance segmentation",type="pil"),gr.outputs.Image(label="semantic segmentation",type="pil")],enable_queue=True, title=title,
|
63 |
description=description,
|
|
|
30 |
# import Mask2Former project
|
31 |
from mask2former import add_maskformer2_config
|
32 |
|
33 |
+
from PIL import Image
|
34 |
+
|
35 |
cfg = get_cfg()
|
36 |
cfg.MODEL.DEVICE='cpu'
|
37 |
add_deeplab_config(cfg)
|
|
|
43 |
cfg.MODEL.MASK_FORMER.TEST.PANOPTIC_ON = True
|
44 |
predictor = DefaultPredictor(cfg)
|
45 |
|
46 |
+
os.system("wget https://i.imgur.com/Vj17K5z.jpg")
|
47 |
+
|
48 |
def inference(img):
|
49 |
im = cv2.imread(img)
|
50 |
outputs = predictor(im)
|
|
|
61 |
description = "Gradio demo for Detectron 2: A PyTorch-based modular object detection library. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|
62 |
article = "<p style='text-align: center'><a href='https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-/' target='_blank'>Detectron2: A PyTorch-based modular object detection library</a> | <a href='https://github.com/facebookresearch/detectron2' target='_blank'>Github Repo</a></p>"
|
63 |
|
64 |
+
examples = [['Vj17K5z.jpg']]
|
65 |
|
66 |
gr.Interface(inference, inputs=gr.inputs.Image(type="filepath"), outputs=[gr.outputs.Image(label="Panoptic segmentation",type="pil"),gr.outputs.Image(label="instance segmentation",type="pil"),gr.outputs.Image(label="semantic segmentation",type="pil")],enable_queue=True, title=title,
|
67 |
description=description,
|