Kaushik Bar commited on
Commit
d362067
·
1 Parent(s): 5c712db
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from paddleocr import PaddleOCR, draw_ocr
2
- from PIL import Image
3
  import gradio as gr
4
  import torch
5
 
@@ -11,8 +11,11 @@ def inference(img, lang):
11
  boxes = [line[0] for line in result]
12
  txts = [line[1][0] for line in result]
13
  scores = [line[1][1] for line in result]
 
 
14
  im_show = draw_ocr(image, boxes, txts, scores,
15
- font_path='https://huggingface.co/spaces/PaddlePaddle/PaddleOCR/blob/main/simfang.ttf')
 
16
  im_show = Image.fromarray(im_show)
17
  im_show.save('result.jpg')
18
  return 'result.jpg'
 
1
  from paddleocr import PaddleOCR, draw_ocr
2
+ from PIL import Image, ImageFont
3
  import gradio as gr
4
  import torch
5
 
 
11
  boxes = [line[0] for line in result]
12
  txts = [line[1][0] for line in result]
13
  scores = [line[1][1] for line in result]
14
+
15
+ font_type = ImageFont.truetype("simfang.ttf", 18)
16
  im_show = draw_ocr(image, boxes, txts, scores,
17
+ font_path=font_type)
18
+
19
  im_show = Image.fromarray(im_show)
20
  im_show.save('result.jpg')
21
  return 'result.jpg'