pragnakalp commited on
Commit
facfabe
1 Parent(s): d5c67ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -27
app.py CHANGED
@@ -100,7 +100,7 @@ def generate_ocr(Method,img):
100
  text_output = ocr_with_keras(img)
101
  if Method == 'PaddleOCR':
102
  text_output = ocr_with_paddle(img)
103
- save_details(Method,text_output,img)
104
 
105
  return text_output
106
  # hostname = socket.gethostname()
@@ -114,33 +114,33 @@ def generate_ocr(Method,img):
114
  """
115
  Save generated details
116
  """
117
- def save_details(Method,text_output,img):
118
- method = []
119
- img_path = []
120
- text = []
121
- picture_path = "image.jpg"
122
 
123
- curr_datetime = datetime.now().strftime('%Y-%m-%d %H-%M-%S')
124
- if text_output:
125
- splitted_path = os.path.splitext(picture_path)
126
- modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
127
- cv2.imwrite('images/'+ modified_picture_path, img)
128
- input_img = 'images/'+ modified_picture_path
129
- try:
130
- df = pd.read_csv("AllDetails.csv")
131
- df2 = {'method': Method, 'input_img': input_img, 'generated_text': text_output}
132
- df = df.append(df2, ignore_index = True)
133
- df.to_csv("AllDetails.csv", index=False)
134
- except:
135
- method.append(Method)
136
- img_path.append(input_img)
137
- text.append(text_output)
138
- dict = {'method': method, 'input_img': img_path, 'generated_text': text}
139
- df = pd.DataFrame(dict,index=None)
140
- df.to_csv("AllDetails.csv")
141
 
142
- hostname = get_device_ip_address()
143
- return send_user_email(input_img,hostname,text_output,Method)
144
  # return hostname
145
 
146
  """
@@ -162,7 +162,7 @@ demo = gr.Interface(
162
  )
163
  # .gradio-container.gap-2 {gap: 10rem;row-gap: 10rem;column-gap: 10rem;}
164
  # .gradio-container {background-color: lightgray}
165
- demo.launch()
166
 
167
  # with gr.Blocks(css=".gradio-container {background-color: red}") as demo:
168
  # input = [gr.Image(shape=(224, 224)), gr.Radio(["EasyOCR", "KerasOCR", "PaddleOCR"],text_color="blue")]
 
100
  text_output = ocr_with_keras(img)
101
  if Method == 'PaddleOCR':
102
  text_output = ocr_with_paddle(img)
103
+ # save_details(Method,text_output,img)
104
 
105
  return text_output
106
  # hostname = socket.gethostname()
 
114
  """
115
  Save generated details
116
  """
117
+ # def save_details(Method,text_output,img):
118
+ # method = []
119
+ # img_path = []
120
+ # text = []
121
+ # picture_path = "image.jpg"
122
 
123
+ # curr_datetime = datetime.now().strftime('%Y-%m-%d %H-%M-%S')
124
+ # if text_output:
125
+ # splitted_path = os.path.splitext(picture_path)
126
+ # modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
127
+ # cv2.imwrite('images/'+ modified_picture_path, img)
128
+ # input_img = 'images/'+ modified_picture_path
129
+ # try:
130
+ # df = pd.read_csv("AllDetails.csv")
131
+ # df2 = {'method': Method, 'input_img': input_img, 'generated_text': text_output}
132
+ # df = df.append(df2, ignore_index = True)
133
+ # df.to_csv("AllDetails.csv", index=False)
134
+ # except:
135
+ # method.append(Method)
136
+ # img_path.append(input_img)
137
+ # text.append(text_output)
138
+ # dict = {'method': method, 'input_img': img_path, 'generated_text': text}
139
+ # df = pd.DataFrame(dict,index=None)
140
+ # df.to_csv("AllDetails.csv")
141
 
142
+ # hostname = get_device_ip_address()
143
+ # return send_user_email(input_img,hostname,text_output,Method)
144
  # return hostname
145
 
146
  """
 
162
  )
163
  # .gradio-container.gap-2 {gap: 10rem;row-gap: 10rem;column-gap: 10rem;}
164
  # .gradio-container {background-color: lightgray}
165
+ demo.launch(enable_queue = False)
166
 
167
  # with gr.Blocks(css=".gradio-container {background-color: red}") as demo:
168
  # input = [gr.Image(shape=(224, 224)), gr.Radio(["EasyOCR", "KerasOCR", "PaddleOCR"],text_color="blue")]