Kalbe-x-Bangkit commited on
Commit
033ddac
1 Parent(s): ae4c42e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -29,7 +29,7 @@ bucket_load = storage_client.bucket(bucket_name_load)
29
  model_path = os.path.join("model.h5")
30
  model = tf.keras.models.load_model(model_path)
31
 
32
- H, W = 512, 512
33
 
34
  test_samples_folder = 'object_detection_test_samples'
35
 
@@ -51,7 +51,7 @@ df = pd.read_excel('BBox_List_2017.xlsx')
51
  labels_dict = dict(zip(df['Image Index'], df['Finding Label']))
52
 
53
  def predict(image):
54
- H, W = 512, 512
55
 
56
  image_resized = cv2.resize(image, (W, H))
57
  image_normalized = (image_resized - 127.5) / 127.5
@@ -181,7 +181,7 @@ def upload_folder_images(original_image_path, enhanced_image_path):
181
  upload_to_gcs(enhanced_dicom_bytes, folder_name + '/' + enhancement_name + '.dcm', content_type='application/dicom')
182
 
183
 
184
- def get_mean_std_per_batch(image_path, df, H=512, W=512):
185
  sample_data = []
186
  for idx, img in enumerate(df.sample(100)["Image Index"].values):
187
  # path = image_dir + img
@@ -192,7 +192,7 @@ def get_mean_std_per_batch(image_path, df, H=512, W=512):
192
  std = np.std(sample_data[0])
193
  return mean, std
194
 
195
- def load_image(img_path, preprocess=True, height=512, width=512):
196
  mean, std = get_mean_std_per_batch(img_path, df, height, width)
197
  x = keras.utils.load_img(img_path, target_size=(height, width))
198
  x = keras.utils.img_to_array(x)
@@ -225,7 +225,7 @@ def grad_cam(input_model, img_array, cls, layer_name):
225
  for index, w in enumerate(weights):
226
  cam += w * output[:, :, index]
227
 
228
- cam = cv2.resize(cam.numpy(), (512, 512), cv2.INTER_LINEAR)
229
  cam = np.maximum(cam, 0)
230
  cam = cam / cam.max()
231
 
 
29
  model_path = os.path.join("model.h5")
30
  model = tf.keras.models.load_model(model_path)
31
 
32
+ H, W = 320, 320
33
 
34
  test_samples_folder = 'object_detection_test_samples'
35
 
 
51
  labels_dict = dict(zip(df['Image Index'], df['Finding Label']))
52
 
53
  def predict(image):
54
+ H, W = 320, 320
55
 
56
  image_resized = cv2.resize(image, (W, H))
57
  image_normalized = (image_resized - 127.5) / 127.5
 
181
  upload_to_gcs(enhanced_dicom_bytes, folder_name + '/' + enhancement_name + '.dcm', content_type='application/dicom')
182
 
183
 
184
+ def get_mean_std_per_batch(image_path, df, H=320, W=320):
185
  sample_data = []
186
  for idx, img in enumerate(df.sample(100)["Image Index"].values):
187
  # path = image_dir + img
 
192
  std = np.std(sample_data[0])
193
  return mean, std
194
 
195
+ def load_image(img_path, preprocess=True, height=320, width=320):
196
  mean, std = get_mean_std_per_batch(img_path, df, height, width)
197
  x = keras.utils.load_img(img_path, target_size=(height, width))
198
  x = keras.utils.img_to_array(x)
 
225
  for index, w in enumerate(weights):
226
  cam += w * output[:, :, index]
227
 
228
+ cam = cv2.resize(cam.numpy(), (320, 320), cv2.INTER_LINEAR)
229
  cam = np.maximum(cam, 0)
230
  cam = cam / cam.max()
231