Spaces:
Sleeping
Sleeping
pragnakalp
commited on
Commit
•
7daa8fa
1
Parent(s):
797a7cd
Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,8 @@ import socket
|
|
15 |
from send_email_user import send_user_email
|
16 |
|
17 |
# if not os.path.isdir('images'):
|
18 |
-
os.mkdir('images')
|
19 |
-
print("create folder--->")
|
20 |
def get_device_ip_address():
|
21 |
|
22 |
if os.name == "nt":
|
@@ -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,34 +115,34 @@ 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 |
-
|
145 |
-
|
146 |
# return hostname
|
147 |
|
148 |
"""
|
|
|
15 |
from send_email_user import send_user_email
|
16 |
|
17 |
# if not os.path.isdir('images'):
|
18 |
+
# os.mkdir('images')
|
19 |
+
# print("create folder--->")
|
20 |
def get_device_ip_address():
|
21 |
|
22 |
if os.name == "nt":
|
|
|
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(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 |
"""
|