Spaces:
Running
on
Zero
Running
on
Zero
Add again bnb
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import (
|
|
4 |
)
|
5 |
from transformers import (
|
6 |
AutoProcessor,
|
7 |
-
|
8 |
LlavaForConditionalGeneration,
|
9 |
)
|
10 |
from PIL import Image
|
@@ -38,12 +38,12 @@ USER_ID = None
|
|
38 |
model_id = "blanchon/PixDiet-pixtral-nutrition-v2"
|
39 |
|
40 |
# BitsAndBytesConfig int-4 config
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
# Modify the model and processor initialization
|
49 |
if TESTING:
|
@@ -55,7 +55,7 @@ else:
|
|
55 |
model_id,
|
56 |
device_map="auto",
|
57 |
torch_dtype=torch.bfloat16,
|
58 |
-
|
59 |
)
|
60 |
processor = AutoProcessor.from_pretrained(model_id)
|
61 |
|
|
|
4 |
)
|
5 |
from transformers import (
|
6 |
AutoProcessor,
|
7 |
+
BitsAndBytesConfig,
|
8 |
LlavaForConditionalGeneration,
|
9 |
)
|
10 |
from PIL import Image
|
|
|
38 |
model_id = "blanchon/PixDiet-pixtral-nutrition-v2"
|
39 |
|
40 |
# BitsAndBytesConfig int-4 config
|
41 |
+
bnb_config = BitsAndBytesConfig(
|
42 |
+
load_in_4bit=True,
|
43 |
+
bnb_4bit_use_double_quant=True,
|
44 |
+
bnb_4bit_quant_type="nf4",
|
45 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
46 |
+
)
|
47 |
|
48 |
# Modify the model and processor initialization
|
49 |
if TESTING:
|
|
|
55 |
model_id,
|
56 |
device_map="auto",
|
57 |
torch_dtype=torch.bfloat16,
|
58 |
+
quantization_config=bnb_config,
|
59 |
)
|
60 |
processor = AutoProcessor.from_pretrained(model_id)
|
61 |
|