drgou commited on
Commit
8491fd6
·
1 Parent(s): 77a0e99
Files changed (2) hide show
  1. app.py +10 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import os
6
  import numpy as np
7
  from PIL import Image
8
  from dotenv import load_dotenv
 
9
 
10
  load_dotenv()
11
 
@@ -22,10 +23,15 @@ app.add_middleware(
22
 
23
  ANIMALS = ["Cat", "Dog", "Panda"]
24
 
25
- # It would've been better to use an environment variable to fix this line actually...
26
- model_path = os.getenv("MODEL_PATH")
27
- print(model_path)
28
- model = tf.keras.models.load_model(model_path)
 
 
 
 
 
29
 
30
 
31
  @app.post('/upload/image')
 
6
  import numpy as np
7
  from PIL import Image
8
  from dotenv import load_dotenv
9
+ from huggingface_hub import hf_hub_download
10
 
11
  load_dotenv()
12
 
 
23
 
24
  ANIMALS = ["Cat", "Dog", "Panda"]
25
 
26
+
27
+ # Download your SavedModel from the Hub
28
+ repo_id = "drgou/howest-deployathome"
29
+ hf_hub_download(repo_id, filename="config.json", repo_type="model", local_dir="./model")
30
+ hf_hub_download(repo_id, filename="metadata.json", repo_type="model", local_dir="./model")
31
+ hf_hub_download(repo_id, filename="model.weights.h5", repo_type="model", local_dir="./model")
32
+
33
+ # Load it
34
+ model = tf.keras.models.load_model("./model")
35
 
36
 
37
  @app.post('/upload/image')
requirements.txt CHANGED
@@ -6,4 +6,5 @@ tensorflow==2.19.0
6
  pillow==11.2.1
7
  uvicorn==0.34.2
8
  python-multipart==0.0.20
9
- python-dotenv==1.1.0
 
 
6
  pillow==11.2.1
7
  uvicorn==0.34.2
8
  python-multipart==0.0.20
9
+ python-dotenv==1.1.0
10
+ huggingface_hub