Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ def search_and_highlight(text, keyword):
|
|
19 |
highlighted_text = re.sub(f"({keyword})", r"<mark>\1</mark>", text, flags=re.IGNORECASE)
|
20 |
return highlighted_text
|
21 |
|
22 |
-
def ocr_and_search(image, keyword):
|
23 |
if image is None:
|
24 |
return "Please upload an image."
|
25 |
|
@@ -35,12 +35,12 @@ iface = gr.Interface(
|
|
35 |
fn=ocr_and_search,
|
36 |
inputs=[
|
37 |
gr.Image(type="pil", label="Upload Image"),
|
38 |
-
gr.Textbox(label="Enter keyword to search (optional)")
|
|
|
39 |
],
|
40 |
outputs=gr.HTML(label="Extracted and Highlighted Text"),
|
41 |
title="OCR and Keyword Search",
|
42 |
description="Upload an image to extract text using OCR and optionally search for keywords in the extracted text."
|
43 |
)
|
44 |
|
45 |
-
|
46 |
-
iface.launch()
|
|
|
19 |
highlighted_text = re.sub(f"({keyword})", r"<mark>\1</mark>", text, flags=re.IGNORECASE)
|
20 |
return highlighted_text
|
21 |
|
22 |
+
def ocr_and_search(image, keyword, languages):
|
23 |
if image is None:
|
24 |
return "Please upload an image."
|
25 |
|
|
|
35 |
fn=ocr_and_search,
|
36 |
inputs=[
|
37 |
gr.Image(type="pil", label="Upload Image"),
|
38 |
+
gr.Textbox(label="Enter keyword to search (optional)"),
|
39 |
+
gr.CheckboxGroup(choices=language_choices, label="Select languages", default=["eng"])
|
40 |
],
|
41 |
outputs=gr.HTML(label="Extracted and Highlighted Text"),
|
42 |
title="OCR and Keyword Search",
|
43 |
description="Upload an image to extract text using OCR and optionally search for keywords in the extracted text."
|
44 |
)
|
45 |
|
46 |
+
iface.launch()
|
|