Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoModel, AutoTokenizer
|
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
import traceback
|
7 |
-
import
|
8 |
# Argument Parsing
|
9 |
parser = argparse.ArgumentParser(description='demo')
|
10 |
parser.add_argument('--device', type=str, default='cuda', help='cuda or mps')
|
@@ -14,11 +14,18 @@ assert device in ['cuda', 'mps']
|
|
14 |
|
15 |
# Load model and tokenizer manually
|
16 |
model_path = 'openbmb/MiniCPM-Llama3-V-2_5'
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
19 |
model.eval()
|
20 |
|
21 |
-
|
22 |
model_name = 'MiniCPM-Llama3-V 2.5'
|
23 |
|
24 |
def chat(image, msgs, sampling=True, temperature=0.7, stream=False):
|
|
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
import traceback
|
7 |
+
import spaces
|
8 |
# Argument Parsing
|
9 |
parser = argparse.ArgumentParser(description='demo')
|
10 |
parser.add_argument('--device', type=str, default='cuda', help='cuda or mps')
|
|
|
14 |
|
15 |
# Load model and tokenizer manually
|
16 |
model_path = 'openbmb/MiniCPM-Llama3-V-2_5'
|
17 |
+
if 'int4' in model_path:
|
18 |
+
if device == 'mps':
|
19 |
+
print('Error: running int4 model with bitsandbytes on Mac is not supported right now.')
|
20 |
+
exit()
|
21 |
+
model = AutoModel.from_pretrained(model_path, trust_remote_code=True)
|
22 |
+
else:
|
23 |
+
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.float16)
|
24 |
+
model = model.to(device=device)
|
25 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
26 |
model.eval()
|
27 |
|
28 |
+
|
29 |
model_name = 'MiniCPM-Llama3-V 2.5'
|
30 |
|
31 |
def chat(image, msgs, sampling=True, temperature=0.7, stream=False):
|