Spaces:
Runtime error
Runtime error
Commit ·
3ba81aa
1
Parent(s): 0c2c424
Update app.py
Browse files4 unmodified lines56789101 unmodified line1213141516171816 unmodified lines3536373839404 unmodified linesimport PILfrom PIL import Image# main titlest.title("Get text from image with EasyOCR")1 unmodified linest.markdown("## EasyOCRR with Streamlit")# upload image filefile = st.file_uploader(label = "Upload your image", type=['png', 'jpg', 'jpeg'])#read the csv file and display the dataframeif file is not None:16 unmodified lines# create a dataframe which shows the predicted text and prediction confidencedf = pd.DataFrame.from_dict(textdic_easyocr).Tst.table(df)else:st.write("Upload your image")4 unmodified lines56789101112131415161718192021221 unmodified line2425262728293016 unmodified lines4748495051525354554 unmodified linesimport PILfrom PIL import Imagedef rectangle(image, result):# https://www.blog.pythonlibrary.org/2021/02/23/drawing-shapes-on-images-with-python-and-pillow/""" draw rectangles on image based on predicted coordinates"""draw = ImageDraw.Draw(image)for res in result:top_left = tuple(res[0][0]) # top left coordinates as tuplebottom_right = tuple(res[0][2]) # bottom right coordinates as tupledraw.rectangle((top_left, bottom_right), outline="blue", width=2)#display image on streamlitst.image(image)# main titlest.title("Get text from image with EasyOCR")1 unmodified linest.markdown("## EasyOCRR with Streamlit")# upload image filefile = st.file_uploader(label = "Upload Here", type=['png', 'jpg', 'jpeg'])#read the csv file and display the dataframeif file is not None:16 unmodified lines# create a dataframe which shows the predicted text and prediction confidencedf = pd.DataFrame.from_dict(textdic_easyocr).Tst.table(df)# get boxes on the imagerectangle(image, result)else:st.write("Upload your image")
app.py+16-1