Spaces:
Build error
Build error
srivatsavdamaraju
commited on
Commit
•
4ab173c
1
Parent(s):
02d43f4
Update app.py
Browse files
app.py
CHANGED
@@ -3,11 +3,17 @@ from PIL import Image
|
|
3 |
from transformers import AutoModel, AutoTokenizer
|
4 |
import gradio as gr
|
5 |
|
|
|
|
|
|
|
6 |
# Load the model and tokenizer
|
7 |
-
model = AutoModel.from_pretrained(
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
# Function to process the image and question
|
13 |
def predict(image, question):
|
|
|
3 |
from transformers import AutoModel, AutoTokenizer
|
4 |
import gradio as gr
|
5 |
|
6 |
+
# Check if GPU is available and set the device
|
7 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
8 |
+
|
9 |
# Load the model and tokenizer
|
10 |
+
model = AutoModel.from_pretrained(
|
11 |
+
'openbmb/MiniCPM-V',
|
12 |
+
trust_remote_code=True,
|
13 |
+
torch_dtype=torch.bfloat16 if device == 'cuda' else torch.float32
|
14 |
+
)
|
15 |
+
model = model.eval().to(device)
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
|
17 |
|
18 |
# Function to process the image and question
|
19 |
def predict(image, question):
|