imanhamid commited on
Commit
ac676e1
·
1 Parent(s): f21c8ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -23,18 +23,19 @@ def predict(
23
  detection_threshold=detection_threshold
24
  )
25
  return samples[0]["img"], preds[0]
26
-
27
- def show_preds(input_image):
28
- img = PIL.Image.fromarray(input_image, "RGB")
29
- pred_dict = model_type.end2end_detect(img, model=model,
30
- class_map=class_map,
31
- detection_threshold=0.5,
32
- display_label=False,
33
- display_bbox=True,
34
- return_img=True,
35
- font_size=16,
36
- label_color="#FF59D6")
37
- return pred_dict["img"]
 
38
 
39
  # Populate examples in Gradio interface
40
  examples = [
 
23
  detection_threshold=detection_threshold
24
  )
25
  return samples[0]["img"], preds[0]
26
+
27
+ def show_preds(input_image, display_list, detection_threshold):
28
+ display_label = ("Label" in display_list)
29
+ display_bbox = ("BBox" in display_list)
30
+
31
+ if detection_threshold==0: detection_threshold=0.5
32
+
33
+ img, pred = predict(model=model, image=input_image, detection_threshold=detection_threshold)
34
+ # print(pred)
35
+ img = draw_pred(img=img, pred=pred, class_map=class_map, display_label=display_label, display_bbox=display_bbox)
36
+ img = PIL.Image.fromarray(img)
37
+ # print("Output Image: ", img.size, type(img))
38
+ return img
39
 
40
  # Populate examples in Gradio interface
41
  examples = [