Fuyu Example#

Source vllm-project/vllm.

 1import requests
 2from PIL import Image
 3
 4from vllm import LLM, SamplingParams
 5
 6
 7def run_fuyu():
 8    llm = LLM(model="adept/fuyu-8b", max_model_len=4096)
 9
10    # single-image prompt
11    prompt = "What is the highest life expectancy at of male?\n"
12    url = "https://huggingface.co/adept/fuyu-8b/resolve/main/chart.png"
13    image = Image.open(requests.get(url, stream=True).raw)
14    sampling_params = SamplingParams(temperature=0, max_tokens=64)
15
16    outputs = llm.generate(
17        {
18            "prompt": prompt,
19            "multi_modal_data": {
20                "image": image
21            },
22        },
23        sampling_params=sampling_params)
24
25    for o in outputs:
26        generated_text = o.outputs[0].text
27        print(generated_text)
28
29
30if __name__ == "__main__":
31    run_fuyu()