merve HF staff commited on
Commit
29db0ee
1 Parent(s): 7d7b08f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,15 +1,19 @@
1
  from transformers import AutoModel, CLIPImageProcessor, CLIPTokenizer
2
  import torch
 
 
3
 
4
  model_name_or_path = "BAAI/EVA-CLIP-8B"
5
  image_size = 224
6
-
7
- processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14")
8
-
9
- model = AutoModel.from_pretrained(
10
- model_name_or_path,
11
- torch_dtype=torch.bfloat16,
12
- trust_remote_code=True).to('cuda').eval()
13
-
14
-
15
- tokenizer = CLIPTokenizer.from_pretrained(model_name_or_path)
 
 
 
1
  from transformers import AutoModel, CLIPImageProcessor, CLIPTokenizer
2
  import torch
3
+ import spaces
4
+
5
 
6
  model_name_or_path = "BAAI/EVA-CLIP-8B"
7
  image_size = 224
8
+ @spaces.GPU
9
+ def load_model():
10
+ processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14")
11
+
12
+ model = AutoModel.from_pretrained(
13
+ model_name_or_path,
14
+ torch_dtype=torch.bfloat16,
15
+ trust_remote_code=True).to('cuda').eval()
16
+
17
+
18
+ tokenizer = CLIPTokenizer.from_pretrained(model_name_or_path)
19
+ return model, tokenizer, processor