JustinLin610 commited on
Commit
271a2e6
1 Parent(s): 7961dd8

update dataframes

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -76,7 +76,7 @@ def draw_boxes(image, bounds, color='red', width=4):
76
  draw = ImageDraw.Draw(image)
77
  for i, bound in enumerate(bounds):
78
  p0, p1, p2, p3 = bound
79
- draw.text(p0, str(i+1), fill=color, align='center')
80
  draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
81
  return image
82
 
@@ -183,7 +183,7 @@ def ocr(img):
183
  result, scores = eval_step(task, generator, models, sample)
184
  ocr_result.append([str(i+1), result[0]['ocr'].replace(' ', '')])
185
 
186
- result = pd.DataFrame(ocr_result)
187
 
188
  return out_img, result
189
 
@@ -199,7 +199,7 @@ examples = [['shupai.png'], ['chinese.jpg'], ['gaidao.jpeg'], ['qiaodaima.png'],
199
  ['benpao.jpeg'], ['wanli.png'], ['xsd.jpg']]
200
  io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='filepath', label='Image'),
201
  outputs=[gr.outputs.Image(type='pil', label='Image'),
202
- gr.outputs.Dataframe(headers=['Box ID', 'Text'], type='pandas', label='OCR Results')],
203
  title=title, description=description, article=article, examples=examples)
204
  io.launch()
205
 
 
76
  draw = ImageDraw.Draw(image)
77
  for i, bound in enumerate(bounds):
78
  p0, p1, p2, p3 = bound
79
+ draw.text((p0[0]+5, p0[1]+5), str(i+1), fill=color, align='center')
80
  draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
81
  return image
82
 
 
183
  result, scores = eval_step(task, generator, models, sample)
184
  ocr_result.append([str(i+1), result[0]['ocr'].replace(' ', '')])
185
 
186
+ result = pd.DataFrame(ocr_result, columns=['Box ID', 'Text'])
187
 
188
  return out_img, result
189
 
 
199
  ['benpao.jpeg'], ['wanli.png'], ['xsd.jpg']]
200
  io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='filepath', label='Image'),
201
  outputs=[gr.outputs.Image(type='pil', label='Image'),
202
+ gr.outputs.Dataframe(type='pandas', label='OCR Results')],
203
  title=title, description=description, article=article, examples=examples)
204
  io.launch()
205