Spaces:
Runtime error
Runtime error
Update app.py
Browse files17 unmodified lines181920212223242526272829301 unmodified line32333435363738394041424344454647484950515253541 unmodified line565758596061626317 unmodified lines# main titlest.title("Get text from image with EasyOCR")# subtitlest.markdown("## EasyOCR 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:1 unmodified linest.image(image) #display# it will only detect the English and Turkish part of the image as textreader = easyocr.Reader(['en','ja'], gpu=False)result = reader.readtext(np.array(image)) # turn image to numpy array# Add a placeholder# latest_iteration = st.empty()# bar = st.progress(0)# for i in range(100):# Update the progress bar with each iteration.# latest_iteration.text(f'Iteration {i+1}')# bar.progress(i + 1)# time.sleep(0.1)# print all predicted text:for idx in range(len(result)):pred_text = result[idx][1]st.write(pred_text)# collect the results in the dictionary:textdic_easyocr = {}1 unmodified linepred_coor = result[idx][0]pred_text = result[idx][1]pred_confidence = result[idx][2]textdic_easyocr[pred_text] = {}textdic_easyocr[pred_text]['pred_confidence'] = pred_confidence# create a data frame which shows the predicted text and prediction confidencedf = pd.DataFrame.from_dict(textdic_easyocr).T17 unmodified lines181920212223242526272829301 unmodified line3233343536373839401 unmodified line42434445464748495017 unmodified lines# main titlest.title("Recognize text and locations from flowchart")# subtitlest.markdown("## FlowchartOCR")# upload image filefile = st.file_uploader(label = "Upload Image", type=['png', 'jpg', 'jpeg'])#read the csv file and display the dataframeif file is not None:1 unmodified linest.image(image) #display# it will only detect the English and Turkish part of the image as textreader = easyocr.Reader(['en'], gpu=False)result = reader.readtext(np.array(image)) # turn image to numpy array# collect the results in the dictionary:textdic_easyocr = {}1 unmodified linepred_coor = result[idx][0]pred_text = result[idx][1]pred_confidence = result[idx][2]if(pred_confidence>0.6):textdic_easyocr[pred_text] = {}textdic_easyocr[pred_text]['pred_confidence'] = pred_confidence# create a data frame which shows the predicted text and prediction confidencedf = pd.DataFrame.from_dict(textdic_easyocr).T
app.py+7-20