Spaces:
Runtime error
Runtime error
upd
Browse files
app.py
CHANGED
@@ -45,17 +45,7 @@ def generate_answer_git(image, question):
|
|
45 |
"document-question-answering",
|
46 |
model="andgrt/layoutlmv2-base-uncased_finetuned_docvqa",
|
47 |
)
|
48 |
-
return qa_pipeline(
|
49 |
-
# pixel_values, _, _ = preprocess_image(image)
|
50 |
-
# input_ids = processor(text=question, add_special_tokens=False).input_ids
|
51 |
-
# input_ids = [processor.tokenizer.cls_token_id] + input_ids
|
52 |
-
# input_ids = torch.tensor(input_ids).unsqueeze(0).to(device)
|
53 |
-
|
54 |
-
# generated_ids = model.generate(
|
55 |
-
# pixel_values=pixel_values, input_ids=input_ids, max_length=50
|
56 |
-
# )
|
57 |
-
# generated_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
58 |
-
# return generated_answer[0]
|
59 |
|
60 |
|
61 |
def generate_answer(image, question):
|
|
|
45 |
"document-question-answering",
|
46 |
model="andgrt/layoutlmv2-base-uncased_finetuned_docvqa",
|
47 |
)
|
48 |
+
return qa_pipeline(image, question)[0]["answer"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
|
51 |
def generate_answer(image, question):
|