Spaces:
Sleeping
Sleeping
File size: 1,263 Bytes
7e6e008 7ec50f8 7e6e008 7ec50f8 7e6e008 7ec50f8 7e6e008 7ec50f8 7e6e008 7ec50f8 7e6e008 7ec50f8 7e6e008 7ec50f8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import streamlit as st
from PIL import Image
from easyocr import Reader
import os
# 讛讙讚专转 讻讜转专转 讛讗驻诇讬拽爪讬讛
st.title("OCR 讘注讘专讬转 注诐 EasyOCR")
# 讬爪讬专转 讗讜讘讬讬拽讟 讛-Reader 砖诇 EasyOCR 注诐 注讘专讬转 (he)
# gpu=False 讻讬 讘-Hugging Face Spaces 讘讞讬谞诐 讗讬谉 GPU
reader = Reader(['he'], gpu=False)
st.write("讛注诇讛 转诪讜谞讛 注诐 讻转讘 讬讚 讘注讘专讬转, 讜谞谞住讛 诇讝讛讜转 讗转 讛讟拽住讟")
uploaded_file = st.file_uploader("讘讞专/讙专讜专 转诪讜谞讛", type=["jpg","jpeg","png"])
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption="讛转诪讜谞讛 砖讛讜注诇转讛", use_container_width=True)
if st.button("驻注谞讞 讟拽住讟"):
with st.spinner("诪讘爪注 OCR..."):
# EasyOCR 讬讻讜诇 诇拽讘诇 讙诐 path, 讗讘诇 谞砖转诪砖 讘驻专诪讟专 detail=0 诇拽讘诇转 讟拽住讟 谞讟讜
# 谞拽专讗 讗转 讛转诪讜谞讛 讬砖讬专讜转 诪讛讘讬讬讟讬诐:
result = reader.readtext(uploaded_file, detail=0)
st.subheader("讟拽住讟 诪讝讜讛讛:")
if result:
st.write(" ".join(result))
else:
st.write("诇讗 讝讜讛讛 讟拽住讟, 讬讬转讻谉 砖讛转诪讜谞讛 诇讗 讘专讜专讛 讗讜 砖讛讻转讘 诪讜专讻讘 诪讚讬.")
|