nextgpt-chapter6-report / code /scripts /run_image_qa_examples.py
CollinMa's picture
Publish NExT-GPT course code and actual execution records
2c2701e verified
Raw History Blame Contribute Delete
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)