Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -97,15 +97,15 @@ def search_keywords(keywords):
|
|
97 |
for keyword in keywords.split():
|
98 |
highlighted_text = re.sub(f"({re.escape(keyword)})", r"<mark>\1</mark>", highlighted_text, flags=re.IGNORECASE)
|
99 |
|
100 |
-
# Return the highlighted text
|
101 |
-
return highlighted_text
|
102 |
|
103 |
# Gradio interface for image input and keyword search
|
104 |
with gr.Blocks() as iface:
|
105 |
# Image upload and text extraction section
|
106 |
with gr.Column():
|
107 |
img_input = gr.Image(type="pil", label="Upload an Image")
|
108 |
-
extracted_output = gr.
|
109 |
|
110 |
# Functionality to trigger the OCR and extraction
|
111 |
img_button = gr.Button("Extract Text")
|
|
|
97 |
for keyword in keywords.split():
|
98 |
highlighted_text = re.sub(f"({re.escape(keyword)})", r"<mark>\1</mark>", highlighted_text, flags=re.IGNORECASE)
|
99 |
|
100 |
+
# Return the highlighted text as HTML
|
101 |
+
return f"<div style='white-space: pre-wrap'>{highlighted_text}</div>"
|
102 |
|
103 |
# Gradio interface for image input and keyword search
|
104 |
with gr.Blocks() as iface:
|
105 |
# Image upload and text extraction section
|
106 |
with gr.Column():
|
107 |
img_input = gr.Image(type="pil", label="Upload an Image")
|
108 |
+
extracted_output = gr.HTML(label="Extracted Text", interactive=False) # Change to HTML to handle formatting
|
109 |
|
110 |
# Functionality to trigger the OCR and extraction
|
111 |
img_button = gr.Button("Extract Text")
|