Download code/scripts/run_local_gpu.py from CollinMa/nextgpt-chapter6-report: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/run_local_gpu.py
- Command line
-
hf download hf://spaces/CollinMa/nextgpt-chapter6-report/code/scripts/run_local_gpu.py
-
curl -L -o run_local_gpu.py https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/run_local_gpu.py
988 Bytes
| """Run the genuine model with CPU parameter offload on the local GPU.""" | |
| import argparse | |
| import json | |
| import os | |
| import sys | |
| from pathlib import Path | |
| os.environ["NEXTGPT_LOW_VRAM"] = "1" | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--prompt', default='Describe the animal in this image in one short sentence.') | |
| parser.add_argument('--image', default=str(ROOT/'examples/inputs/dog_image.jpg')) | |
| parser.add_argument('--video') | |
| parser.add_argument('--audio') | |
| parser.add_argument('--max-tokens', type=int, default=64) | |
| parser.add_argument('--steps', type=int, default=10) | |
| args = parser.parse_args() | |
| from engine import ENGINE | |
| result = ENGINE.run(args.prompt, args.image or None, args.video, args.audio, | |
| max_tokens=args.max_tokens, steps=args.steps) | |
| print(json.dumps(result, ensure_ascii=False, indent=2), flush=True) | |