Spaces:
Runtime error
Runtime error
Commit ·
8d6429d
1
Parent(s): 1401e1a
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ import torchvision.transforms as T
|
|
| 16 |
from custom_resnet import LitResnet
|
| 17 |
|
| 18 |
classes = ['plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
|
| 19 |
-
|
| 20 |
wrong_img = pd.read_csv('misclassified_images.csv')
|
| 21 |
wrong_img_no = len(wrong_img)
|
| 22 |
|
|
@@ -57,9 +57,9 @@ def image_classifier(input_image, top_classes=3, show_cam=True, target_layers=[2
|
|
| 57 |
_, label = torch.max(output, 1)
|
| 58 |
|
| 59 |
#confidences.sort(key=lambda x: x[1], reverse=True)
|
| 60 |
-
confidences = OrderedDict(confidences[:top_classes])
|
| 61 |
#label = torch.argmax(output).item()
|
| 62 |
-
|
| 63 |
outputs = list()
|
| 64 |
if show_cam:
|
| 65 |
for layer in target_layers:
|
|
@@ -82,7 +82,7 @@ demo1 = gr.Interface(
|
|
| 82 |
gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
|
| 83 |
info="Set Transparency of CAMs")
|
| 84 |
],
|
| 85 |
-
outputs=[gr.Gallery(label="Output Images", columns=2, rows=2), gr.Label(label='Top Classes')],
|
| 86 |
examples=examples
|
| 87 |
)
|
| 88 |
|
|
|
|
| 16 |
from custom_resnet import LitResnet
|
| 17 |
|
| 18 |
classes = ['plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
|
| 19 |
+
top_classes_g = 3
|
| 20 |
wrong_img = pd.read_csv('misclassified_images.csv')
|
| 21 |
wrong_img_no = len(wrong_img)
|
| 22 |
|
|
|
|
| 57 |
_, label = torch.max(output, 1)
|
| 58 |
|
| 59 |
#confidences.sort(key=lambda x: x[1], reverse=True)
|
| 60 |
+
#confidences = OrderedDict(confidences[:top_classes])
|
| 61 |
#label = torch.argmax(output).item()
|
| 62 |
+
top_classes_g = top_classes
|
| 63 |
outputs = list()
|
| 64 |
if show_cam:
|
| 65 |
for layer in target_layers:
|
|
|
|
| 82 |
gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
|
| 83 |
info="Set Transparency of CAMs")
|
| 84 |
],
|
| 85 |
+
outputs=[gr.Gallery(label="Output Images", columns=2, rows=2), gr.Label(label='Top Classes',num_top_classes=top_classes_g)],
|
| 86 |
examples=examples
|
| 87 |
)
|
| 88 |
|