File size: 618 Bytes
2c2701e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | """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)
|