omkar90 commited on
Commit
b58f415
·
verified ·
1 Parent(s): 07634cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -7,6 +7,10 @@ import io
7
  import torch
8
  import clip
9
  import tensorflow as tf
 
 
 
 
10
 
11
  app = FastAPI()
12
 
@@ -14,8 +18,14 @@ app = FastAPI()
14
  tflite_model = tf.lite.Interpreter(model_path="resnet_model.tflite")
15
  tflite_model.allocate_tensors()
16
 
 
 
17
  clip_device = "cuda" if torch.cuda.is_available() else "cpu"
18
- clip_model, clip_preprocess = clip.load("ViT-B/32", device=clip_device)
 
 
 
 
19
 
20
 
21
  # Class names
 
7
  import torch
8
  import clip
9
  import tensorflow as tf
10
+ import os
11
+
12
+
13
+
14
 
15
  app = FastAPI()
16
 
 
18
  tflite_model = tf.lite.Interpreter(model_path="resnet_model.tflite")
19
  tflite_model.allocate_tensors()
20
 
21
+ # clip_device = "cuda" if torch.cuda.is_available() else "cpu"
22
+ # clip_model, clip_preprocess = clip.load("ViT-B/32", device=clip_device)
23
  clip_device = "cuda" if torch.cuda.is_available() else "cpu"
24
+
25
+ # Create a writable models directory
26
+ os.makedirs("models", exist_ok=True)
27
+
28
+ clip_model, clip_preprocess = clip.load("ViT-B/32", device=clip_device, download_root="./models")
29
 
30
 
31
  # Class names