added top code for number of classes
Browse files- .gitignore +2 -0
- app.py +2 -1
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
__pycache__/app.cpython-37.pyc
|
2 |
+
__pycache__/custom_resnet.cpython-37.pyc
|
app.py
CHANGED
@@ -36,8 +36,9 @@ def inference(input_img, transparency = 0.5, target_layer_number = -1, num_top_c
|
|
36 |
# Sort confidences dictionary in descending order of values and take top num_top_classes
|
37 |
sorted_confidences = {k: v for k, v in sorted(confidences.items(), key=lambda item: item[1], reverse=True)}
|
38 |
top_classes = list(sorted_confidences.keys())[:num_top_classes]
|
|
|
39 |
|
40 |
-
return
|
41 |
|
42 |
title = "CIFAR10 trained on ResNet18 Model with GradCAM"
|
43 |
description = "A simple Gradio interface to infer on ResNet model, and get GradCAM results"
|
|
|
36 |
# Sort confidences dictionary in descending order of values and take top num_top_classes
|
37 |
sorted_confidences = {k: v for k, v in sorted(confidences.items(), key=lambda item: item[1], reverse=True)}
|
38 |
top_classes = list(sorted_confidences.keys())[:num_top_classes]
|
39 |
+
top = dict((k,v) for k, v in sorted_confidences.items() if k in top_classes)
|
40 |
|
41 |
+
return top, visualization
|
42 |
|
43 |
title = "CIFAR10 trained on ResNet18 Model with GradCAM"
|
44 |
description = "A simple Gradio interface to infer on ResNet model, and get GradCAM results"
|