HugoHE commited on
Commit
b36f6d5
1 Parent(s): 1bfb4c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -92,15 +92,6 @@ class Detectron2Monitor():
92
  with open("monitors_dict.pkl", 'rb') as f:
93
  monitors_dict = load(f)
94
  return monitors_dict
95
- # monitors_dict = {}
96
- # for class_name in self.label_list:
97
- # if class_name == "train" or class_name == "OOD":
98
- # continue
99
- # monitor_path = f"monitors/{class_name}/monitor_for_clustering_parameter" + "_tau_" + str(tau) + ".pkl"
100
- # with open(monitor_path, 'rb') as f:
101
- # monitor = load(f)
102
- # monitors_dict[class_name] = monitor
103
- # return monitors_dict
104
 
105
  def _fasterrcnn_reshape_transform(self, x):
106
  target_size = x['p6'].size()[-2 : ]
@@ -144,14 +135,13 @@ class Detectron2Monitor():
144
  reshape_transform=self._fasterrcnn_reshape_transform)
145
  grayscale_cam = cam(input_image_dict, targets)
146
  cam = self._postprocess_cam(grayscale_cam, input_image_dict[0]["width"], input_image_dict[0]["height"])
147
- # plt.rcParams["figure.figsize"] = (30,10)
148
- # plt.imshow(img_detection[..., ::-1], interpolation='none')
149
- # plt.imshow(cam, cmap='jet', alpha=0.5)
150
- # plt.axis("off")
151
- # img_buff = io.BytesIO()
152
- # plt.savefig(img_buff, format='png', bbox_inches='tight', pad_inches=0)
153
- # img_cam = Image.open(img_buff)
154
- img_cam = image
155
  image_dict = {}
156
  image_dict["image"] = image
157
  image_dict["cam"] = img_cam
 
92
  with open("monitors_dict.pkl", 'rb') as f:
93
  monitors_dict = load(f)
94
  return monitors_dict
 
 
 
 
 
 
 
 
 
95
 
96
  def _fasterrcnn_reshape_transform(self, x):
97
  target_size = x['p6'].size()[-2 : ]
 
135
  reshape_transform=self._fasterrcnn_reshape_transform)
136
  grayscale_cam = cam(input_image_dict, targets)
137
  cam = self._postprocess_cam(grayscale_cam, input_image_dict[0]["width"], input_image_dict[0]["height"])
138
+ plt.rcParams["figure.figsize"] = (30,10)
139
+ plt.imshow(img_detection[..., ::-1], interpolation='none')
140
+ plt.imshow(cam, cmap='jet', alpha=0.5)
141
+ plt.axis("off")
142
+ img_buff = io.BytesIO()
143
+ plt.savefig(img_buff, format='png', bbox_inches='tight', pad_inches=0)
144
+ img_cam = Image.open(img_buff)
 
145
  image_dict = {}
146
  image_dict["image"] = image
147
  image_dict["cam"] = img_cam