File size: 763 Bytes
e376229
74727d3
e376229
74727d3
e376229
 
74727d3
e376229
 
 
74727d3
e376229
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from transformers import pipeline
import gradio as gr
from PIL import Image

# Загружаем модель
pipe = pipeline(model="impira/layoutlm-document-qa")

def ask_document(image, question):
    result = pipe(image=image, question=question)
    return result

# Интерфейс
gr.Interface(
    fn=ask_document,
    inputs=[
        gr.Image(type="pil", label="📷 Загрузите бланк"),
        gr.Textbox(label="❓ Вопрос", placeholder="Например: Какая фамилия?")
    ],
    outputs=gr.JSON(label="🧠 Ответ"),
    title="🦁 OCRion v2 (Document QA)",
    description="Задайте вопрос о содержимом бланка — нейросеть сама найдёт ответ!"
).launch()