pragnakalp
commited on
Commit
•
703f9d4
1
Parent(s):
55b140e
Update app.py
Browse files
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 |
-
|
18 |
-
|
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 |
-
|
105 |
|
106 |
return text_output
|
107 |
# hostname = socket.gethostname()
|
@@ -115,32 +115,32 @@ def generate_ocr(Method,img):
|
|
115 |
"""
|
116 |
Save generated details
|
117 |
"""
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
# return hostname
|
145 |
|
146 |
"""
|
|
|
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 |
+
picture_path = "image.jpg"
|
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 |
"""
|