(model, img_path, prompt)
| 114 | |
| 115 | @ torch.inference_mode() |
| 116 | def generate_output(model, img_path, prompt): |
| 117 | print("image path:", img_path) |
| 118 | if img_path is not None: |
| 119 | image = Image.open(img_path).convert('RGB') |
| 120 | image = transform_val(image).unsqueeze(0) |
| 121 | else: |
| 122 | image = None |
| 123 | _prompt = format_prompt(prompt) |
| 124 | |
| 125 | if image is not None: |
| 126 | image = image.cuda() |
| 127 | |
| 128 | with torch.cuda.amp.autocast(dtype=torch.bfloat16): |
| 129 | results = model.generate([_prompt], image, max_gen_len=512, temperature=0.1, top_p=0.7) |
| 130 | text_output = results[0].strip() |
| 131 | return text_output |
| 132 | |
| 133 | def eval_MMVet_benchmark(model, args): |
| 134 |
no test coverage detected