Update app.py
Browse files
app.py
CHANGED
@@ -45,10 +45,15 @@ def describe_image(image, user_question="Solve this AP Problem step by step and
|
|
45 |
|
46 |
# Load and prepare the model
|
47 |
vl_gpt = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True).to(torch.float16).eval()
|
|
|
48 |
|
49 |
# Generate embeddings from the image input
|
50 |
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs).to(dtype=torch.float16)
|
51 |
|
|
|
|
|
|
|
|
|
52 |
# Generate the model's response
|
53 |
outputs = vl_gpt.language_model.generate(
|
54 |
inputs_embeds=inputs_embeds,
|
@@ -60,6 +65,7 @@ def describe_image(image, user_question="Solve this AP Problem step by step and
|
|
60 |
do_sample=False,
|
61 |
use_cache=True
|
62 |
)
|
|
|
63 |
|
64 |
# Decode the generated tokens into text
|
65 |
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
|
|
|
45 |
|
46 |
# Load and prepare the model
|
47 |
vl_gpt = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True).to(torch.float16).eval()
|
48 |
+
vl_gpt = vl_gpt.to(torch.float16)
|
49 |
|
50 |
# Generate embeddings from the image input
|
51 |
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs).to(dtype=torch.float16)
|
52 |
|
53 |
+
print(f"Inputs Embeds dtype: {inputs_embeds.dtype}")
|
54 |
+
print(f"Attention Mask dtype: {attention_mask.dtype}")
|
55 |
+
print(f"Model dtype: {next(vl_gpt.parameters()).dtype}")
|
56 |
+
|
57 |
# Generate the model's response
|
58 |
outputs = vl_gpt.language_model.generate(
|
59 |
inputs_embeds=inputs_embeds,
|
|
|
65 |
do_sample=False,
|
66 |
use_cache=True
|
67 |
)
|
68 |
+
outputs = outputs.to(torch.float16)
|
69 |
|
70 |
# Decode the generated tokens into text
|
71 |
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
|