9prayer commited on
Commit
2c92c70
·
verified ·
1 Parent(s): 0574388

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -7,21 +7,20 @@ import gradio as gr
7
  import easyocr
8
 
9
  @spaces.GPU
10
- def process(img):
11
- img.save('uploaded_image.png')
12
  reader = easyocr.Reader(['en'])
13
- bounds = reader.readtext('uploaded_image.png')
14
- im = PIL.Image.open(img.name)
15
- draw = ImageDraw.Draw(image)
16
  for bound in bounds:
17
  p0, p1, p2, p3 = bound[0]
18
  draw.line([*p0, *p1, *p2, *p3, *p0], fill = 'yellow', width = 2)
19
- im.save('result.jpg')
20
  return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
21
 
22
  title = '车架号识别展示'
23
  description = '拖拽图片到识别区开始分析'
24
- ip = gr.Image(sources = ['upload'], label = '上传图片', width = '100%', height = '40rem', type = 'pil')
25
  op = [gr.Image(sources = [], label = '处理结果', width = '100%', height = '40rem'), gr.Dataframe(col_count = (1, 'fixed'), show_label = False)]
26
  css = """
27
  table.svelte-y11bhb.svelte-y11bhb { max-width: 100%; overflow-x: hidden; }
 
7
  import easyocr
8
 
9
  @spaces.GPU
10
+ def process(img_path):
 
11
  reader = easyocr.Reader(['en'])
12
+ bounds = reader.readtext(img_path)
13
+ pim = PIL.Image.open(img_path)
14
+ draw = ImageDraw.Draw(pim)
15
  for bound in bounds:
16
  p0, p1, p2, p3 = bound[0]
17
  draw.line([*p0, *p1, *p2, *p3, *p0], fill = 'yellow', width = 2)
18
+ pim.save('result.jpg')
19
  return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
20
 
21
  title = '车架号识别展示'
22
  description = '拖拽图片到识别区开始分析'
23
+ ip = gr.Image(sources = ['upload'], label = '上传图片', width = '100%', height = '40rem', type = 'filepath')
24
  op = [gr.Image(sources = [], label = '处理结果', width = '100%', height = '40rem'), gr.Dataframe(col_count = (1, 'fixed'), show_label = False)]
25
  css = """
26
  table.svelte-y11bhb.svelte-y11bhb { max-width: 100%; overflow-x: hidden; }