Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,22 @@ from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
|
|
3 |
from PIL import Image
|
4 |
import requests
|
5 |
from io import BytesIO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Load the model and processor
|
8 |
repo_name = "cyan2k/molmo-7B-O-bnb-4bit"
|
9 |
-
arguments = {"device_map": "auto", "torch_dtype": "
|
10 |
|
11 |
# Load the processor and model
|
12 |
processor = AutoProcessor.from_pretrained(repo_name, **arguments)
|
|
|
3 |
from PIL import Image
|
4 |
import requests
|
5 |
from io import BytesIO
|
6 |
+
import subprocess
|
7 |
+
import sys
|
8 |
+
|
9 |
+
def install_bitsandbytes():
|
10 |
+
# Uninstall bitsandbytes if installed
|
11 |
+
subprocess.run([sys.executable, "-m", "pip", "uninstall", "-y", "bitsandbytes"])
|
12 |
+
|
13 |
+
# Reinstall bitsandbytes with the required options
|
14 |
+
subprocess.run([sys.executable, "-m", "pip", "install", "bitsandbytes", "--force-reinstall", "--index-url", "https://pypi.org/simple/", "--no-cache-dir"])
|
15 |
+
|
16 |
+
# Call the function at the start of the script
|
17 |
+
install_bitsandbytes()
|
18 |
|
19 |
# Load the model and processor
|
20 |
repo_name = "cyan2k/molmo-7B-O-bnb-4bit"
|
21 |
+
arguments = {"device_map": "auto", "torch_dtype": "auto", "trust_remote_code": True}
|
22 |
|
23 |
# Load the processor and model
|
24 |
processor = AutoProcessor.from_pretrained(repo_name, **arguments)
|