Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import pytesseract
|
|
| 10 |
from PIL import Image
|
| 11 |
import gradio as gr
|
| 12 |
import os
|
|
|
|
| 13 |
|
| 14 |
# Function to extract text from a PDF file using OCR
|
| 15 |
def extract_text_from_pdf(pdf_path):
|
|
@@ -21,6 +22,10 @@ def extract_text_from_pdf(pdf_path):
|
|
| 21 |
text += pytesseract.image_to_string(image)
|
| 22 |
return text
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# Process and retrieve answers
|
| 25 |
def process_invoice(pdf, hf_token, questions):
|
| 26 |
# Extract text from the PDF
|
|
|
|
| 10 |
from PIL import Image
|
| 11 |
import gradio as gr
|
| 12 |
import os
|
| 13 |
+
from pydantic import BaseModel
|
| 14 |
|
| 15 |
# Function to extract text from a PDF file using OCR
|
| 16 |
def extract_text_from_pdf(pdf_path):
|
|
|
|
| 22 |
text += pytesseract.image_to_string(image)
|
| 23 |
return text
|
| 24 |
|
| 25 |
+
class Config(BaseModel):
|
| 26 |
+
class Config:
|
| 27 |
+
arbitrary_types_allowed = True
|
| 28 |
+
|
| 29 |
# Process and retrieve answers
|
| 30 |
def process_invoice(pdf, hf_token, questions):
|
| 31 |
# Extract text from the PDF
|