Ammar-alhaj-ali commited on
Commit
82a876f
1 Parent(s): 294e913

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -35,11 +35,11 @@ labels = ['O', 'B-HEADER', 'I-HEADER', 'B-QUESTION', 'I-QUESTION', 'B-ANSWER', '
35
  id2label = {v: k for v, k in enumerate(labels)}
36
  label2color = {
37
  "B-HEADER": 'red',
38
- "I-HEADER": 'green',
39
- "B-QUESTION": 'orange',
40
- "I-QUESTION": "blue",
41
- "B-ANSWER": 'gray',
42
- "I-ANSWERE": 'violet',
43
  "O": 'orange'
44
  }
45
 
@@ -83,9 +83,9 @@ def process_image(image):
83
  font = ImageFont.load_default()
84
  for prediction, box in zip(true_predictions, true_boxes):
85
  predicted_label = iob_to_label(prediction)
86
- draw.rectangle(box, outline='red') #label2color[predicted_label]
87
  print(predicted_label)
88
- draw.text((box[0]+10, box[1]-10), text=predicted_label, fill='red', font=font) #label2color[predicted_label]
89
 
90
  return image
91
 
 
35
  id2label = {v: k for v, k in enumerate(labels)}
36
  label2color = {
37
  "B-HEADER": 'red',
38
+ "I-HEADER": 'red',
39
+ "B-QUESTION": 'red',
40
+ "I-QUESTION": "red",
41
+ "B-ANSWER": 'blue',
42
+ "I-ANSWERE": 'blue',
43
  "O": 'orange'
44
  }
45
 
 
83
  font = ImageFont.load_default()
84
  for prediction, box in zip(true_predictions, true_boxes):
85
  predicted_label = iob_to_label(prediction)
86
+ draw.rectangle(box, outline=label2color[predicted_label]) #label2color[predicted_label]
87
  print(predicted_label)
88
+ draw.text((box[0]+10, box[1]-10), text=predicted_label, fill=label2color[predicted_label], font=font) #label2color[predicted_label]
89
 
90
  return image
91