Update app.py
Browse files
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 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
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
|