Spaces:
Runtime error
Runtime error
Commit
•
4711ea0
1
Parent(s):
666d384
Update app.py
Browse files
app.py
CHANGED
@@ -52,8 +52,12 @@ def ocr_idcard():
|
|
52 |
|
53 |
|
54 |
ocrResult = TTVOcrProcess(file_path1.encode('utf-8'), file_path2.encode('utf-8'))
|
55 |
-
ocrResDict = json.loads(ocrResult)
|
56 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
if_check = ttv_if_checker(file_path1.encode('utf-8'))
|
59 |
response = jsonify({"status": status, "data": ocrResDict, "authenticity": if_check})
|
@@ -79,8 +83,12 @@ def ocr_idcard_base64():
|
|
79 |
file_path = os.path.abspath(save_path)
|
80 |
|
81 |
ocrResult = TTVOcrProcess(file_path.encode('utf-8'))
|
82 |
-
ocrResDict = json.loads(ocrResult)
|
83 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
if_check = ttv_if_checker(file_path.encode('utf-8'))
|
86 |
response = jsonify({"status": status, "data": ocrResDict, "authenticity": if_check})
|
@@ -105,8 +113,12 @@ def ocr_credit():
|
|
105 |
file_path = os.path.abspath(save_path)
|
106 |
|
107 |
ocrResult = TTVOcrCreditCard(file_path.encode('utf-8'))
|
108 |
-
ocrResDict = json.loads(ocrResult)
|
109 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
response = jsonify({"status": status, "data": ocrResDict})
|
112 |
|
@@ -130,8 +142,12 @@ def ocr_credit_base64():
|
|
130 |
file_path = os.path.abspath(save_path)
|
131 |
|
132 |
ocrResult = TTVOcrCreditCard(file_path.encode('utf-8'))
|
133 |
-
ocrResDict = json.loads(ocrResult)
|
134 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
response = jsonify({"status": status, "data": ocrResDict})
|
137 |
|
@@ -154,8 +170,12 @@ def ocr_barcode():
|
|
154 |
file_path = os.path.abspath(save_path)
|
155 |
|
156 |
ocrResult = TTVOcrBarCode(file_path.encode('utf-8'))
|
157 |
-
ocrResDict = json.loads(ocrResult)
|
158 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
response = jsonify({"status": status, "data": ocrResDict})
|
161 |
|
@@ -179,8 +199,12 @@ def ocr_barcode_base64():
|
|
179 |
print('file_path: ', file_path)
|
180 |
|
181 |
ocrResult = TTVOcrBarCode(file_path.encode('utf-8'))
|
182 |
-
ocrResDict = json.loads(ocrResult)
|
183 |
status = "ok"
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
response = jsonify({"status": status, "data": ocrResDict})
|
186 |
|
|
|
52 |
|
53 |
|
54 |
ocrResult = TTVOcrProcess(file_path1.encode('utf-8'), file_path2.encode('utf-8'))
|
|
|
55 |
status = "ok"
|
56 |
+
if not ocrResult:
|
57 |
+
ocrResDict = {}
|
58 |
+
status = "error"
|
59 |
+
else:
|
60 |
+
ocrResDict = json.loads(ocrResult)
|
61 |
|
62 |
if_check = ttv_if_checker(file_path1.encode('utf-8'))
|
63 |
response = jsonify({"status": status, "data": ocrResDict, "authenticity": if_check})
|
|
|
83 |
file_path = os.path.abspath(save_path)
|
84 |
|
85 |
ocrResult = TTVOcrProcess(file_path.encode('utf-8'))
|
|
|
86 |
status = "ok"
|
87 |
+
if not ocrResult:
|
88 |
+
ocrResDict = {}
|
89 |
+
status = "error"
|
90 |
+
else:
|
91 |
+
ocrResDict = json.loads(ocrResult)
|
92 |
|
93 |
if_check = ttv_if_checker(file_path.encode('utf-8'))
|
94 |
response = jsonify({"status": status, "data": ocrResDict, "authenticity": if_check})
|
|
|
113 |
file_path = os.path.abspath(save_path)
|
114 |
|
115 |
ocrResult = TTVOcrCreditCard(file_path.encode('utf-8'))
|
|
|
116 |
status = "ok"
|
117 |
+
if not ocrResult:
|
118 |
+
ocrResDict = {}
|
119 |
+
status = "error"
|
120 |
+
else:
|
121 |
+
ocrResDict = json.loads(ocrResult)
|
122 |
|
123 |
response = jsonify({"status": status, "data": ocrResDict})
|
124 |
|
|
|
142 |
file_path = os.path.abspath(save_path)
|
143 |
|
144 |
ocrResult = TTVOcrCreditCard(file_path.encode('utf-8'))
|
|
|
145 |
status = "ok"
|
146 |
+
if not ocrResult:
|
147 |
+
ocrResDict = {}
|
148 |
+
status = "error"
|
149 |
+
else:
|
150 |
+
ocrResDict = json.loads(ocrResult)
|
151 |
|
152 |
response = jsonify({"status": status, "data": ocrResDict})
|
153 |
|
|
|
170 |
file_path = os.path.abspath(save_path)
|
171 |
|
172 |
ocrResult = TTVOcrBarCode(file_path.encode('utf-8'))
|
|
|
173 |
status = "ok"
|
174 |
+
if not ocrResult:
|
175 |
+
ocrResDict = {}
|
176 |
+
status = "error"
|
177 |
+
else:
|
178 |
+
ocrResDict = json.loads(ocrResult)
|
179 |
|
180 |
response = jsonify({"status": status, "data": ocrResDict})
|
181 |
|
|
|
199 |
print('file_path: ', file_path)
|
200 |
|
201 |
ocrResult = TTVOcrBarCode(file_path.encode('utf-8'))
|
|
|
202 |
status = "ok"
|
203 |
+
if not ocrResult:
|
204 |
+
ocrResDict = {}
|
205 |
+
status = "error"
|
206 |
+
else:
|
207 |
+
ocrResDict = json.loads(ocrResult)
|
208 |
|
209 |
response = jsonify({"status": status, "data": ocrResDict})
|
210 |
|