Spaces:
Runtime error
Runtime error
import tempfile | |
import os | |
import streamlit as st | |
import paddlehub as hub | |
from PIL import Image | |
import io | |
pp_ocrv3 = hub.Module(name="ch_pp-ocrv3") | |
def inference(img): | |
with tempfile.TemporaryDirectory() as tempdir_name: | |
pp_ocrv3.recognize_text(paths=[img],use_gpu=False,output_dir=tempdir_name,visualization=True) | |
result_names = os.listdir(tempdir_name) | |
output_image = Image.open(os.path.join(tempdir_name, result_names[0])) | |
return [output_image] | |
title="ch_PP-OCRv3" | |
description="ch_PP-OCRv3 is a practical ultra-lightweight OCR system developed by PaddleOCR." | |
examples=[['test.png']] | |
uploaded_file = st.file_uploader("Choose a file") | |
if uploaded_file is not None: | |
# To read file as bytes: | |
bytes_data = uploaded_file.getvalue() | |
st.write(bytes_data) | |
image = Image.open(io.BytesIO(bytes_data)) | |
st.image(image, caption='Sunrise by the mountains') |