Spaces:
Sleeping
Sleeping
| """ | |
| Script to download required ML models. | |
| """ | |
| from app.core.config import settings | |
| from pathlib import Path | |
| import requests | |
| from tqdm import tqdm | |
| def download_file(url: str, destination: Path): | |
| response = requests.get(url, stream=True) | |
| total_size = int(response.headers.get('content-length', 0)) | |
| with open(destination, 'wb') as file, tqdm( | |
| total=total_size, | |
| unit='B', | |
| unit_scale=True | |
| ) as pbar: | |
| for chunk in response.iter_content(chunk_size=8192): | |
| file.write(chunk) | |
| pbar.update(len(chunk)) | |
| def main(): | |
| model_dir = settings.model_path | |
| model_dir.mkdir(parents=True, exist_ok=True) | |
| # Add your model download URL | |
| model_url = "https://huggingface.co/.../Qwen2.5-0.5B-Instruct-Q4_K_M.gguf" | |
| model_path = model_dir / settings.qwen_model_file | |
| if model_path.exists(): | |
| print(f"Model already exists: {model_path}") | |
| return | |
| print(f"Downloading model to {model_path}...") | |
| download_file(model_url, model_path) | |
| print("Download complete!") | |
| if __name__ == "__main__": | |
| main() | |