alakxender commited on
Commit
47e20c9
·
1 Parent(s): 698de8d
Files changed (2) hide show
  1. app.py +2 -2
  2. csm1b_dv.py +8 -4
app.py CHANGED
@@ -15,7 +15,7 @@ from csm1b_dv import (
15
  split_sentences, extract_audio_output, generate_conversation,
16
  change_model_and_update_ui
17
  )
18
- from dia_1_6B_dv import get_dia_1_6B_tab
19
 
20
  with gr.Blocks(
21
  title="Dhivehi (Thaana) Text-to-Speech",
@@ -36,7 +36,7 @@ with gr.Blocks(
36
  """
37
  ) as app:
38
  get_csm1b_tab()
39
- get_dia_1_6B_tab()
40
 
41
  if __name__ == "__main__":
42
  app.launch(share=False)
 
15
  split_sentences, extract_audio_output, generate_conversation,
16
  change_model_and_update_ui
17
  )
18
+ #from dia_1_6B_dv import get_dia_1_6B_tab
19
 
20
  with gr.Blocks(
21
  title="Dhivehi (Thaana) Text-to-Speech",
 
36
  """
37
  ) as app:
38
  get_csm1b_tab()
39
+ # get_dia_1_6B_tab()
40
 
41
  if __name__ == "__main__":
42
  app.launch(share=False)
csm1b_dv.py CHANGED
@@ -80,9 +80,13 @@ def load_model(model_name):
80
  return False
81
  model_id = MODELS[model_name]
82
  print(f"Model ID: {model_id}")
83
- if current_model_id == model_id:
84
- print(f"Model '{model_name}' already loaded")
85
  return True
 
 
 
 
86
  try:
87
  print(f"Loading model '{model_name}' on {device}...")
88
  if model is not None:
@@ -92,7 +96,7 @@ def load_model(model_name):
92
 
93
  print(f"Loading processor from {model_id}...")
94
  processor = AutoProcessor.from_pretrained(model_id)
95
- print(f"Processor loaded successfully")
96
 
97
  if hasattr(processor.tokenizer, "init_kwargs"):
98
  processor.tokenizer.init_kwargs.pop("pad_to_multiple_of", None)
@@ -103,7 +107,7 @@ def load_model(model_name):
103
  device_map=device,
104
  torch_dtype=torch.float32
105
  )
106
- print(f"Model loaded successfully")
107
 
108
  # Check if model has generate method
109
  if hasattr(model, 'generate'):
 
80
  return False
81
  model_id = MODELS[model_name]
82
  print(f"Model ID: {model_id}")
83
+ if current_model_id == model_id and model is not None and processor is not None:
84
+ print(f"Model '{model_name}' already loaded and valid")
85
  return True
86
+ elif current_model_id == model_id:
87
+ print(f"Model '{model_name}' was previously loaded but model/processor is None, reloading...")
88
+ # Reset the current_model_id to force reload
89
+ current_model_id = None
90
  try:
91
  print(f"Loading model '{model_name}' on {device}...")
92
  if model is not None:
 
96
 
97
  print(f"Loading processor from {model_id}...")
98
  processor = AutoProcessor.from_pretrained(model_id)
99
+ print(f"Processor loaded successfully: {processor is not None}")
100
 
101
  if hasattr(processor.tokenizer, "init_kwargs"):
102
  processor.tokenizer.init_kwargs.pop("pad_to_multiple_of", None)
 
107
  device_map=device,
108
  torch_dtype=torch.float32
109
  )
110
+ print(f"Model loaded successfully: {model is not None}")
111
 
112
  # Check if model has generate method
113
  if hasattr(model, 'generate'):