gauri-sharan commited on
Commit
86bd82f
·
verified ·
1 Parent(s): 40f7360

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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.Textbox(label="Extracted Text", interactive=False)
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")