pragnakalp commited on
Commit
ada7afd
1 Parent(s): 1937a3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -14,8 +14,8 @@ from paddleocr import PaddleOCR
14
  import socket
15
  from send_email_user import send_user_email
16
 
17
- if not os.path.isdir('images'):
18
- os.mkdir('images')
19
 
20
  def get_device_ip_address():
21
 
@@ -101,7 +101,7 @@ def generate_ocr(Method,img):
101
  text_output = ocr_with_keras(img)
102
  if Method == 'PaddleOCR':
103
  text_output = ocr_with_paddle(img)
104
- save_details(Method,text_output,img)
105
 
106
  return text_output
107
  # hostname = socket.gethostname()
@@ -115,34 +115,34 @@ def generate_ocr(Method,img):
115
  """
116
  Save generated details
117
  """
118
- def save_details(Method,text_output,img):
119
- method = []
120
- img_path = []
121
- text = []
122
- input_img = ''
123
- hostname = ''
124
- picture_path = "image.jpg"
125
- curr_datetime = datetime.now().strftime('%Y-%m-%d %H-%M-%S')
126
- if text_output:
127
- splitted_path = os.path.splitext(picture_path)
128
- modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
129
- cv2.imwrite('images/'+ modified_picture_path, img)
130
- input_img = 'images/'+ modified_picture_path
131
- try:
132
- df = pd.read_csv("AllDetails.csv")
133
- df2 = {'method': Method, 'input_img': input_img, 'generated_text': text_output}
134
- df = df.append(df2, ignore_index = True)
135
- df.to_csv("AllDetails.csv", index=False)
136
- except:
137
- method.append(Method)
138
- img_path.append(input_img)
139
- text.append(text_output)
140
- dict = {'method': method, 'input_img': img_path, 'generated_text': text}
141
- df = pd.DataFrame(dict,index=None)
142
- df.to_csv("AllDetails.csv")
143
 
144
- hostname = get_device_ip_address()
145
- return send_user_email(input_img,hostname,text_output,Method)
146
  # return hostname
147
 
148
  """
 
14
  import socket
15
  from send_email_user import send_user_email
16
 
17
+ # if not os.path.isdir('images'):
18
+ # os.mkdir('images')
19
 
20
  def get_device_ip_address():
21
 
 
101
  text_output = ocr_with_keras(img)
102
  if Method == 'PaddleOCR':
103
  text_output = ocr_with_paddle(img)
104
+ # save_details(Method,text_output,img)
105
 
106
  return text_output
107
  # hostname = socket.gethostname()
 
115
  """
116
  Save generated details
117
  """
118
+ # def save_details(Method,text_output,img):
119
+ # method = []
120
+ # img_path = []
121
+ # text = []
122
+ # input_img = ''
123
+ # hostname = ''
124
+ # picture_path = "image.jpg"
125
+ # curr_datetime = datetime.now().strftime('%Y-%m-%d %H-%M-%S')
126
+ # if text_output:
127
+ # splitted_path = os.path.splitext(picture_path)
128
+ # modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
129
+ # cv2.imwrite('images/'+ modified_picture_path, img)
130
+ # input_img = 'images/'+ modified_picture_path
131
+ # try:
132
+ # df = pd.read_csv("AllDetails.csv")
133
+ # df2 = {'method': Method, 'input_img': input_img, 'generated_text': text_output}
134
+ # df = df.append(df2, ignore_index = True)
135
+ # df.to_csv("AllDetails.csv", index=False)
136
+ # except:
137
+ # method.append(Method)
138
+ # img_path.append(input_img)
139
+ # text.append(text_output)
140
+ # dict = {'method': method, 'input_img': img_path, 'generated_text': text}
141
+ # df = pd.DataFrame(dict,index=None)
142
+ # df.to_csv("AllDetails.csv")
143
 
144
+ # hostname = get_device_ip_address()
145
+ # return send_user_email(input_img,hostname,text_output,Method)
146
  # return hostname
147
 
148
  """