Kalbe-x-Bangkit commited on
Commit
834264e
1 Parent(s): 6390d35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -233,14 +233,15 @@ def grad_cam(input_model, img_array, cls, layer_name):
233
 
234
  # Compute Grad-CAM
235
  def compute_gradcam(model, img_path, layer_name='bn'):
236
- base_model = keras.applications.DenseNet121(weights = './densenet.hdf5', include_top = False)
237
- x = base_model.output
238
- x = keras.layers.GlobalAveragePooling2D()(x)
239
- predictions = keras.layers.Dense(14, activation = "sigmoid")(x)
240
- model_gradcam = keras.Model(inputs=base_model.input, outputs=predictions)
241
- model_gradcam.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),
242
- loss='sparse_categorical_crossentropy')
243
- model.load_weights('./pretrained_model.h5')
 
244
 
245
  preprocessed_input = load_image(img_path)
246
  predictions = model_gradcam.predict(preprocessed_input)
 
233
 
234
  # Compute Grad-CAM
235
  def compute_gradcam(model, img_path, layer_name='bn'):
236
+ # base_model = keras.applications.DenseNet121(weights = './densenet.hdf5', include_top = False)
237
+ # x = base_model.output
238
+ # x = keras.layers.GlobalAveragePooling2D()(x)
239
+ # predictions = keras.layers.Dense(14, activation = "sigmoid")(x)
240
+ # model_gradcam = keras.Model(inputs=base_model.input, outputs=predictions)
241
+ # model_gradcam.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),
242
+ # loss='sparse_categorical_crossentropy')
243
+ # model.load_weights('./pretrained_model.h5')
244
+ model_gradcam = keras.models.load_model('./gradcam_model.h5')
245
 
246
  preprocessed_input = load_image(img_path)
247
  predictions = model_gradcam.predict(preprocessed_input)