Spaces:
Sleeping
Sleeping
Add extra demo file
Browse files- img.jpg +0 -0
- img_demo_1.jpg +0 -0
- img_demo_2.jpg +0 -0
- img_demo_2.png +0 -0
- pages/App.py +14 -7
img.jpg
CHANGED
img_demo_1.jpg
CHANGED
img_demo_2.jpg
ADDED
img_demo_2.png
DELETED
Binary file (45.6 kB)
|
|
pages/App.py
CHANGED
@@ -443,7 +443,7 @@ def process_detect(in_image_path, _in_list_images, _in_list_readers, in_list_par
|
|
443 |
# Visualization
|
444 |
if easyocr_boxes_coordinates:
|
445 |
easyocr_image_detect = draw_detected(_in_list_images[0], easyocr_boxes_coordinates, \
|
446 |
-
in_color, 'None',
|
447 |
else:
|
448 |
easyocr_boxes_coordinates = easyocr_status
|
449 |
##
|
@@ -824,7 +824,7 @@ def draw_reco_images(in_image, in_boxes_coordinates, in_list_texts, in_list_conf
|
|
824 |
cv2.putText(list_reco_images[ind_tessocr], \
|
825 |
in_df_results_tesseract.iloc[num]['text'], \
|
826 |
(box[0][0],int(np.round((box[0][1]+box[2][1])/2,0))), \
|
827 |
-
cv2.FONT_HERSHEY_DUPLEX, in_font_scale, text_color,
|
828 |
|
829 |
with show_reco.container():
|
830 |
# Draw the results, 2 images per line
|
@@ -852,6 +852,7 @@ def draw_reco_images(in_image, in_boxes_coordinates, in_list_texts, in_list_conf
|
|
852 |
cols[ind_col].write(list_reco_status[ind], \
|
853 |
use_column_width=True)
|
854 |
|
|
|
855 |
###
|
856 |
def highlight():
|
857 |
"""Draw recognized text on original image, for each OCR solution used
|
@@ -901,7 +902,7 @@ def get_demo():
|
|
901 |
"""
|
902 |
|
903 |
out_img_demo_1 = Image.open("img_demo_1.jpg")
|
904 |
-
out_img_demo_2 = Image.open("img_demo_2.
|
905 |
|
906 |
return out_img_demo_1, out_img_demo_2
|
907 |
|
@@ -911,7 +912,13 @@ def get_demo():
|
|
911 |
|
912 |
##----------- Initializations ---------------------------------------------------------------------
|
913 |
#print("PID : ", os.getpid())
|
914 |
-
st.set_page_config(layout="wide")
|
|
|
|
|
|
|
|
|
|
|
|
|
915 |
st.title("OCR solutions comparator")
|
916 |
st.markdown("##### *EasyOCR, PPOCR, MMOCR, Tesseract*")
|
917 |
#st.markdown("#### PID : " + str(os.getpid()))
|
@@ -952,7 +959,7 @@ if img_typ == 'Use a demo file':
|
|
952 |
if demo_used == 'File 1':
|
953 |
image_file = 'img_demo_1.jpg'
|
954 |
else:
|
955 |
-
image_file = 'img_demo_2.
|
956 |
|
957 |
##----------- Process input image -----------------------------------------------------------------
|
958 |
if image_file is not None:
|
@@ -1168,7 +1175,7 @@ Use rectlar box to calculate faster, and polygonal box more accurate for curved
|
|
1168 |
horizontal=True, on_change=highlight)
|
1169 |
|
1170 |
##----------- Form with hyperparameters for recognition -----------------------
|
1171 |
-
st.markdown("##### Hyperparameters values for recognition")
|
1172 |
with st.form("form2"):
|
1173 |
with st.expander("Choose recognition hyperparameters for " + reader_type_list[0], \
|
1174 |
expanded=False):
|
@@ -1341,7 +1348,7 @@ Use rectlar box to calculate faster, and polygonal box more accurate for curved
|
|
1341 |
in_conf_threshold=st.session_state.conf_threshold_sld)
|
1342 |
|
1343 |
st.subheader("Recognition details")
|
1344 |
-
with st.expander("Detailed areas for EasyOCR, PPOCR, MMOCR", expanded=
|
1345 |
cols = st.columns(cols_size)
|
1346 |
cols[0].markdown('#### Detected area')
|
1347 |
for i in range(1, (len(reader_type_list)-1)*2, 2):
|
|
|
443 |
# Visualization
|
444 |
if easyocr_boxes_coordinates:
|
445 |
easyocr_image_detect = draw_detected(_in_list_images[0], easyocr_boxes_coordinates, \
|
446 |
+
in_color, 'None', 3)
|
447 |
else:
|
448 |
easyocr_boxes_coordinates = easyocr_status
|
449 |
##
|
|
|
824 |
cv2.putText(list_reco_images[ind_tessocr], \
|
825 |
in_df_results_tesseract.iloc[num]['text'], \
|
826 |
(box[0][0],int(np.round((box[0][1]+box[2][1])/2,0))), \
|
827 |
+
cv2.FONT_HERSHEY_DUPLEX, in_font_scale, text_color, 2)
|
828 |
|
829 |
with show_reco.container():
|
830 |
# Draw the results, 2 images per line
|
|
|
852 |
cols[ind_col].write(list_reco_status[ind], \
|
853 |
use_column_width=True)
|
854 |
|
855 |
+
st.markdown(' 💡 Wrong font size? you can adjust it below:')
|
856 |
###
|
857 |
def highlight():
|
858 |
"""Draw recognized text on original image, for each OCR solution used
|
|
|
902 |
"""
|
903 |
|
904 |
out_img_demo_1 = Image.open("img_demo_1.jpg")
|
905 |
+
out_img_demo_2 = Image.open("img_demo_2.jpg")
|
906 |
|
907 |
return out_img_demo_1, out_img_demo_2
|
908 |
|
|
|
912 |
|
913 |
##----------- Initializations ---------------------------------------------------------------------
|
914 |
#print("PID : ", os.getpid())
|
915 |
+
st.set_page_config(page_title='OCR Comparator', layout ="wide")
|
916 |
+
st.markdown(f'''
|
917 |
+
<style>
|
918 |
+
section[data-testid="stSidebar"] .css-ng1t4o {{width: 14rem;}}
|
919 |
+
section[data-testid="stSidebar"] .css-1d391kg {{width: 14rem;}}
|
920 |
+
</style>
|
921 |
+
''',unsafe_allow_html=True)
|
922 |
st.title("OCR solutions comparator")
|
923 |
st.markdown("##### *EasyOCR, PPOCR, MMOCR, Tesseract*")
|
924 |
#st.markdown("#### PID : " + str(os.getpid()))
|
|
|
959 |
if demo_used == 'File 1':
|
960 |
image_file = 'img_demo_1.jpg'
|
961 |
else:
|
962 |
+
image_file = 'img_demo_2.jpg'
|
963 |
|
964 |
##----------- Process input image -----------------------------------------------------------------
|
965 |
if image_file is not None:
|
|
|
1175 |
horizontal=True, on_change=highlight)
|
1176 |
|
1177 |
##----------- Form with hyperparameters for recognition -----------------------
|
1178 |
+
st.markdown("##### Hyperparameters values for recognition:")
|
1179 |
with st.form("form2"):
|
1180 |
with st.expander("Choose recognition hyperparameters for " + reader_type_list[0], \
|
1181 |
expanded=False):
|
|
|
1348 |
in_conf_threshold=st.session_state.conf_threshold_sld)
|
1349 |
|
1350 |
st.subheader("Recognition details")
|
1351 |
+
with st.expander("Detailed areas for EasyOCR, PPOCR, MMOCR", expanded=True):
|
1352 |
cols = st.columns(cols_size)
|
1353 |
cols[0].markdown('#### Detected area')
|
1354 |
for i in range(1, (len(reader_type_list)-1)*2, 2):
|