Rohit8y commited on
Commit
b4511b1
1 Parent(s): 6821e4c

bug fixed cv2

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -14,10 +14,11 @@ from detectron2.utils.visualizer import Visualizer
14
  from detectron2.data import MetadataCatalog
15
 
16
 
17
- def predict(image):
18
  print(datetime.datetime.now())
19
- # Convert PIL Image to numpy array
20
- input_image = cv2.imread(image.name)
 
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()