Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,21 @@ import easyocr
|
|
| 9 |
@spaces.GPU
|
| 10 |
def process(img_path):
|
| 11 |
reader = easyocr.Reader(['en'])
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
title = '车架号识别展示'
|
| 17 |
description = '拖拽图片到识别区开始分析'
|
| 18 |
ip = gr.Image(sources = ['upload'], label = '上传图片', width = '100%', height = '40rem', type = 'filepath')
|
| 19 |
-
op = [gr.Image(sources = None, label = '处理结果', width = '100%', height = '40rem', type = 'filepath'), gr.Textbox()]
|
| 20 |
css = """
|
| 21 |
table.svelte-y11bhb.svelte-y11bhb { max-width: 100%; overflow-x: hidden; }
|
| 22 |
thead.svelte-y11bhb.svelte-y11bhb { visibility: hidden; }
|
|
|
|
| 9 |
@spaces.GPU
|
| 10 |
def process(img_path):
|
| 11 |
reader = easyocr.Reader(['en'])
|
| 12 |
+
results = reader.readtext(img_path)
|
| 13 |
+
ret = ""
|
| 14 |
+
pim = PIL.Image.open(img_path)
|
| 15 |
+
draw = ImageDraw.Draw(pim)
|
| 16 |
+
for (bbox, text, prob) in result:
|
| 17 |
+
p0, p1, p2, p3 = bbox
|
| 18 |
+
draw.line([*p0, *p1, *p2, *p3, *p0], fill = 'yellow', width = 2)
|
| 19 |
+
ret = text
|
| 20 |
+
break
|
| 21 |
+
return [img_path, ret]
|
| 22 |
|
| 23 |
title = '车架号识别展示'
|
| 24 |
description = '拖拽图片到识别区开始分析'
|
| 25 |
ip = gr.Image(sources = ['upload'], label = '上传图片', width = '100%', height = '40rem', type = 'filepath')
|
| 26 |
+
op = [gr.Image(sources = None, label = '处理结果', width = '100%', height = '40rem', type = 'filepath'), gr.Textbox(show_label = False)]
|
| 27 |
css = """
|
| 28 |
table.svelte-y11bhb.svelte-y11bhb { max-width: 100%; overflow-x: hidden; }
|
| 29 |
thead.svelte-y11bhb.svelte-y11bhb { visibility: hidden; }
|