zamal commited on
Commit
11161c7
·
verified ·
1 Parent(s): 7ba17c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
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": "float16", "trust_remote_code": True}
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)