Spaces:
Sleeping
Sleeping
Update app.py
Browse filesThe folder names for new test images and the mis classified images are corrected here
app.py
CHANGED
@@ -92,7 +92,7 @@ def classify_image(input_image, top_classes=3, grad_cam=True, target_layers=[2,
|
|
92 |
demo1 = gr.Interface(
|
93 |
fn=classify_image,
|
94 |
inputs=[
|
95 |
-
gr.Image(shape=(32, 32), label="Input Image", value='
|
96 |
gr.Slider(1, 10, value=3, step=1, label="Number of Top Classes"),
|
97 |
gr.Checkbox(label="Show GradCAM?", value=True),
|
98 |
#gr.Slider(-4, -1, value=-2, step=1, label="Which Layer?"),
|
@@ -101,13 +101,13 @@ demo1 = gr.Interface(
|
|
101 |
],
|
102 |
outputs=[gr.Gallery(label="Output Images", columns=2, rows=2),
|
103 |
gr.Label(label='Top Classes')],
|
104 |
-
examples=[[f'
|
105 |
)
|
106 |
|
107 |
def show_mis_classifications(num_examples=20, grad_cam=True, target_layer=-2, transparency=0.5):
|
108 |
result = list()
|
109 |
for index, row in mis_classified_df.iterrows():
|
110 |
-
image = np.asarray(Image.open(f'
|
111 |
output_image, confidence = classify_image(image, top_classes=1, grad_cam=grad_cam, target_layers=[4+target_layer],
|
112 |
transparency=transparency)
|
113 |
truth = row['ground_truths']
|
|
|
92 |
demo1 = gr.Interface(
|
93 |
fn=classify_image,
|
94 |
inputs=[
|
95 |
+
gr.Image(shape=(32, 32), label="Input Image", value='test_images/cat.jpg'),
|
96 |
gr.Slider(1, 10, value=3, step=1, label="Number of Top Classes"),
|
97 |
gr.Checkbox(label="Show GradCAM?", value=True),
|
98 |
#gr.Slider(-4, -1, value=-2, step=1, label="Which Layer?"),
|
|
|
101 |
],
|
102 |
outputs=[gr.Gallery(label="Output Images", columns=2, rows=2),
|
103 |
gr.Label(label='Top Classes')],
|
104 |
+
examples=[[f'test_images/{k}.jpg'] for k in classes.values()]
|
105 |
)
|
106 |
|
107 |
def show_mis_classifications(num_examples=20, grad_cam=True, target_layer=-2, transparency=0.5):
|
108 |
result = list()
|
109 |
for index, row in mis_classified_df.iterrows():
|
110 |
+
image = np.asarray(Image.open(f'misclassified_examples/{index}.jpg'))
|
111 |
output_image, confidence = classify_image(image, top_classes=1, grad_cam=grad_cam, target_layers=[4+target_layer],
|
112 |
transparency=transparency)
|
113 |
truth = row['ground_truths']
|