RubenVierstraete commited on
Commit
c2ceacd
·
1 Parent(s): 23f66eb

changed main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -12
main.py CHANGED
@@ -7,7 +7,6 @@ from fastapi.middleware.cors import CORSMiddleware
7
  from fastapi import FastAPI
8
  from huggingface_hub import hf_hub_download
9
 
10
- # test
11
  app = FastAPI()
12
 
13
  app.add_middleware(
@@ -21,18 +20,14 @@ app.add_middleware(
21
  # Animal names here
22
  ANIMALS = ['Cat', 'Dog', 'Panda']
23
 
24
- model_path = hf_hub_download(
25
- repo_id="RubenVierstraete/masterclass-2025",
26
- filename="model.keras",
27
- repo_type="model",
28
- cache_dir="/tmp/hf_cache"
29
- )
30
-
31
- model = tf.keras.models.load_model(model_path)
32
-
33
-
34
-
35
 
 
 
36
 
37
 
38
  @app.post('/upload/image')
 
7
  from fastapi import FastAPI
8
  from huggingface_hub import hf_hub_download
9
 
 
10
  app = FastAPI()
11
 
12
  app.add_middleware(
 
20
  # Animal names here
21
  ANIMALS = ['Cat', 'Dog', 'Panda']
22
 
23
+ # 1) download your SavedModel from the Hub
24
+ repo_id = "RubenVierstraete/masterclass-2025"
25
+ hf_hub_download(repo_id, filename="config.json", repo_type="model", local_dir="./model")
26
+ hf_hub_download(repo_id, filename="metadata.json", repo_type="model", local_dir="./model")
27
+ hf_hub_download(repo_id, filename="model.weights.h5", repo_type="model", local_dir="./model")
 
 
 
 
 
 
28
 
29
+ # 2) load it
30
+ model = tf.keras.models.load_model("./model")
31
 
32
 
33
  @app.post('/upload/image')