Spaces:
Runtime error
Runtime error
debu das commited on
Commit ·
2208ac7
1
Parent(s): 667e7d5
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,8 @@ def ocr(img,lang):
|
|
| 11 |
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
|
| 12 |
# to switch the language model in order.
|
| 13 |
ocr = PaddleOCR(use_angle_cls=True, lang=lang) # need to run only once to download and load model into memory
|
| 14 |
-
|
|
|
|
| 15 |
result = ocr.ocr(img, cls=True)
|
| 16 |
for idx in range(len(result)):
|
| 17 |
res = result[idx]
|
|
@@ -21,7 +22,7 @@ def ocr(img,lang):
|
|
| 21 |
# draw result
|
| 22 |
from PIL import Image
|
| 23 |
result = result[0]
|
| 24 |
-
image =
|
| 25 |
boxes = [line[0] for line in result]
|
| 26 |
st.text(boxes)
|
| 27 |
txts = [line[1][0] for line in result]
|
|
@@ -44,6 +45,6 @@ if submit:
|
|
| 44 |
bytes_data = uploaded_file.getvalue()
|
| 45 |
if bytes_data is not None:
|
| 46 |
bytes_data = uploaded_file.read()
|
| 47 |
-
image = Image.open(bytes_data)
|
| 48 |
-
st.image(image, caption='
|
| 49 |
ocr(image,'ch')
|
|
|
|
| 11 |
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
|
| 12 |
# to switch the language model in order.
|
| 13 |
ocr = PaddleOCR(use_angle_cls=True, lang=lang) # need to run only once to download and load model into memory
|
| 14 |
+
print(img)
|
| 15 |
+
print(type(img))
|
| 16 |
result = ocr.ocr(img, cls=True)
|
| 17 |
for idx in range(len(result)):
|
| 18 |
res = result[idx]
|
|
|
|
| 22 |
# draw result
|
| 23 |
from PIL import Image
|
| 24 |
result = result[0]
|
| 25 |
+
image = img.convert('RGB')
|
| 26 |
boxes = [line[0] for line in result]
|
| 27 |
st.text(boxes)
|
| 28 |
txts = [line[1][0] for line in result]
|
|
|
|
| 45 |
bytes_data = uploaded_file.getvalue()
|
| 46 |
if bytes_data is not None:
|
| 47 |
bytes_data = uploaded_file.read()
|
| 48 |
+
image = Image.open(io.BytesIO(bytes_data))
|
| 49 |
+
st.image(image, caption='your img')
|
| 50 |
ocr(image,'ch')
|