dhhd255 commited on
Commit
451a56c
·
1 Parent(s): 724eb41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,17 +1,16 @@
1
  import streamlit as st
2
  from tensorflow import keras
3
  import numpy as np
4
- from huggingface_hub import HfApi
5
 
6
  # Authenticate and download the custom model from Hugging Face Spaces
7
- hf_api = HfApi()
8
- model_url = hf_api.presigned_url('dhhd255', 'idk_test', filename='best_model.h5', token='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')
9
- r = requests.get(model_url)
10
- with open('best_model.h5', 'wb') as f:
11
- f.write(r.content)
12
 
13
  # Load your custom model
14
- model = keras.models.load_model('best_model.h5')
15
 
16
  # Define a function that takes an image as input and uses the model for inference
17
  def image_classifier(image):
 
1
  import streamlit as st
2
  from tensorflow import keras
3
  import numpy as np
4
+ from huggingface_hub import HfFileSystem
5
 
6
  # Authenticate and download the custom model from Hugging Face Spaces
7
+ fs = HfFileSystem()
8
+ model_path = 'dhhd255/idk_test/best_model.h5'
9
+ with fs.open(model_path, 'rb') as f:
10
+ model_content = f.read()
 
11
 
12
  # Load your custom model
13
+ model = keras.models.load_model(model_content)
14
 
15
  # Define a function that takes an image as input and uses the model for inference
16
  def image_classifier(image):