phamvi856 commited on
Commit
50bd582
·
1 Parent(s): 391f127

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -72,7 +72,7 @@ def process_image(image):
72
  predicted_label = id2label[predicted_labels[idx]]
73
  box_width = np.array(box)[2] - np.array(box)[0]
74
  box_height = np.array(box)[3] - np.array(box)[1]
75
- normalized_box = unnormalize_box(box, width, height)
76
  extracted_content[predicted_label] = image.crop(normalized_box).copy()
77
 
78
  # Draw predictions over the image
@@ -82,7 +82,7 @@ def process_image(image):
82
  predicted_label = iob_to_label(id2label[prediction])
83
  box_width = np.array(box)[2] - np.array(box)[0]
84
  box_height = np.array(box)[3] - np.array(box)[1]
85
- normalized_box = unnormalize_box(box, width, height)
86
  draw.rectangle(normalized_box, outline=label2color[predicted_label])
87
  draw.text((normalized_box[0] + 10, normalized_box[1] - 10), text=predicted_label, fill=label2color[predicted_label], font=font)
88
 
 
72
  predicted_label = id2label[predicted_labels[idx]]
73
  box_width = np.array(box)[2] - np.array(box)[0]
74
  box_height = np.array(box)[3] - np.array(box)[1]
75
+ normalized_box = [int(coord) for coord in unnormalize_box(box, width, height)]
76
  extracted_content[predicted_label] = image.crop(normalized_box).copy()
77
 
78
  # Draw predictions over the image
 
82
  predicted_label = iob_to_label(id2label[prediction])
83
  box_width = np.array(box)[2] - np.array(box)[0]
84
  box_height = np.array(box)[3] - np.array(box)[1]
85
+ normalized_box = [int(coord) for coord in unnormalize_box(box, width, height)]
86
  draw.rectangle(normalized_box, outline=label2color[predicted_label])
87
  draw.text((normalized_box[0] + 10, normalized_box[1] - 10), text=predicted_label, fill=label2color[predicted_label], font=font)
88