Update app.py
Browse files
app.py
CHANGED
@@ -19,8 +19,7 @@ from dataset.dataset import *
|
|
19 |
|
20 |
|
21 |
model = ResNet18(20, None)
|
22 |
-
model = model.load_from_checkpoint("resnet18.ckpt", map_location=torch.device("cpu"))
|
23 |
-
model.eval()
|
24 |
|
25 |
dataloader_args = dict(shuffle=True, batch_size=64)
|
26 |
_, test_transforms = get_transforms(mu, std)
|
@@ -38,7 +37,7 @@ def upload_image_inference(input_img, n_top_classes, transparency):
|
|
38 |
|
39 |
org_img = input_img.copy()
|
40 |
|
41 |
-
input_img =
|
42 |
input_img = input_img.unsqueeze(0)
|
43 |
|
44 |
outputs = model(input_img)
|
@@ -157,7 +156,7 @@ with gr.Blocks() as gradcam:
|
|
157 |
|
158 |
upload_output = [gr.Label(label='Top Classes'),
|
159 |
gr.Gallery(label="Image | CAM | Image+CAM",
|
160 |
-
show_label=True,
|
161 |
rows=[1],
|
162 |
object_fit="contain",
|
163 |
height="auto")]
|
@@ -179,7 +178,7 @@ with gr.Blocks() as gradcam:
|
|
179 |
gr.Slider(0, 1, value=0.6, label='Transparency')]
|
180 |
|
181 |
image_output21 = gr.Gallery(label="Images - Grad-CAM (correct)",
|
182 |
-
show_label=True,
|
183 |
button21 = gr.Button("View Images")
|
184 |
|
185 |
with gr.Column():
|
@@ -188,7 +187,7 @@ with gr.Blocks() as gradcam:
|
|
188 |
gr.Slider(0, 1, value=0.6, label='Transparency')]
|
189 |
|
190 |
image_output22 = gr.Gallery(label="Images - Grad-CAM (Misclassified)",
|
191 |
-
show_label=True,
|
192 |
button22 = gr.Button("View Images")
|
193 |
|
194 |
button1.click(upload_image_inference, inputs=upload_input, outputs=upload_output)
|
@@ -197,4 +196,4 @@ with gr.Blocks() as gradcam:
|
|
197 |
|
198 |
|
199 |
|
200 |
-
gradcam.launch()
|
|
|
19 |
|
20 |
|
21 |
model = ResNet18(20, None)
|
22 |
+
model = model.load_from_checkpoint("/content/drive/MyDrive/ERAV1/S12/resnet18.ckpt", map_location=torch.device("cpu"))
|
|
|
23 |
|
24 |
dataloader_args = dict(shuffle=True, batch_size=64)
|
25 |
_, test_transforms = get_transforms(mu, std)
|
|
|
37 |
|
38 |
org_img = input_img.copy()
|
39 |
|
40 |
+
input_img = test_transforms(image=org_img)['image']
|
41 |
input_img = input_img.unsqueeze(0)
|
42 |
|
43 |
outputs = model(input_img)
|
|
|
156 |
|
157 |
upload_output = [gr.Label(label='Top Classes'),
|
158 |
gr.Gallery(label="Image | CAM | Image+CAM",
|
159 |
+
show_label=True, min_width=80).style(columns=[3],
|
160 |
rows=[1],
|
161 |
object_fit="contain",
|
162 |
height="auto")]
|
|
|
178 |
gr.Slider(0, 1, value=0.6, label='Transparency')]
|
179 |
|
180 |
image_output21 = gr.Gallery(label="Images - Grad-CAM (correct)",
|
181 |
+
show_label=True, min_width=80)
|
182 |
button21 = gr.Button("View Images")
|
183 |
|
184 |
with gr.Column():
|
|
|
187 |
gr.Slider(0, 1, value=0.6, label='Transparency')]
|
188 |
|
189 |
image_output22 = gr.Gallery(label="Images - Grad-CAM (Misclassified)",
|
190 |
+
show_label=True, min_width=80)
|
191 |
button22 = gr.Button("View Images")
|
192 |
|
193 |
button1.click(upload_image_inference, inputs=upload_input, outputs=upload_output)
|
|
|
196 |
|
197 |
|
198 |
|
199 |
+
gradcam.launch()
|