Spaces:
Sleeping
Sleeping
bug fixed cv2
Browse files
app.py
CHANGED
@@ -14,10 +14,11 @@ from detectron2.utils.visualizer import Visualizer
|
|
14 |
from detectron2.data import MetadataCatalog
|
15 |
|
16 |
|
17 |
-
def predict(
|
18 |
print(datetime.datetime.now())
|
19 |
-
# Convert PIL Image to
|
20 |
-
|
|
|
21 |
# Initialise model
|
22 |
cfg = get_cfg()
|
23 |
cfg.merge_from_file(model_zoo.get_config_file("COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml"))
|
@@ -42,6 +43,6 @@ image_input = gr.Image(type="pil", label="Input Image")
|
|
42 |
|
43 |
iface = gr.Interface(fn=predict,
|
44 |
inputs=[image_input],
|
45 |
-
outputs=gr.Image(),
|
46 |
examples=["examples/6178_3003_0.jpg"])
|
47 |
iface.launch()
|
|
|
14 |
from detectron2.data import MetadataCatalog
|
15 |
|
16 |
|
17 |
+
def predict(pil_image):
|
18 |
print(datetime.datetime.now())
|
19 |
+
# Convert PIL Image to CV2
|
20 |
+
open_cv_image = np.array(pil_image)
|
21 |
+
input_image = open_cv_image[:, :, ::-1].copy()
|
22 |
# Initialise model
|
23 |
cfg = get_cfg()
|
24 |
cfg.merge_from_file(model_zoo.get_config_file("COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml"))
|
|
|
43 |
|
44 |
iface = gr.Interface(fn=predict,
|
45 |
inputs=[image_input],
|
46 |
+
outputs=gr.Image(type="pil"),
|
47 |
examples=["examples/6178_3003_0.jpg"])
|
48 |
iface.launch()
|