Download app.py from Socold/Valaxy: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/spaces/Socold/Valaxy/resolve/main/app.py
- Command line
-
hf download hf://spaces/Socold/Valaxy/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Socold/Valaxy/resolve/main/app.py
1.94 kB
| import os | |
| import subprocess | |
| import sys | |
| # Cloner votre repository | |
| if not os.path.exists("VV_Clone_1"): | |
| subprocess.run(["git", "clone", "https://github.com/Socold/VV_Clone_1.git"]) | |
| sys.path.insert(0, "VV_Clone_1") | |
| # Installer les dépendances | |
| subprocess.run([sys.executable, "-m", "pip", "install", "-q", | |
| "torch", "transformers>=4.40.0", "accelerate", "gradio>=4.0.0", | |
| "soundfile", "librosa", "scipy", "numpy", "ffmpeg-python"]) | |
| subprocess.run([sys.executable, "-m", "pip", "install", "-e", "VV_Clone_1"]) | |
| import torch | |
| import gradio as gr | |
| # Configuration - Changé pour utiliser 7B | |
| MODEL_PATH = "aoi-ot/VibeVoice-7B" # ← Modifié ici | |
| # Récupérer les secrets (invisibles publiquement) | |
| USERNAME = os.environ.get("AUTH_USERNAME") | |
| PASSWORD = os.environ.get("AUTH_PASSWORD") | |
| print(f"Chargement du modèle: {MODEL_PATH}") | |
| print(f"GPU: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU'}") | |
| print(f"VRAM disponible: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.2f} GB") | |
| # Lancer le script principal avec les arguments | |
| os.chdir("VV_Clone_1") | |
| sys.argv = ["gradio_demo.py", "--model_path", MODEL_PATH, "--share"] | |
| # Importer et modifier le main pour ajouter l'auth | |
| from demo.gradio_demo import main | |
| # Si les secrets existent, modifier le fichier pour ajouter l'auth | |
| if USERNAME and PASSWORD: | |
| with open("demo/gradio_demo.py", "r") as f: | |
| content = f.read() | |
| # Remplacer la ligne launch pour ajouter auth | |
| content = content.replace( | |
| 'demo.launch(share=args.share)', | |
| f'demo.launch(share=args.share, auth=("{USERNAME}", "{PASSWORD}"))' | |
| ) | |
| with open("demo/gradio_demo.py", "w") as f: | |
| f.write(content) | |
| print(f"Authentification activée pour l'utilisateur: {USERNAME}") | |
| else: | |
| print("Pas d'authentification configurée (pas de secrets définis)") | |
| # Lancer le main | |
| print("Démarrage de l'interface VibeVoice-7B...") | |
| main() |