Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from byaldi import RAGMultiModalModel
|
| 3 |
-
|
| 4 |
-
# Initialize the ColPali model
|
| 5 |
model = RAGMultiModalModel.from_pretrained("vidore/colpali")
|
| 6 |
-
|
| 7 |
def extract_and_search(image, keyword):
|
| 8 |
-
|
| 9 |
-
extracted_text = model.predict(image) # Replace with actual prediction method
|
| 10 |
-
|
| 11 |
-
# Perform keyword search
|
| 12 |
matching_lines = [line for line in extracted_text.splitlines() if keyword.lower() in line.lower()]
|
| 13 |
-
|
| 14 |
return extracted_text, matching_lines
|
| 15 |
-
|
| 16 |
-
# Create Gradio interface
|
| 17 |
interface = gr.Interface(
|
| 18 |
fn=extract_and_search,
|
| 19 |
inputs=[
|
|
@@ -27,6 +18,4 @@ interface = gr.Interface(
|
|
| 27 |
title="ColPali OCR with Keyword Search",
|
| 28 |
description="Upload an image and enter a keyword to search within the extracted text."
|
| 29 |
)
|
| 30 |
-
|
| 31 |
-
# Launch the app
|
| 32 |
interface.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from byaldi import RAGMultiModalModel
|
|
|
|
|
|
|
| 3 |
model = RAGMultiModalModel.from_pretrained("vidore/colpali")
|
|
|
|
| 4 |
def extract_and_search(image, keyword):
|
| 5 |
+
extracted_text = model.predict(image)
|
|
|
|
|
|
|
|
|
|
| 6 |
matching_lines = [line for line in extracted_text.splitlines() if keyword.lower() in line.lower()]
|
|
|
|
| 7 |
return extracted_text, matching_lines
|
|
|
|
|
|
|
| 8 |
interface = gr.Interface(
|
| 9 |
fn=extract_and_search,
|
| 10 |
inputs=[
|
|
|
|
| 18 |
title="ColPali OCR with Keyword Search",
|
| 19 |
description="Upload an image and enter a keyword to search within the extracted text."
|
| 20 |
)
|
|
|
|
|
|
|
| 21 |
interface.launch(share=True)
|