debu das commited on
Commit
d4a7cc5
1 Parent(s): 580c5d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -28,17 +28,22 @@ def ocr(img,lang):
28
  st.text(txts)
29
  scores = [line[1][1] for line in result]
30
  st.text(scores)
31
- #im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
32
- #im_show = Image.fromarray(im_show)
33
- #st.image(im_show, caption='Sunrise by the mountains')
34
  #im_show.save('result.jpg')
35
 
36
-
37
- uploaded_file = st.file_uploader("Choose a file")
38
- if uploaded_file is not None:
39
- # To read file as bytes:
40
- bytes_data = uploaded_file.getvalue()
41
- st.write(bytes_data)
42
- image = Image.open(io.BytesIO(bytes_data))
43
- st.image(image, caption='Sunrise by the mountains')
44
- ocr(image,'ch')
 
 
 
 
 
 
28
  st.text(txts)
29
  scores = [line[1][1] for line in result]
30
  st.text(scores)
31
+ im_show = draw_ocr(image, boxes, txts, scores, font_path='/simfang.ttf')
32
+ im_show = Image.fromarray(im_show)
33
+ st.image(im_show, caption='Sunrise by the mountains')
34
  #im_show.save('result.jpg')
35
 
36
+ _, col0, _ = st.columns([1, 3, 1])
37
+ with col0:
38
+ st.header("OCR")
39
+ form = st.form(key='my-form')
40
+ uploaded_file = form.file_uploader('Choose your img file', type=['png', 'jpg'],accept_multiple_files=False)
41
+ submit = form.form_submit_button('Submit')
42
+ if submit:
43
+ if uploaded_file is not None:
44
+ bytes_data = uploaded_file.getvalue()
45
+ if bytes_data is not None:
46
+ bytes_data = uploaded_file.read()
47
+ image = Image.open(io.BytesIO(bytes_data))
48
+ st.image(image, caption='Sunrise by the mountains')
49
+ ocr(image,'ch')