Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ layoutlm_model = LayoutLMForTokenClassification.from_pretrained("microsoft/layou
|
|
| 7 |
layoutlm_tokenizer = LayoutLMTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
|
| 8 |
|
| 9 |
# Function to extract text from image
|
| 10 |
-
def extract_text_from_image(image)
|
| 11 |
inputs = layoutlm_tokenizer(image, return_tensors="pt")
|
| 12 |
with torch.no_grad():
|
| 13 |
outputs = layoutlm_model(**inputs)
|
|
@@ -17,7 +17,7 @@ def extract_text_from_image(image)
|
|
| 17 |
return text
|
| 18 |
|
| 19 |
# Function to generate response
|
| 20 |
-
def generate_response(prompt, text)
|
| 21 |
# You can use your existing code here for response generation
|
| 22 |
# For this example, let's simply return the extracted text with the prompt
|
| 23 |
return f"{prompt} {text}"
|
|
|
|
| 7 |
layoutlm_tokenizer = LayoutLMTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
|
| 8 |
|
| 9 |
# Function to extract text from image
|
| 10 |
+
def extract_text_from_image(image):
|
| 11 |
inputs = layoutlm_tokenizer(image, return_tensors="pt")
|
| 12 |
with torch.no_grad():
|
| 13 |
outputs = layoutlm_model(**inputs)
|
|
|
|
| 17 |
return text
|
| 18 |
|
| 19 |
# Function to generate response
|
| 20 |
+
def generate_response(prompt, text):
|
| 21 |
# You can use your existing code here for response generation
|
| 22 |
# For this example, let's simply return the extracted text with the prompt
|
| 23 |
return f"{prompt} {text}"
|