Spaces:
Sleeping
Sleeping
File size: 1,344 Bytes
e4d7281 a3e32eb e4d7281 a3e32eb e4d7281 |
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 32 33 34 35 36 |
import pandas as pd
import numpy as np
import streamlit as st
import easyocr
import PIL
from PIL import Image, ImageDraw
from matplotlib import pyplot as plt
from KZReader import KZReader
# main title
st.set_page_config(layout="wide")
st.title("Суретте жазылған текстті анықта")
# subtitle
st.markdown("## әзірше PNG, JPG форматтарың ғана жүктеуге болады")
col1, col2 = st.columns(2)
uploaded_file = col1.file_uploader("Upload your file here ",type=['png','jpeg','jpg','pdf'])
if uploaded_file is not None:
col1.image(uploaded_file) #display
#print("GOGO ",type(uploaded_file))
image_extensions = (".jpg", ".jpeg", ".png")
pdf_extensions = (".pdf")
if uploaded_file.name.lower().endswith(image_extensions):
image = Image.open(uploaded_file)
reader = KZReader() #easyocr.Reader(['tr','en'], gpu=False)
result = reader.readtext(np.array(image),paragraph=True) # turn image to numpy array
#print(len(result))
result_text = "\n\n".join([item[1] for item in result])
col2.markdown(result_text)
elif uploaded_file.name.lower().endswith(pdf_extensions):
print("PDF file")
col2.markdown("PDF file")
else:
print(f'unsupported file {image_name}')
col2.markdown("ERROR") |