Spaces:
Runtime error
Runtime error
AnonymousSub
commited on
Commit
•
ffec48e
1
Parent(s):
9ce67d0
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ def generate_answer_git(processor, model, image, question):
|
|
41 |
generated_ids = model.generate(pixel_values=pixel_values, input_ids=input_ids, max_length=128)#50)
|
42 |
generated_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
43 |
|
44 |
-
return generated_answer.replace(question, '').replace(question.lower(), '').strip()
|
45 |
|
46 |
|
47 |
def generate_answer_blip(processor, model, image, question):
|
@@ -51,7 +51,7 @@ def generate_answer_blip(processor, model, image, question):
|
|
51 |
generated_ids = model.generate(**inputs, max_length=128)#50)
|
52 |
generated_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
53 |
|
54 |
-
return generated_answer
|
55 |
|
56 |
|
57 |
def generate_answer_vilt(processor, model, image, question):
|
@@ -63,7 +63,7 @@ def generate_answer_vilt(processor, model, image, question):
|
|
63 |
|
64 |
predicted_class_idx = outputs.logits.argmax(-1).item()
|
65 |
|
66 |
-
return model.config.id2label[predicted_class_idx]
|
67 |
|
68 |
|
69 |
def generate_answers(image, question):
|
|
|
41 |
generated_ids = model.generate(pixel_values=pixel_values, input_ids=input_ids, max_length=128)#50)
|
42 |
generated_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
43 |
|
44 |
+
return generated_answer[0].replace(question, '').replace(question.lower(), '').strip()
|
45 |
|
46 |
|
47 |
def generate_answer_blip(processor, model, image, question):
|
|
|
51 |
generated_ids = model.generate(**inputs, max_length=128)#50)
|
52 |
generated_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
53 |
|
54 |
+
return generated_answer[0].strip()
|
55 |
|
56 |
|
57 |
def generate_answer_vilt(processor, model, image, question):
|
|
|
63 |
|
64 |
predicted_class_idx = outputs.logits.argmax(-1).item()
|
65 |
|
66 |
+
return model.config.id2label[predicted_class_idx]#[0].strip()
|
67 |
|
68 |
|
69 |
def generate_answers(image, question):
|