-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.py
30 lines (28 loc) · 1.07 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit as st
from spacy import displacy # Add this line
from PIL import Image
def show_ui():
st.sidebar.header("Input Options")
option = st.sidebar.radio(
"Choose an option:",
("Manual Input", "Upload PDF", "Upload Image")
)
if option == "Manual Input":
text_input = st.text_area("Enter text manually:")
pdf_file = None
image_file = None
elif option == "Upload PDF":
text_input = None
pdf_file = st.file_uploader("Upload PDF", type=["pdf"])
image_file = None
else: # option == "Upload Image"
text_input = None
pdf_file = None
image_file = st.file_uploader("Upload Image", type=["jpg", "jpeg", "png"])
return text_input, pdf_file, image_file
def display_output(combined_text, entities, colors):
st.header("Output")
st.subheader("Combined Text:")
st.write(combined_text)
html = displacy.render([{"text": combined_text, "ents": entities, "title": None}], style="ent", manual=True, options={"colors": colors})
st.write(html, unsafe_allow_html=True)