aaravlovescodes commited on
Commit
221b833
·
verified ·
1 Parent(s): 2801237

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -52,11 +52,14 @@ st.set_option("deprecation.showfileUploaderEncoding", False)
52
  @st.cache_resource(show_spinner=False)
53
  def load_model():
54
  try:
55
- from huggingface_hub import from_pretrained_keras, hf_hub_download
 
56
 
57
  # Download the model files directly
58
  model_path = hf_hub_download(repo_id="ryefoxlime/PneumoniaDetection", filename="saved_model.pb")
59
- model = keras.models.load_model(model_path)
 
 
60
  return model
61
  except Exception as e:
62
  st.error(f"Error loading model: {str(e)}")
 
52
  @st.cache_resource(show_spinner=False)
53
  def load_model():
54
  try:
55
+ from huggingface_hub import hf_hub_download
56
+ from keras.layers import TFSMLayer
57
 
58
  # Download the model files directly
59
  model_path = hf_hub_download(repo_id="ryefoxlime/PneumoniaDetection", filename="saved_model.pb")
60
+
61
+ # Use TFSMLayer to load the model
62
+ model = TFSMLayer(model_path, call_endpoint='serving_default')
63
  return model
64
  except Exception as e:
65
  st.error(f"Error loading model: {str(e)}")