Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -48,16 +48,16 @@ def inference(image_url, image, min_score):
|
|
48 |
if r:
|
49 |
im = np.frombuffer(r.content, dtype="uint8")
|
50 |
im = cv2.imdecode(im, cv2.IMREAD_COLOR)
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = min_score
|
56 |
predictor = DefaultPredictor(cfg)
|
57 |
|
58 |
outputs = predictor(image)
|
59 |
|
60 |
-
v = Visualizer(
|
61 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
62 |
|
63 |
return out.get_image()
|
|
|
48 |
if r:
|
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(image)
|
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()
|