Spaces:
Runtime error
Runtime error
debu das
commited on
Commit
·
d4a7cc5
1
Parent(s):
580c5d1
Update app.py
Browse files
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 |
-
|
32 |
-
|
33 |
-
|
34 |
#im_show.save('result.jpg')
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
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')
|