Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
os.environ.setdefault("NUMBA_DISABLE_CUDA", "1")
|
| 3 |
|
| 4 |
import spaces
|
| 5 |
import torch
|
| 6 |
print(f"After import spaces: cuda_available={torch.cuda.is_available()}")
|
| 7 |
|
| 8 |
-
# Install chatterbox packages
|
| 9 |
import subprocess, sys
|
| 10 |
subprocess.run(
|
| 11 |
[sys.executable, "-m", "pip", "install", "--no-deps",
|
|
@@ -17,11 +17,17 @@ print(f"After pip install: cuda_available={torch.cuda.is_available()}")
|
|
| 17 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 18 |
print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
import gradio as gr
|
| 21 |
|
| 22 |
@spaces.GPU(duration=60)
|
| 23 |
def test_gpu(text):
|
| 24 |
-
return f"CUDA
|
| 25 |
|
| 26 |
demo = gr.Interface(fn=test_gpu, inputs=gr.Textbox(value="test"), outputs=gr.Textbox())
|
| 27 |
demo.launch(mcp_server=True)
|
|
|
|
| 1 |
import os
|
| 2 |
+
os.environ.setdefault("CHATTERBOX_FLASH_ENGINE", "torch")
|
| 3 |
os.environ.setdefault("NUMBA_DISABLE_CUDA", "1")
|
| 4 |
|
| 5 |
import spaces
|
| 6 |
import torch
|
| 7 |
print(f"After import spaces: cuda_available={torch.cuda.is_available()}")
|
| 8 |
|
|
|
|
| 9 |
import subprocess, sys
|
| 10 |
subprocess.run(
|
| 11 |
[sys.executable, "-m", "pip", "install", "--no-deps",
|
|
|
|
| 17 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 18 |
print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
|
| 19 |
|
| 20 |
+
MODEL_ID = "ResembleAI/chatterbox-flash"
|
| 21 |
+
print(f"Loading model from {MODEL_ID}...")
|
| 22 |
+
tts = ChatterboxFlashTTS.from_pretrained(MODEL_ID, device="cuda", dtype=torch.bfloat16)
|
| 23 |
+
print(f"After model load: cuda_available={torch.cuda.is_available()}")
|
| 24 |
+
print("Model loaded successfully.")
|
| 25 |
+
|
| 26 |
import gradio as gr
|
| 27 |
|
| 28 |
@spaces.GPU(duration=60)
|
| 29 |
def test_gpu(text):
|
| 30 |
+
return f"CUDA: {torch.cuda.is_available()}, devices: {torch.cuda.device_count()}"
|
| 31 |
|
| 32 |
demo = gr.Interface(fn=test_gpu, inputs=gr.Textbox(value="test"), outputs=gr.Textbox())
|
| 33 |
demo.launch(mcp_server=True)
|