Yashvj123 commited on
Commit
c9c6088
·
verified ·
1 Parent(s): 3dd03eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -110,6 +110,11 @@ def save_text_as_image(text, file_path):
110
 
111
  set_background("background_img.jpg")
112
 
 
 
 
 
 
113
  st.sidebar.title("💊 MediAssist")
114
  st.sidebar.markdown("Analyze prescriptions with ease using AI")
115
  st.sidebar.markdown("---")
@@ -150,8 +155,7 @@ if uploaded_file:
150
  dilated_path = orig_path.replace(".png", "_dilated.png")
151
  cv2.imwrite(dilated_path, dilated)
152
 
153
- # OCR
154
- reader = easyocr.Reader(['en'])
155
  text_list = reader.readtext(dilated, detail=0)
156
  text = "\n".join(text_list)
157
 
 
110
 
111
  set_background("background_img.jpg")
112
 
113
+ # OCR
114
+ @st.cache_resource
115
+ def load_easyocr_reader():
116
+ return easyocr.Reader(['en'])
117
+
118
  st.sidebar.title("💊 MediAssist")
119
  st.sidebar.markdown("Analyze prescriptions with ease using AI")
120
  st.sidebar.markdown("---")
 
155
  dilated_path = orig_path.replace(".png", "_dilated.png")
156
  cv2.imwrite(dilated_path, dilated)
157
 
158
+ reader = load_easyocr_reader()
 
159
  text_list = reader.readtext(dilated, detail=0)
160
  text = "\n".join(text_list)
161