Skip to content

Commit

Permalink
Update run_opt_with_text.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ucas-HaoranWei authored Mar 19, 2024
1 parent 9da34b5 commit a8520b2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Vary-master/vary/demo/run_opt_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def eval_model(args):
model = varyOPTForCausalLM.from_pretrained(model_name)



model.to(device='cuda', dtype=torch.bfloat16)

# image_processor_high = test_transform
Expand All @@ -60,20 +59,19 @@ def eval_model(args):
qs = "Provide the OCR results of this image."
# qs = "detect Person in this image.Your answer should be structured precisely according to the category:[xmin,ymin,xmax,ymax] format."

if use_im_start_end:
qs = DEFAULT_IM_START_TOKEN + DEFAULT_IMAGE_PATCH_TOKEN*image_token_len + DEFAULT_IM_END_TOKEN + qs
else:
qs = DEFAULT_IMAGE_TOKEN + '\n' + qs


qs = DEFAULT_IM_START_TOKEN + DEFAULT_IMAGE_PATCH_TOKEN * image_token_len + DEFAULT_IM_END_TOKEN + '\n' + qs

conv_mode = "v1"
conv = conv_templates[conv_mode].copy()
conv.append_message(conv.roles[0], qs)
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()

prompt = DEFAULT_IM_START_TOKEN + DEFAULT_IMAGE_PATCH_TOKEN * image_token_len + DEFAULT_IM_END_TOKEN + '\n' + qs

inputs = tokenizer([prompt])

print(prompt)


image = load_image(args.image_file)
image_1 = image.copy()
Expand Down

0 comments on commit a8520b2

Please sign in to comment.