Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -53,9 +53,9 @@ def idcard_recognition():
|
|
53 |
j.update({"Status": "Ok"})
|
54 |
response = jsonify(j)
|
55 |
else:
|
56 |
-
response = jsonify({"Status": "
|
57 |
except:
|
58 |
-
response = jsonify({"Status": "Error"})
|
59 |
|
60 |
response.status_code = 200
|
61 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
@@ -63,22 +63,32 @@ def idcard_recognition():
|
|
63 |
|
64 |
@app.route('/idcard_recognition_multi_page', methods=['POST'])
|
65 |
def idcard_recognition_multi_page():
|
|
|
|
|
66 |
try:
|
67 |
file1 = request.files['file1']
|
68 |
-
file2 = request.files['file2']
|
69 |
-
|
70 |
base64_image1 = base64.b64encode(file1.read()).decode('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
base64_image2 = base64.b64encode(file2.read()).decode('utf-8')
|
|
|
|
|
|
|
72 |
ret = idcardRecognition(base64_image1.encode('utf-8'), base64_image2.encode('utf-8'))
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
except:
|
81 |
-
response = jsonify({"Status": "Error"})
|
82 |
|
83 |
response.status_code = 200
|
84 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
@@ -97,9 +107,9 @@ def idcard_recognition_base64():
|
|
97 |
j.update({"Status": "Ok"})
|
98 |
response = jsonify(j)
|
99 |
else:
|
100 |
-
response = jsonify({"Status": "
|
101 |
except:
|
102 |
-
response = jsonify({"Status": "Error"})
|
103 |
|
104 |
response.status_code = 200
|
105 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
@@ -107,21 +117,33 @@ def idcard_recognition_base64():
|
|
107 |
|
108 |
@app.route('/idcard_recognition_base64_multi_page', methods=['POST'])
|
109 |
def idcard_recognition_base64_multi_page():
|
|
|
|
|
|
|
110 |
try:
|
111 |
content = request.get_json()
|
112 |
base64_image1 = content['base64_1']
|
113 |
-
|
|
|
114 |
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
response = jsonify(j)
|
121 |
-
else:
|
122 |
-
response = jsonify({"Status": "Error"})
|
123 |
except:
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
response.status_code = 200
|
127 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
|
|
53 |
j.update({"Status": "Ok"})
|
54 |
response = jsonify(j)
|
55 |
else:
|
56 |
+
response = jsonify({"Status": "Processing Failed"})
|
57 |
except:
|
58 |
+
response = jsonify({"Status": "Image Error"})
|
59 |
|
60 |
response.status_code = 200
|
61 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
|
|
63 |
|
64 |
@app.route('/idcard_recognition_multi_page', methods=['POST'])
|
65 |
def idcard_recognition_multi_page():
|
66 |
+
base64_image1 = ""
|
67 |
+
base64_image2 = ""
|
68 |
try:
|
69 |
file1 = request.files['file1']
|
|
|
|
|
70 |
base64_image1 = base64.b64encode(file1.read()).decode('utf-8')
|
71 |
+
except:
|
72 |
+
response = jsonify({"Status": "Front Image Error"})
|
73 |
+
|
74 |
+
response.status_code = 200
|
75 |
+
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
76 |
+
return response
|
77 |
+
|
78 |
+
try:
|
79 |
+
file2 = request.files['file2']
|
80 |
base64_image2 = base64.b64encode(file2.read()).decode('utf-8')
|
81 |
+
except:
|
82 |
+
base64_image2 = ""
|
83 |
+
|
84 |
ret = idcardRecognition(base64_image1.encode('utf-8'), base64_image2.encode('utf-8'))
|
85 |
|
86 |
+
if ret != None:
|
87 |
+
j = json.loads(ret)
|
88 |
+
j.update({"Status": "Ok"})
|
89 |
+
response = jsonify(j)
|
90 |
+
else:
|
91 |
+
response = jsonify({"Status": "Processing Failed"})
|
|
|
|
|
92 |
|
93 |
response.status_code = 200
|
94 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
|
|
107 |
j.update({"Status": "Ok"})
|
108 |
response = jsonify(j)
|
109 |
else:
|
110 |
+
response = jsonify({"Status": "Processing Failed"})
|
111 |
except:
|
112 |
+
response = jsonify({"Status": "Image Error"})
|
113 |
|
114 |
response.status_code = 200
|
115 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
|
|
117 |
|
118 |
@app.route('/idcard_recognition_base64_multi_page', methods=['POST'])
|
119 |
def idcard_recognition_base64_multi_page():
|
120 |
+
base64_image1 = ""
|
121 |
+
base64_image2 = ""
|
122 |
+
|
123 |
try:
|
124 |
content = request.get_json()
|
125 |
base64_image1 = content['base64_1']
|
126 |
+
except:
|
127 |
+
response = jsonify({"Status": "Front Image Error"})
|
128 |
|
129 |
+
response.status_code = 200
|
130 |
+
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
131 |
+
return response
|
132 |
|
133 |
+
try:
|
134 |
+
content = request.get_json()
|
135 |
+
base64_image2 = content['base64_2']
|
|
|
|
|
|
|
136 |
except:
|
137 |
+
base64_image2 = ""
|
138 |
+
|
139 |
+
ret = idcardRecognition(base64_image1.encode('utf-8'), base64_image2.encode('utf-8'))
|
140 |
+
|
141 |
+
if ret != None:
|
142 |
+
j = json.loads(ret)
|
143 |
+
j.update({"Status": "Ok"})
|
144 |
+
response = jsonify(j)
|
145 |
+
else:
|
146 |
+
response = jsonify({"Status": "Processing Failed"})
|
147 |
|
148 |
response.status_code = 200
|
149 |
response.headers["Content-Type"] = "application/json; charset=utf-8"
|