Update app.py
Browse files
app.py
CHANGED
@@ -42,13 +42,16 @@ def classify_image(input):
|
|
42 |
n_components=5,
|
43 |
top_k=10
|
44 |
)
|
|
|
|
|
|
|
|
|
45 |
gradCamImage = gradCam.run_grad_cam_on_image(model=model,
|
46 |
target_layer=targetLayerGradCam,
|
47 |
-
targets_for_gradcam=
|
48 |
input_tensor=tensorResized,
|
49 |
input_image=faceResized,
|
50 |
reshape_transform=gradCam.reshape_transform_vit_huggingface)
|
51 |
-
result = gradCam.get_top_category(model, tensorResized)
|
52 |
if result[0]["label"] == "pos" and result[0]["score"] > 0.9 and result[0]["score"] < 0.95:
|
53 |
return result[0]["label"], result[0]["score"], str("Nice!"), face, dffImage, gradCamImage
|
54 |
elif result[0]["label"] == "pos" and result[0]["score"] > 0.95:
|
|
|
42 |
n_components=5,
|
43 |
top_k=10
|
44 |
)
|
45 |
+
result = gradCam.get_top_category(model, tensorResized)
|
46 |
+
cls = result[0]["label"]
|
47 |
+
clsIdx = gradCam.category_name_to_index(model, cls)
|
48 |
+
clsTarget = ClassifierOutputTarget(clsIdx)
|
49 |
gradCamImage = gradCam.run_grad_cam_on_image(model=model,
|
50 |
target_layer=targetLayerGradCam,
|
51 |
+
targets_for_gradcam=[clsTarget],
|
52 |
input_tensor=tensorResized,
|
53 |
input_image=faceResized,
|
54 |
reshape_transform=gradCam.reshape_transform_vit_huggingface)
|
|
|
55 |
if result[0]["label"] == "pos" and result[0]["score"] > 0.9 and result[0]["score"] < 0.95:
|
56 |
return result[0]["label"], result[0]["score"], str("Nice!"), face, dffImage, gradCamImage
|
57 |
elif result[0]["label"] == "pos" and result[0]["score"] > 0.95:
|