Spaces:
Runtime error
Runtime error
jatinbittu13
commited on
Commit
•
576ab32
1
Parent(s):
d8e6044
Update app.py
Browse files
app.py
CHANGED
@@ -41,13 +41,13 @@ def verify(model, detection_threshold, verification_threshold):
|
|
41 |
# Build results array
|
42 |
results = []
|
43 |
ver_images= []
|
44 |
-
for file in os.listdir(os.path.join('')):
|
45 |
-
|
46 |
-
|
47 |
ver_images_len= len(ver_images)
|
48 |
for image in ver_images:
|
49 |
-
input_img = preprocess(os.path.join('input_image.jpg'))
|
50 |
-
validation_img = preprocess(os.path.join('', image))
|
51 |
# Make Predictions
|
52 |
result = model.predict(list(np.expand_dims([input_img, validation_img], axis=1)))
|
53 |
results.append(result)
|
@@ -60,15 +60,19 @@ def verify(model, detection_threshold, verification_threshold):
|
|
60 |
print('Verification -- ',verification)
|
61 |
verified = verification > verification_threshold
|
62 |
|
63 |
-
return detection,verification,verified,ver_images_len
|
|
|
|
|
|
|
64 |
|
65 |
def take_ver_images (image):
|
66 |
-
|
67 |
-
|
|
|
68 |
count+=1
|
69 |
return '{} Image Collected!'.format(count)
|
70 |
def verify_identity (image):
|
71 |
-
cv2.imwrite(os.path.join('input_image.jpg'), image)
|
72 |
detection,verification,verified,ver_images_len = verify(siamese_model, 0.8, 0.7)
|
73 |
# return {'Detections': int(detection),'Confidence': float(verification),'Verified': bool(verified)}
|
74 |
return 'Detected {} out of {} samples'.format(detection,ver_images_len),float(verification),'Verified' if verified else 'Not Verified'
|
|
|
41 |
# Build results array
|
42 |
results = []
|
43 |
ver_images= []
|
44 |
+
for file in os.listdir(os.path.join('application_data', 'verification_images')):
|
45 |
+
if file[len(file)-4:] == '.jpg':
|
46 |
+
ver_images.append(file)
|
47 |
ver_images_len= len(ver_images)
|
48 |
for image in ver_images:
|
49 |
+
input_img = preprocess(os.path.join('application_data', 'input_image', 'input_image.jpg'))
|
50 |
+
validation_img = preprocess(os.path.join('application_data', 'verification_images', image))
|
51 |
# Make Predictions
|
52 |
result = model.predict(list(np.expand_dims([input_img, validation_img], axis=1)))
|
53 |
results.append(result)
|
|
|
60 |
print('Verification -- ',verification)
|
61 |
verified = verification > verification_threshold
|
62 |
|
63 |
+
return detection,verification,verified,ver_images_len
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
|
68 |
def take_ver_images (image):
|
69 |
+
for file in os.listdir(os.path.join('application_data', 'verification_images')):
|
70 |
+
os.remove(file)
|
71 |
+
cv2.imwrite(os.path.join('application_data', 'verification_images', '{}.jpg'.format(uuid.uuid1())), image)
|
72 |
count+=1
|
73 |
return '{} Image Collected!'.format(count)
|
74 |
def verify_identity (image):
|
75 |
+
cv2.imwrite(os.path.join('application_data', 'input_image', 'input_image.jpg'), image)
|
76 |
detection,verification,verified,ver_images_len = verify(siamese_model, 0.8, 0.7)
|
77 |
# return {'Detections': int(detection),'Confidence': float(verification),'Verified': bool(verified)}
|
78 |
return 'Detected {} out of {} samples'.format(detection,ver_images_len),float(verification),'Verified' if verified else 'Not Verified'
|