Download scripts/predownload_qwen3vl.py from Tinghong-Ye22/code-HFD: direct link, hf CLI and curl.
- Browser
- Download file 742 Bytes
-
https://huggingface.co/Tinghong-Ye22/code-HFD/resolve/main/scripts/predownload_qwen3vl.py
- Command line
-
hf download hf://Tinghong-Ye22/code-HFD/scripts/predownload_qwen3vl.py
-
curl -L -o predownload_qwen3vl.py https://huggingface.co/Tinghong-Ye22/code-HFD/resolve/main/scripts/predownload_qwen3vl.py
742 Bytes
| import os | |
| dotenv_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env') | |
| assert os.path.exists(dotenv_path), f".env file not found at {dotenv_path}" | |
| from dotenv import load_dotenv | |
| load_dotenv(dotenv_path) | |
| print("HF_HOME:", os.getenv("HF_HOME")) | |
| print("TORCH_HOME:", os.getenv("TORCH_HOME")) | |
| import torch | |
| from transformers import Qwen3VLForConditionalGeneration, AutoProcessor | |
| model = Qwen3VLForConditionalGeneration.from_pretrained( | |
| "Qwen/Qwen3-VL-2B-Instruct", | |
| attn_implementation="flash_attention_2", | |
| dtype=torch.bfloat16, | |
| device_map={"": "cuda:0"}, | |
| # local_files_only=True | |
| ) | |
| print("Model loaded.") | |
| vlm_processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-2B-Instruct") | |
| print("Processor loaded.") | |