Graduate

Add image standardization

...@@ -28,6 +28,9 @@ app = Flask(__name__) ...@@ -28,6 +28,9 @@ app = Flask(__name__)
28 sess = tf.compat.v1.Session() 28 sess = tf.compat.v1.Session()
29 29
30 30
31 +def image_standardization(image):
32 + return (image - 127.5) / 128.0
33 +
31 def resize(image): 34 def resize(image):
32 resized = cv2.resize(image, (image_size, image_size), interpolation=cv2.INTER_AREA) 35 resized = cv2.resize(image, (image_size, image_size), interpolation=cv2.INTER_AREA)
33 return resized 36 return resized
...@@ -80,6 +83,7 @@ def register(): ...@@ -80,6 +83,7 @@ def register():
80 image_np = np.frombuffer(image, dtype=np.uint8) 83 image_np = np.frombuffer(image, dtype=np.uint8)
81 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) 84 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED)
82 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB) 85 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
86 + image_np = image_standardization(image_np)
83 image_np = prewhiten(image_np) 87 image_np = prewhiten(image_np)
84 image_np = resize(image_np) 88 image_np = resize(image_np)
85 image_np = image_np.reshape(-1, image_size, image_size, 3) 89 image_np = image_np.reshape(-1, image_size, image_size, 3)
...@@ -127,7 +131,7 @@ def verify(): ...@@ -127,7 +131,7 @@ def verify():
127 if (distance < dist_min): 131 if (distance < dist_min):
128 verified_id = row_data['student_id'] 132 verified_id = row_data['student_id']
129 dist_min = distance 133 dist_min = distance
130 - new_embedding = db_embedding * 0.97 + embedding * 0.03 134 + new_embedding = db_embedding * 0.99 + embedding * 0.01
131 new_embedding = new_embedding.tobytes() 135 new_embedding = new_embedding.tobytes()
132 sql = "UPDATE student_embedding SET embedding=_binary %s WHERE student_id = %s" 136 sql = "UPDATE student_embedding SET embedding=_binary %s WHERE student_id = %s"
133 cursor.execute(sql, (new_embedding, verified_id)) 137 cursor.execute(sql, (new_embedding, verified_id))
......
1 [verification_server] 1 [verification_server]
2 model=models/20200816-080621 2 model=models/20200816-080621
3 -threshold=0.78 3 +threshold=0.685
4 image_size=160 4 image_size=160
......
1 -python3 -m flask run --host 0.0.0.0 --port 443 --cert=cert.pem --key=key.pem 1 +python3 -m flask run --host 0.0.0.0 --port 443 --no-debugger --no-reload --cert=cert.pem --key=key.pem
......
...@@ -257,13 +257,13 @@ and is wrapped around the whole page content, except for the footer in this exam ...@@ -257,13 +257,13 @@ and is wrapped around the whole page content, except for the footer in this exam
257 <canvas id="canvasOutput">/canvas> 257 <canvas id="canvasOutput">/canvas>
258 </div> 258 </div>
259 <div id="inputForm"> 259 <div id="inputForm">
260 - <strong>얼굴 이미지는 서버에 저장되지 않습니다</strong><br> 260 + <strong>얼굴 이미지는 '절대로' 저장되지 않습니다</strong><br>
261 - <strong>(복원 불가능한 512차원 벡터로 변환됩니다)</strong><br>
262 <strong>학번과 이름은 임의로 입력해주세요</strong><br> 261 <strong>학번과 이름은 임의로 입력해주세요</strong><br>
263 <strong>예)1234/홍길동 등</strong><br> 262 <strong>예)1234/홍길동 등</strong><br>
264 학번: <input type="text" id="student_id"><br> 263 학번: <input type="text" id="student_id"><br>
265 이름: <input type="text" id="student_name"><br> 264 이름: <input type="text" id="student_name"><br>
266 - <input id="sender" type="button" onclick="submit()" value="등록" disabled> 265 + <input id="sender" type="button" onclick="submit()" value="등록" disabled><br>
266 + 등록 후: <a href="https://gabibing.com">출석체크 페이지</a>
267 </div> 267 </div>
268 </div> 268 </div>
269 </div> 269 </div>
......