Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -49,15 +49,16 @@ def inference(image_url, image, min_score):
|
|
49 |
im = np.frombuffer(r.content, dtype="uint8")
|
50 |
im = cv2.imdecode(im, cv2.IMREAD_COLOR)
|
51 |
else:
|
|
|
52 |
# Model expect BGR!
|
53 |
-
im = image[:,:,::-1]
|
54 |
|
55 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = min_score
|
56 |
predictor = DefaultPredictor(cfg)
|
57 |
|
58 |
outputs = predictor(im)
|
59 |
|
60 |
-
v = Visualizer(im, my_metadata, scale=1.2, instance_mode=ColorMode.IMAGE )
|
61 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
62 |
|
63 |
return out.get_image()
|
@@ -70,7 +71,7 @@ article = '<p>Detectron model is available from our repository <a href="https://
|
|
70 |
gr.Interface(
|
71 |
inference,
|
72 |
[gr.inputs.Textbox(label="Image URL", placeholder=""),
|
73 |
-
gr.inputs.Image(image_mode="RGB", source="upload", optional=False, label="Input Image"),
|
74 |
gr.Slider(minimum=0.0, maximum=1.0, value=0.5, label="Minimum score"),
|
75 |
],
|
76 |
gr.outputs.Image(type="pil", label="Output"),
|
|
|
49 |
im = np.frombuffer(r.content, dtype="uint8")
|
50 |
im = cv2.imdecode(im, cv2.IMREAD_COLOR)
|
51 |
else:
|
52 |
+
im = cv2.imread(image.name)
|
53 |
# Model expect BGR!
|
54 |
+
#im = image[:,:,::-1]
|
55 |
|
56 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = min_score
|
57 |
predictor = DefaultPredictor(cfg)
|
58 |
|
59 |
outputs = predictor(im)
|
60 |
|
61 |
+
v = Visualizer(im[:,:,::-1], my_metadata, scale=1.2, instance_mode=ColorMode.IMAGE )
|
62 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
63 |
|
64 |
return out.get_image()
|
|
|
71 |
gr.Interface(
|
72 |
inference,
|
73 |
[gr.inputs.Textbox(label="Image URL", placeholder=""),
|
74 |
+
gr.inputs.Image(type="file", image_mode="RGB", source="upload", optional=False, label="Input Image"),
|
75 |
gr.Slider(minimum=0.0, maximum=1.0, value=0.5, label="Minimum score"),
|
76 |
],
|
77 |
gr.outputs.Image(type="pil", label="Output"),
|