piyushgrover commited on
Commit
588684f
·
1 Parent(s): b81da07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -32
app.py CHANGED
@@ -35,33 +35,6 @@ scaled_anchors = (
35
  ).to(model.device)
36
 
37
  cam = YoloGradCAM(model=model, target_layers=[model.layers[-2]], scaled_anchors=scaled_anchors, use_cuda=False)
38
- '''cfg.IMG_DIR = cfg.DATASET + "/images/"
39
- cfg.LABEL_DIR = cfg.DATASET + "/labels/"
40
- eval_dataset = YOLODataset(
41
- cfg.DATASET + "/25examples.csv",
42
- transform=cfg.test_transforms,
43
- S=[cfg.IMAGE_SIZE // 32, cfg.IMAGE_SIZE // 16, cfg.IMAGE_SIZE // 8],
44
- img_dir=cfg.IMG_DIR,
45
- label_dir=cfg.LABEL_DIR,
46
- anchors=cfg.ANCHORS,
47
- mosaic=False
48
- )
49
- eval_loader = DataLoader(
50
- dataset=eval_dataset,
51
- batch_size=cfg.BATCH_SIZE,
52
- num_workers=cfg.NUM_WORKERS,
53
- pin_memory=cfg.PIN_MEMORY,
54
- shuffle=True,
55
- drop_last=False,
56
- )
57
-
58
- scaled_anchors = (
59
- torch.tensor(cfg.ANCHORS)
60
- * torch.tensor(cfg.S).unsqueeze(1).unsqueeze(1).repeat(1, 3, 2)
61
- )
62
- scaled_anchors = scaled_anchors.to(cfg.DEVICE)
63
-
64
- utils.plot_examples(model, eval_loader, 0.5, 0.6, scaled_anchors)'''
65
 
66
  sample_images = [
67
  ['images/000001.jpg'],
@@ -153,11 +126,11 @@ with gr.Blocks() as app:
153
  with gr.Row():
154
  if_show_grad_cam = gr.Checkbox(value=True, label='Show Class Activation Map (What the model sees)?')
155
 
156
- # with gr.Row(visible=True) as top_class_output:
157
- with gr.Row(visible=True) as top_class_output:
158
- top_class_output_img = gr.Image(interactive=False, label='Prediction Output')
159
- with gr.Row(visible=True) as top_class_output:
160
- grad_cam_out = gr.Image(interactive=False, visible=True, label='CAM Outcome')
161
 
162
 
163
  def show_cam_output(input):
 
35
  ).to(model.device)
36
 
37
  cam = YoloGradCAM(model=model, target_layers=[model.layers[-2]], scaled_anchors=scaled_anchors, use_cuda=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  sample_images = [
40
  ['images/000001.jpg'],
 
126
  with gr.Row():
127
  if_show_grad_cam = gr.Checkbox(value=True, label='Show Class Activation Map (What the model sees)?')
128
 
129
+ with gr.Row(visible=True) as top_class_output:
130
+ with gr.Column(visible=True) as top_class_output:
131
+ top_class_output_img = gr.Image(interactive=False, label='Prediction Output')
132
+ with gr.Column(visible=True) as top_class_output:
133
+ grad_cam_out = gr.Image(interactive=False, visible=True, label='CAM Outcome')
134
 
135
 
136
  def show_cam_output(input):