frankai98 commited on
Commit
b3f4787
·
verified ·
1 Parent(s): f1a75fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
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
- "load_in_4bit": True,
73
- "quantization_config": {
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
  }