Spaces:
Running
Running
pragnakalp
commited on
Commit
•
f801bb8
1
Parent(s):
38efbdd
Add HF token
Browse files
app.py
CHANGED
@@ -28,6 +28,9 @@ import smtplib
|
|
28 |
# if not os.path.isdir('images'):
|
29 |
# os.mkdir('images')
|
30 |
# print("create folder--->")
|
|
|
|
|
|
|
31 |
print(os.getcwd())
|
32 |
def get_device_ip_address():
|
33 |
|
@@ -113,22 +116,22 @@ def generate_ocr(Method,img):
|
|
113 |
if Method == 'PaddleOCR':
|
114 |
text_output = ocr_with_paddle(img)
|
115 |
# save_details(Method,text_output,img)
|
116 |
-
sender="[email protected]"
|
117 |
-
password="httscgatatbbxxur"
|
118 |
-
reciever="[email protected]"
|
119 |
|
120 |
-
s = smtplib.SMTP('smtp.gmail.com', 587)
|
121 |
-
s.starttls()
|
122 |
-
s.ehlo()
|
123 |
-
s.login(sender,password)
|
124 |
|
125 |
-
message = """Subject : Appointment Booking\n\n
|
126 |
-
|
127 |
-
Your OCR generated successfully"""
|
128 |
-
s.sendmail(sender, reciever, message)
|
129 |
-
s.quit()
|
130 |
-
mailsend=1
|
131 |
-
print("Send mail successfully")
|
132 |
return text_output
|
133 |
|
134 |
except Exception as e:
|
@@ -197,6 +200,7 @@ demo = gr.Interface(
|
|
197 |
description="Try OCR with different methods",
|
198 |
theme="darkpeach",
|
199 |
css=".gradio-container {background-color: lightgray} #radio_div {background-color: #FFD8B4; font-size: 40px;}",
|
200 |
-
allow_flagging = "manual"
|
|
|
201 |
)
|
202 |
demo.launch(enable_queue = False)
|
|
|
28 |
# if not os.path.isdir('images'):
|
29 |
# os.mkdir('images')
|
30 |
# print("create folder--->")
|
31 |
+
|
32 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
33 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "OCR-img-to-text-flag")
|
34 |
print(os.getcwd())
|
35 |
def get_device_ip_address():
|
36 |
|
|
|
116 |
if Method == 'PaddleOCR':
|
117 |
text_output = ocr_with_paddle(img)
|
118 |
# save_details(Method,text_output,img)
|
119 |
+
# sender="[email protected]"
|
120 |
+
# password="httscgatatbbxxur"
|
121 |
+
# reciever="[email protected]"
|
122 |
|
123 |
+
# s = smtplib.SMTP('smtp.gmail.com', 587)
|
124 |
+
# s.starttls()
|
125 |
+
# s.ehlo()
|
126 |
+
# s.login(sender,password)
|
127 |
|
128 |
+
# message = """Subject : Appointment Booking\n\n
|
129 |
+
# Hello,
|
130 |
+
# Your OCR generated successfully"""
|
131 |
+
# s.sendmail(sender, reciever, message)
|
132 |
+
# s.quit()
|
133 |
+
# mailsend=1
|
134 |
+
# print("Send mail successfully")
|
135 |
return text_output
|
136 |
|
137 |
except Exception as e:
|
|
|
200 |
description="Try OCR with different methods",
|
201 |
theme="darkpeach",
|
202 |
css=".gradio-container {background-color: lightgray} #radio_div {background-color: #FFD8B4; font-size: 40px;}",
|
203 |
+
allow_flagging = "manual",
|
204 |
+
flagging_callback=hf_writer
|
205 |
)
|
206 |
demo.launch(enable_queue = False)
|