multimodalart HF Staff commited on
Commit
2a23192
·
verified ·
1 Parent(s): 6445403

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +36 -4
app.py CHANGED
@@ -14,13 +14,45 @@ subprocess.run(
14
  )
15
  print(f"After pip install: cuda_available={torch.cuda.is_available()}")
16
 
 
17
  from chatterbox_flash import ChatterboxFlashTTS
18
  print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
19
 
20
- # Load model on CPU
21
- tts = ChatterboxFlashTTS.from_pretrained("ResembleAI/chatterbox-flash", device="cpu", dtype=torch.bfloat16)
22
- print(f"After model load on CPU: cuda_available={torch.cuda.is_available()}")
23
- print("Model loaded successfully.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  import gradio as gr
26
 
 
14
  )
15
  print(f"After pip install: cuda_available={torch.cuda.is_available()}")
16
 
17
+ # Test: just import chatterbox, don't load model
18
  from chatterbox_flash import ChatterboxFlashTTS
19
  print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
20
 
21
+ # Test: load just the voice encoder (small model)
22
+ from chatterbox.models.ve.model import VoiceEncoder
23
+ from safetensors.torch import load_file
24
+ import tempfile, os as _os
25
+ from huggingface_hub import hf_hub_download
26
+
27
+ print("Downloading ve.safetensors...")
28
+ ve_path = hf_hub_download("ResembleAI/chatterbox-flash", "ve.safetensors")
29
+ ve = VoiceEncoder()
30
+ ve.load_state_dict(load_file(ve_path))
31
+ ve.to("cpu").eval()
32
+ print(f"After ve load: cuda_available={torch.cuda.is_available()}")
33
+
34
+ # Test: load just the t3 model
35
+ from chatterbox_flash.t3 import ChatterboxFlashT3
36
+ print("Downloading t3_flash.safetensors...")
37
+ t3_path = hf_hub_download("ResembleAI/chatterbox-flash", "t3_flash.safetensors")
38
+ t3 = ChatterboxFlashT3(drf_block_size=16)
39
+ t3_state = load_file(t3_path)
40
+ if "model" in t3_state:
41
+ t3_state = t3_state["model"][0]
42
+ t3.load_state_dict(t3_state)
43
+ t3.to(device="cpu", dtype=torch.bfloat16).eval()
44
+ print(f"After t3 load: cuda_available={torch.cuda.is_available()}")
45
+
46
+ # Test: load s3gen
47
+ from chatterbox.models.s3gen.s3gen import S3Gen
48
+ print("Downloading s3gen.safetensors...")
49
+ s3gen_path = hf_hub_download("ResembleAI/chatterbox-flash", "s3gen.safetensors")
50
+ s3gen = S3Gen(meanflow=True)
51
+ s3gen.load_state_dict(load_file(s3gen_path), strict=False)
52
+ s3gen.to("cpu").eval()
53
+ print(f"After s3gen load: cuda_available={torch.cuda.is_available()}")
54
+
55
+ print("All models loaded on CPU. Testing GPU...")
56
 
57
  import gradio as gr
58