phamvi856 commited on
Commit
9255af8
1 Parent(s): 811ff7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -72,8 +72,8 @@ def process_image(image):
72
  extracted_content = {}
73
  for idx, box in enumerate(encoding.bbox.tolist()):
74
  predicted_label = id2label[predicted_labels[idx]]
75
- box_width = box[2] - box[0]
76
- box_height = box[3] - box[1]
77
  normalized_box = [
78
  box[0] * width / 1000,
79
  box[1] * height / 1000,
@@ -87,8 +87,8 @@ def process_image(image):
87
  font = ImageFont.load_default()
88
  for prediction, box in zip(predicted_labels, encoding.bbox.tolist()):
89
  predicted_label = iob_to_label(id2label[prediction])
90
- box_width = box[2] - box[0]
91
- box_height = box[3] - box[1]
92
  normalized_box = [
93
  box[0] * width / 1000,
94
  box[1] * height / 1000,
@@ -120,3 +120,4 @@ iface = gr.Interface(fn=process_image,
120
  enable_queue=True)
121
 
122
  iface.launch(inline=False, share=False, debug=False)
 
 
72
  extracted_content = {}
73
  for idx, box in enumerate(encoding.bbox.tolist()):
74
  predicted_label = id2label[predicted_labels[idx]]
75
+ box_width = np.array(box)[2] - np.array(box)[0]
76
+ box_height = np.array(box)[3] - np.array(box)[1]
77
  normalized_box = [
78
  box[0] * width / 1000,
79
  box[1] * height / 1000,
 
87
  font = ImageFont.load_default()
88
  for prediction, box in zip(predicted_labels, encoding.bbox.tolist()):
89
  predicted_label = iob_to_label(id2label[prediction])
90
+ box_width = np.array(box)[2] - np.array(box)[0]
91
+ box_height = np.array(box)[3] - np.array(box)[1]
92
  normalized_box = [
93
  box[0] * width / 1000,
94
  box[1] * height / 1000,
 
120
  enable_queue=True)
121
 
122
  iface.launch(inline=False, share=False, debug=False)
123
+