Spaces:
Runtime error
Runtime error
Commit ·
3ba81aa
1
Parent(s): 0c2c424
Update app.py
Browse files4 unmodified lines56789101112131415161718192021221 unmodified line242526152728293016 unmodified lines4748495051525354554 unmodified linesimport PILfrom PIL import Image
def 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 tuple bottom_right = tuple(res[0][2]) # bottom right coordinates as tuple draw.rectangle((top_left, bottom_right), outline="blue", width=2) #display image on streamlit st.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 your image", type=['png', 'jpg', 'jpeg'])file = 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 confidence df = pd.DataFrame.from_dict(textdic_easyocr).T st.table(df)
# get boxes on the image rectangle(image, result) else: st.write("Upload your image")app.py+16-1