Spaces:
Running
Running
Commit
·
823c6c6
1
Parent(s):
a5b4e6b
Upload app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,6 @@ add_maskformer2_config(cfg)
|
|
44 |
add_fcclip_config(cfg)
|
45 |
cfg.merge_from_file("configs/coco/panoptic-segmentation/fcclip/fcclip_convnext_large_eval_ade20k.yaml")
|
46 |
os.system("gdown 1-91PIns86vyNaL3CzMmDD39zKGnPMtvj")
|
47 |
-
os.system("gdown 1-91PIns86vyNaL3CzMmDD39zKGnPMtvj")
|
48 |
cfg.MODEL.WEIGHTS = './fcclip_cocopan.pth'
|
49 |
cfg.MODEL.MASK_FORMER.TEST.SEMANTIC_ON = False
|
50 |
cfg.MODEL.MASK_FORMER.TEST.INSTANCE_ON = False
|
@@ -154,12 +153,13 @@ def build_demo_classes_and_metadata(vocab, label_list):
|
|
154 |
def inference(image_path, vocab, label_list):
|
155 |
|
156 |
logger.info("building class names")
|
|
|
157 |
demo_classes, demo_metadata = build_demo_classes_and_metadata(vocab, label_list)
|
158 |
predictor.set_metadata(demo_metadata)
|
159 |
|
160 |
im = cv2.imread(image_path)
|
161 |
outputs = predictor(im)
|
162 |
-
v = OpenVocabVisualizer(im[:, :, ::-1], demo_metadata,
|
163 |
panoptic_result = v.draw_panoptic_seg(outputs["panoptic_seg"][0].to("cpu"), outputs["panoptic_seg"][1]).get_image()
|
164 |
return Image.fromarray(np.uint8(panoptic_result)).convert('RGB')
|
165 |
|
|
|
44 |
add_fcclip_config(cfg)
|
45 |
cfg.merge_from_file("configs/coco/panoptic-segmentation/fcclip/fcclip_convnext_large_eval_ade20k.yaml")
|
46 |
os.system("gdown 1-91PIns86vyNaL3CzMmDD39zKGnPMtvj")
|
|
|
47 |
cfg.MODEL.WEIGHTS = './fcclip_cocopan.pth'
|
48 |
cfg.MODEL.MASK_FORMER.TEST.SEMANTIC_ON = False
|
49 |
cfg.MODEL.MASK_FORMER.TEST.INSTANCE_ON = False
|
|
|
153 |
def inference(image_path, vocab, label_list):
|
154 |
|
155 |
logger.info("building class names")
|
156 |
+
vocab = vocab.replace(", ", ",").replace("; ", ";")
|
157 |
demo_classes, demo_metadata = build_demo_classes_and_metadata(vocab, label_list)
|
158 |
predictor.set_metadata(demo_metadata)
|
159 |
|
160 |
im = cv2.imread(image_path)
|
161 |
outputs = predictor(im)
|
162 |
+
v = OpenVocabVisualizer(im[:, :, ::-1], demo_metadata, instance_mode=ColorMode.IMAGE)
|
163 |
panoptic_result = v.draw_panoptic_seg(outputs["panoptic_seg"][0].to("cpu"), outputs["panoptic_seg"][1]).get_image()
|
164 |
return Image.fromarray(np.uint8(panoptic_result)).convert('RGB')
|
165 |
|