MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / generate_output

Function generate_output

light-eval/src/eval_llavabenchmark.py:129–144  ·  view source on GitHub ↗
(model, img_path,prompt)

Source from the content-addressed store, hash-verified

127
128@ torch.inference_mode()
129def generate_output(model, img_path,prompt):
130
131 if img_path is not None:
132 image = Image.open(img_path).convert('RGB')
133 image = transform_val(image).unsqueeze(0)
134 else:
135 image = None
136 _prompt = format_prompt(prompt)
137
138 if image is not None:
139 image = image.cuda()
140 with torch.cuda.amp.autocast(dtype=torch.bfloat16):
141 results = model.generate([_prompt], image, max_gen_len=512, temperature=0.1, top_p=0.7)
142 text_output = results[0].strip()
143
144 return text_output
145
146
147

Callers 1

eval_llava_benchmarkFunction · 0.70

Calls 2

format_promptFunction · 0.70
generateMethod · 0.45

Tested by

no test coverage detected