Wolowolo commited on
Commit
9506b75
·
verified ·
1 Parent(s): 31d9fab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -7,7 +7,7 @@
7
 
8
  import sys
9
  import os
10
- os.system(f'pip install grad-cam')
11
  os.system(f'pip install dlib')
12
  import dlib
13
  import argparse
@@ -184,8 +184,8 @@ class TargetCategory:
184
  return output[self.category_index]
185
 
186
 
187
- def preprocess_image_cam(pil_img,
188
- mean=[0.5482207536697388, 0.42340534925460815, 0.3654651641845703],
189
  std=[0.2789176106452942, 0.2438540756702423, 0.23493893444538116]):
190
  img_np = np.array(pil_img)
191
  img_np = img_np.astype(np.float32) / 255.0
@@ -222,9 +222,9 @@ def FSFM3C_image_detection(image):
222
  image_results = f"The largest face in this image may be {max_prob_class} with probability: \n [{', '.join(probabilities)}]"
223
 
224
  # Generate CAM heatmap for the detected class
225
- use_cuda = True
226
- input_tensor = preprocess_image(img,
227
- mean=[0.5482207536697388, 0.42340534925460815, 0.3654651641845703],
228
  std=[0.2789176106452942, 0.2438540756702423, 0.23493893444538116])
229
  if use_cuda:
230
  input_tensor = input_tensor.cuda()
 
7
 
8
  import sys
9
  import os
10
+
11
  os.system(f'pip install dlib')
12
  import dlib
13
  import argparse
 
184
  return output[self.category_index]
185
 
186
 
187
+ def preprocess_image_cam(pil_img,
188
+ mean=[0.5482207536697388, 0.42340534925460815, 0.3654651641845703],
189
  std=[0.2789176106452942, 0.2438540756702423, 0.23493893444538116]):
190
  img_np = np.array(pil_img)
191
  img_np = img_np.astype(np.float32) / 255.0
 
222
  image_results = f"The largest face in this image may be {max_prob_class} with probability: \n [{', '.join(probabilities)}]"
223
 
224
  # Generate CAM heatmap for the detected class
225
+ use_cuda = torch.cuda.is_available()
226
+ input_tensor = preprocess_image(img,
227
+ mean=[0.5482207536697388, 0.42340534925460815, 0.3654651641845703],
228
  std=[0.2789176106452942, 0.2438540756702423, 0.23493893444538116])
229
  if use_cuda:
230
  input_tensor = input_tensor.cuda()