Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
# Initialize the ColPali model
|
5 |
model = RAGMultiModalModel.from_pretrained("vidore/colpali-v1.2")
|
6 |
|
7 |
def extract_and_search(image, keyword):
|
8 |
# Use the model to extract text from the image
|
9 |
-
|
|
|
10 |
|
11 |
# Perform keyword search
|
12 |
matching_lines = [line for line in extracted_text.splitlines() if keyword.lower() in line.lower()]
|
@@ -29,4 +30,4 @@ interface = gr.Interface(
|
|
29 |
)
|
30 |
|
31 |
# Launch the app
|
32 |
-
interface.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import RAGMultiModalModel # Importing the ColPali model
|
3 |
|
4 |
# Initialize the ColPali model
|
5 |
model = RAGMultiModalModel.from_pretrained("vidore/colpali-v1.2")
|
6 |
|
7 |
def extract_and_search(image, keyword):
|
8 |
# Use the model to extract text from the image
|
9 |
+
inputs = {"images": [image]}
|
10 |
+
extracted_text = model.generate(**inputs) # Replace with actual prediction method
|
11 |
|
12 |
# Perform keyword search
|
13 |
matching_lines = [line for line in extracted_text.splitlines() if keyword.lower() in line.lower()]
|
|
|
30 |
)
|
31 |
|
32 |
# Launch the app
|
33 |
+
interface.launch(share=True)
|