Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,13 @@ st.header("Turn Your Image to a Short Audio Story for Children")
|
|
62 |
# Model loading
|
63 |
@st.cache_resource
|
64 |
def load_models():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
return {
|
66 |
"img_model": pipeline("image-to-text", "cnmoro/tiny-image-captioning"),
|
67 |
"story_model": pipeline(
|
@@ -69,12 +76,8 @@ def load_models():
|
|
69 |
"Qwen/Qwen2.5-0.5B-Instruct",
|
70 |
device_map="auto",
|
71 |
model_kwargs={
|
72 |
-
"
|
73 |
-
"
|
74 |
-
"load_in_4bit": True,
|
75 |
-
"bnb_4bit_compute_dtype": torch.float16,
|
76 |
-
"bnb_4bit_quant_type": "nf4"
|
77 |
-
}
|
78 |
}
|
79 |
)
|
80 |
}
|
|
|
62 |
# Model loading
|
63 |
@st.cache_resource
|
64 |
def load_models():
|
65 |
+
# Configure 4-bit quantization properly
|
66 |
+
quantization_config = BitsAndBytesConfig(
|
67 |
+
load_in_4bit=True,
|
68 |
+
bnb_4bit_compute_dtype=torch.float16,
|
69 |
+
bnb_4bit_quant_type="nf4"
|
70 |
+
)
|
71 |
+
|
72 |
return {
|
73 |
"img_model": pipeline("image-to-text", "cnmoro/tiny-image-captioning"),
|
74 |
"story_model": pipeline(
|
|
|
76 |
"Qwen/Qwen2.5-0.5B-Instruct",
|
77 |
device_map="auto",
|
78 |
model_kwargs={
|
79 |
+
"quantization_config": quantization_config,
|
80 |
+
"torch_dtype": torch.float16
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
)
|
83 |
}
|