diff --git a/app/api/face.py b/app/api/face.py index d181d373b1a10e564edfdfcbed3233d9b61522d4..73b4a0dde8f7455e93a38638ecc27b76a586e72f 100644 --- a/app/api/face.py +++ b/app/api/face.py @@ -35,7 +35,7 @@ def face_recognition(): y_pred = anti_spoofing_two_stream_vit.get_y_prediction(x=image, msr=image_msr) if y_pred == 1: user = User() - user.from_dict({'id': 0, 'name': '非活体', 'cell_phone_number': ''}) + user.from_dict({'id': 0, 'username': '非活体', 'cell_phone_number': ''}) return jsonify(success=True, data=user.to_dict(), status_code=200) # face recognition @@ -52,7 +52,7 @@ def face_recognition(): target = compare.face_net_compare(embedding, x, y) if target == 0: user = User() - user.from_dict({'id': 0, 'name': '无法识别', 'cell_phone_number': ''}) + user.from_dict({'id': 0, 'username': '无法识别', 'cell_phone_number': ''}) else: user = User.query.filter_by(id=int(target)).first() return jsonify(success=True, data=user.to_dict(), status_code=200) diff --git a/app/model/models.py b/app/model/models.py index b41d8a93b4f5e3aabb34d7bf8589dddf74e9eba6..b7297564313f6941738765ff68c33f4ff36c1ea6 100644 --- a/app/model/models.py +++ b/app/model/models.py @@ -25,7 +25,7 @@ class User(PaginatedAPIMixin, db.Model): return data def from_dict(self, data): - for field in ['username', 'cell_phone_number']: + for field in ['id', 'username', 'cell_phone_number']: if field in data: setattr(self, field, data[field]) diff --git a/app/recognition/anti_spoofing_two_stream_vit.py b/app/recognition/anti_spoofing_two_stream_vit.py index c08dbbb83aef3b9958abcb456d9a18cb2360e460..b9d8f0598b1284537a08450ba644f0350b30055c 100644 --- a/app/recognition/anti_spoofing_two_stream_vit.py +++ b/app/recognition/anti_spoofing_two_stream_vit.py @@ -50,7 +50,7 @@ class AntiSpoofingTwoStreamVit(FaceModel): x = x.unsqueeze(0) msr = msr.unsqueeze(0) - if next(self.model.parameters()).device: + if next(self.model.parameters()).is_cuda: x = x.cuda(device='cuda:0') msr = msr.cuda(device='cuda:0') logits = self.model(x, msr)