Update app.py
Browse files
app.py
CHANGED
@@ -51,13 +51,18 @@ def classify_image(input):
|
|
51 |
input_image=faceResized,
|
52 |
reshape_transform=gradCam.reshape_transform_vit_huggingface)
|
53 |
result = pipe(face)
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
|
57 |
iface = gr.Interface(
|
58 |
fn=classify_image,
|
59 |
inputs="image",
|
60 |
-
outputs=["text", "number", "image", "image", "image"],
|
61 |
title="Attraction Classifier - subjective",
|
62 |
description=f"Takes in a (224, 224) image and outputs an attraction class: {'pos', 'neg'}, along with a GradCam/DFF explanation. Face detection, cropping, and resizing are done internally. Uploaded images are not stored by us, but may be stored by HF. Refer to their privacy policy for details."
|
63 |
)
|
|
|
51 |
input_image=faceResized,
|
52 |
reshape_transform=gradCam.reshape_transform_vit_huggingface)
|
53 |
result = pipe(face)
|
54 |
+
if result[0]["label"] == "pos" and result[0]["score"] > 0.9:
|
55 |
+
return result[0]["label"], result[0]["score"], str("Nice!"), face, dffImage, gradCamImage
|
56 |
+
elif result[0]["label"] == "pos" and result[0]["score"] > 0.95
|
57 |
+
return result[0]["label"], result[0]["score"], str("WHOA!!!!"), face, dffImage, gradCamImage
|
58 |
+
else:
|
59 |
+
return result[0]["label"], result[0]["score"], "Indifferent", face, dffImage, gradCamImage
|
60 |
|
61 |
|
62 |
iface = gr.Interface(
|
63 |
fn=classify_image,
|
64 |
inputs="image",
|
65 |
+
outputs=["text", "number", "text", "image", "image", "image"],
|
66 |
title="Attraction Classifier - subjective",
|
67 |
description=f"Takes in a (224, 224) image and outputs an attraction class: {'pos', 'neg'}, along with a GradCam/DFF explanation. Face detection, cropping, and resizing are done internally. Uploaded images are not stored by us, but may be stored by HF. Refer to their privacy policy for details."
|
68 |
)
|