Spaces:
Sleeping
Sleeping
MinxuanQin
commited on
Commit
•
a0bc852
1
Parent(s):
24da9e2
adapt dimension of blip inputs
Browse files
app.py
CHANGED
@@ -45,12 +45,11 @@ if uploaded_file is not None:
|
|
45 |
pixel_values = blip_processor(images=img, return_tensors="pt").pixel_values
|
46 |
blip_ques = blip_processor.tokenizer.cls_token + question
|
47 |
batch_input_ids = blip_processor(text=blip_ques, add_special_tokens=False).input_ids
|
48 |
-
batch_input_ids = torch.tensor(batch_input_ids)
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
# blip_output = blip_processor.batch_decode(generate_ids, skip_special_tokens=True)
|
53 |
|
54 |
st.text(f"Answer of ViLT: {orig_pred}")
|
55 |
st.text(f"Answer after fine-tuning: {pred}")
|
56 |
-
|
|
|
45 |
pixel_values = blip_processor(images=img, return_tensors="pt").pixel_values
|
46 |
blip_ques = blip_processor.tokenizer.cls_token + question
|
47 |
batch_input_ids = blip_processor(text=blip_ques, add_special_tokens=False).input_ids
|
48 |
+
batch_input_ids = torch.tensor(batch_input_ids).unsqueeze(0)
|
49 |
+
|
50 |
+
generate_ids = blip_model.generate(pixel_values=pixel_values, input_ids=batch_input_ids, max_length=50)
|
51 |
+
blip_output = blip_processor.batch_decode(generate_ids, skip_special_tokens=True)
|
|
|
52 |
|
53 |
st.text(f"Answer of ViLT: {orig_pred}")
|
54 |
st.text(f"Answer after fine-tuning: {pred}")
|
55 |
+
st.text(f"Answer of BLIP: {blip_output[0]}")
|