Spaces:
Build error
Build error
| """ | |
| Downloads all required models into ./models/ | |
| Run this AFTER setup.bat | |
| Models: | |
| 1. Qwen2.5-VL-7B Q4_K_M (~4.68 GB) β vision + language brain | |
| 2. Qwen2.5-VL mmproj (~300 MB) β lets AI "see" the image | |
| Whisper + Coqui TTS auto-download on first app.py run | |
| """ | |
| from pathlib import Path | |
| from huggingface_hub import hf_hub_download, list_repo_files | |
| import os | |
| MODELS_DIR = Path("./models") | |
| MODELS_DIR.mkdir(exist_ok=True) | |
| def download_file(repo_id, filename, desc): | |
| print(f"\nβ¬οΈ {desc}") | |
| print(f" repo : {repo_id}") | |
| print(f" file : {filename}") | |
| print(f" to : {MODELS_DIR}/") | |
| print(" (progress bar will appear below...)\n") | |
| path = hf_hub_download( | |
| repo_id=repo_id, | |
| filename=filename, | |
| local_dir=str(MODELS_DIR), | |
| ) | |
| size_gb = os.path.getsize(path) / (1024**3) | |
| print(f"\n β Saved β {path} ({size_gb:.2f} GB)") | |
| return path | |
| print("\n=== SunoDoc Model Downloader ===") | |
| print("Repo : unsloth/Qwen2.5-VL-7B-Instruct-GGUF (confirmed correct)") | |
| print("Total : ~5 GB one-time download\n") | |
| # ββ 1. Find the mmproj filename dynamically βββββββββββββββββββββββββββββββββββ | |
| print("π Scanning repo for mmproj file...") | |
| REPO = "unsloth/Qwen2.5-VL-7B-Instruct-GGUF" | |
| all_files = list(list_repo_files(REPO)) | |
| mmproj_files = [f for f in all_files if "mmproj" in f.lower()] | |
| q4_files = [f for f in all_files if "q4_k_m" in f.lower() and f.endswith(".gguf")] | |
| print(f" Found Q4_K_M files : {q4_files}") | |
| print(f" Found mmproj files : {mmproj_files}") | |
| if not q4_files: | |
| print("\nβ Q4_K_M file not found in repo. Available files:") | |
| for f in all_files: | |
| print(f" {f}") | |
| exit(1) | |
| MAIN_FILE = q4_files[0] | |
| MMPROJ_FILE = mmproj_files[0] if mmproj_files else None | |
| # ββ 2. Download main model ββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| download_file(REPO, MAIN_FILE, "Qwen2.5-VL-7B main model (~4.68 GB) β the AI brain") | |
| # ββ 3. Download mmproj (vision connector) ββββββββββββββββββββββββββββββββββββ | |
| if MMPROJ_FILE: | |
| download_file(REPO, MMPROJ_FILE, "mmproj vision connector (~300 MB)") | |
| else: | |
| print("\nβ οΈ No mmproj file found in this repo.") | |
| print(" Trying ggml-org/Qwen2.5-VL-7B-Instruct-GGUF as fallback...") | |
| FALLBACK_REPO = "ggml-org/Qwen2.5-VL-7B-Instruct-GGUF" | |
| fb_files = list(list_repo_files(FALLBACK_REPO)) | |
| fb_mmproj = [f for f in fb_files if "mmproj" in f.lower()] | |
| if fb_mmproj: | |
| download_file(FALLBACK_REPO, fb_mmproj[0], "mmproj vision connector (fallback repo)") | |
| else: | |
| print(" β mmproj not found in fallback either. Check HuggingFace manually.") | |
| # ββ 4. Summary ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| print("\n=== Download complete! ===\n") | |
| print("Files in ./models/:") | |
| for f in sorted(MODELS_DIR.iterdir()): | |
| if f.is_file(): | |
| size_gb = f.stat().st_size / (1024**3) | |
| print(f" {f.name:60s} {size_gb:.2f} GB") | |
| print("\nπ₯ Whisper (STT) will auto-download on first app.py run (~500 MB)") | |
| print("π₯ Coqui Hindi TTS will auto-download on first TTS call (~100 MB)") | |
| print("\nβ Next step: python app.py") | |