nickmuchi commited on
Commit
6704fb2
·
1 Parent(s): 2cf7863

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -45,7 +45,7 @@ def visualize_prediction(img, output_dict, threshold=0.5, id2label=None):
45
  boxes = output_dict["boxes"][keep].tolist()
46
  scores = output_dict["scores"][keep].tolist()
47
  labels = output_dict["labels"][keep].tolist()
48
- print(labels)
49
  if id2label is not None:
50
 
51
  labels = [id2label[x] for x in labels]
@@ -56,8 +56,9 @@ def visualize_prediction(img, output_dict, threshold=0.5, id2label=None):
56
  ax = plt.gca()
57
  colors = COLORS * 100
58
  for score, (xmin, ymin, xmax, ymax), label, color in zip(scores, boxes, labels, colors):
59
- ax.add_patch(plt.Rectangle((xmin, ymin), xmax - xmin, ymax - ymin, fill=False, color=color, linewidth=10))
60
- ax.text(xmin, ymin, f"{label}: {score:0.2f}", fontsize=60, bbox=dict(facecolor="yellow", alpha=0.8))
 
61
  plt.axis("off")
62
  return fig2img(plt.gcf())
63
 
 
45
  boxes = output_dict["boxes"][keep].tolist()
46
  scores = output_dict["scores"][keep].tolist()
47
  labels = output_dict["labels"][keep].tolist()
48
+
49
  if id2label is not None:
50
 
51
  labels = [id2label[x] for x in labels]
 
56
  ax = plt.gca()
57
  colors = COLORS * 100
58
  for score, (xmin, ymin, xmax, ymax), label, color in zip(scores, boxes, labels, colors):
59
+ if label == 'license-plates':
60
+ ax.add_patch(plt.Rectangle((xmin, ymin), xmax - xmin, ymax - ymin, fill=False, color=color, linewidth=10))
61
+ ax.text(xmin, ymin, f"{label}: {score:0.2f}", fontsize=60, bbox=dict(facecolor="yellow", alpha=0.8))
62
  plt.axis("off")
63
  return fig2img(plt.gcf())
64