Spaces:
Runtime error
Runtime error
chats-bug
commited on
Commit
·
7917b37
1
Parent(s):
8236a85
Qconfig
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import open_clip
|
|
5 |
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
|
8 |
-
|
9 |
# Use when running on a CPU
|
10 |
device_map = {
|
11 |
"transformer.word_embeddings": 0,
|
@@ -17,7 +17,12 @@ device_map = {
|
|
17 |
|
18 |
# Load the Blip2 model
|
19 |
preprocessor_blip2_8_bit = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
20 |
-
model_blip2_8_bit = Blip2ForConditionalGeneration.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Load the Blip base model
|
23 |
# preprocessor_blip_base = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
|
|
5 |
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
|
8 |
+
quantization_config = BitsAndBytesConfig(llm_int8_enable_fp32_cpu_offload=True)
|
9 |
# Use when running on a CPU
|
10 |
device_map = {
|
11 |
"transformer.word_embeddings": 0,
|
|
|
17 |
|
18 |
# Load the Blip2 model
|
19 |
preprocessor_blip2_8_bit = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
20 |
+
model_blip2_8_bit = Blip2ForConditionalGeneration.from_pretrained(
|
21 |
+
"Salesforce/blip2-opt-2.7b",
|
22 |
+
device_map=device_map,
|
23 |
+
quantization_config=quantization_config,
|
24 |
+
load_in_8bit=True
|
25 |
+
)
|
26 |
|
27 |
# Load the Blip base model
|
28 |
# preprocessor_blip_base = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|