Download code/scripts/run_image_qa_examples.py from CollinMa/nextgpt-chapter6-report: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/run_image_qa_examples.py
- Command line
-
hf download hf://spaces/CollinMa/nextgpt-chapter6-report/code/scripts/run_image_qa_examples.py
-
curl -L -o run_image_qa_examples.py https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/run_image_qa_examples.py
618 Bytes
| """Two actual image-to-text cases with one shared model load.""" | |
| 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)) | |
| from engine import ENGINE | |
| if __name__=='__main__': | |
| for image in ('dog_image.jpg','car_image.jpg'): | |
| result=ENGINE.run('Describe what is shown in this image in one short sentence.', | |
| image=str(ROOT/'examples/inputs'/image),max_tokens=64,steps=10,text_only=True) | |
| print(json.dumps({'input':image,**result},ensure_ascii=False,indent=2),flush=True) | |