Spaces:
Running
on
Zero
Running
on
Zero
mjavaid
commited on
Commit
·
b7430e6
1
Parent(s):
278a9c4
first commit
Browse files
app.py
CHANGED
@@ -5,7 +5,9 @@ from PIL import Image
|
|
5 |
import io
|
6 |
import requests
|
7 |
import spaces
|
|
|
8 |
|
|
|
9 |
# Initialize model and processor globally for caching
|
10 |
model_id = "CohereForAI/aya-vision-8b"
|
11 |
processor = None
|
@@ -17,7 +19,7 @@ def load_model():
|
|
17 |
try:
|
18 |
processor = AutoProcessor.from_pretrained(model_id)
|
19 |
model = AutoModelForImageTextToText.from_pretrained(
|
20 |
-
model_id, device_map="auto", torch_dtype=torch.float16
|
21 |
)
|
22 |
return "Model loaded successfully!"
|
23 |
except Exception as e:
|
|
|
5 |
import io
|
6 |
import requests
|
7 |
import spaces
|
8 |
+
import os
|
9 |
|
10 |
+
hf_token = os.environ.get("HF_TOKEN")
|
11 |
# Initialize model and processor globally for caching
|
12 |
model_id = "CohereForAI/aya-vision-8b"
|
13 |
processor = None
|
|
|
19 |
try:
|
20 |
processor = AutoProcessor.from_pretrained(model_id)
|
21 |
model = AutoModelForImageTextToText.from_pretrained(
|
22 |
+
model_id, device_map="auto", torch_dtype=torch.float16, use_auth_token=hf_token
|
23 |
)
|
24 |
return "Model loaded successfully!"
|
25 |
except Exception as e:
|