| 
							 | 
						import streamlit as st
 | 
					
					
						
						| 
							 | 
						import os
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						st.title("Vietnamese Multimodel NER")
 | 
					
					
						
						| 
							 | 
						def save_uploaded_image(image, directory):
 | 
					
					
						
						| 
							 | 
						    if not os.path.exists(directory):
 | 
					
					
						
						| 
							 | 
						        os.makedirs(directory)
 | 
					
					
						
						| 
							 | 
						    file_path = os.path.join(directory, image.name)
 | 
					
					
						
						| 
							 | 
						    with open(file_path, "wb") as f:
 | 
					
					
						
						| 
							 | 
						        f.write(image.getbuffer())
 | 
					
					
						
						| 
							 | 
						    return file_path
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						st.sidebar.title('Selection')
 | 
					
					
						
						| 
							 | 
						page = st.sidebar.selectbox("Choose a page", ["NER", "Multimodal NER"])
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						if page == "NER":
 | 
					
					
						
						| 
							 | 
						    st.header("NER")
 | 
					
					
						
						| 
							 | 
						    text = st.text_area("Enter your text for NER:", height=300)
 | 
					
					
						
						| 
							 | 
						    if st.button("Process NER"):
 | 
					
					
						
						| 
							 | 
						        st.write("Processing text with NER model...")
 | 
					
					
						
						| 
							 | 
						        
 | 
					
					
						
						| 
							 | 
						        st.write(f"Input text: {text}")
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						elif page == "Multimodal NER":
 | 
					
					
						
						| 
							 | 
						    st.header("Multimodal NER")
 | 
					
					
						
						| 
							 | 
						    text = st.text_area("Enter your text for Multimodal NER:", height=300)
 | 
					
					
						
						| 
							 | 
						    image = st.file_uploader("Upload an image:", type=["png", "jpg", "jpeg"])
 | 
					
					
						
						| 
							 | 
						    if st.button("Process Multimodal NER"):
 | 
					
					
						
						| 
							 | 
						        st.write("Processing text and image with Multimodal NER model...")
 | 
					
					
						
						| 
							 | 
						        
 | 
					
					
						
						| 
							 | 
						        st.write(f"Input text: {text}")
 | 
					
					
						
						| 
							 | 
						        if image:
 | 
					
					
						
						| 
							 | 
						            save_path='E:/demo_datn/pythonProject1/Model/MultimodelNER/VLSP2016/Image'
 | 
					
					
						
						| 
							 | 
						            image_name = image.name
 | 
					
					
						
						| 
							 | 
						            print(image_name)
 | 
					
					
						
						| 
							 | 
						            saved_image_path = save_uploaded_image(image, save_path)
 | 
					
					
						
						| 
							 | 
						
 | 
					
					
						
						| 
							 | 
						            st.image(image, caption="Uploaded Image", use_column_width=True)
 | 
					
					
						
						| 
							 | 
						        else:
 | 
					
					
						
						| 
							 | 
						            st.write("No image uploaded.")
 | 
					
					
						
						| 
							 | 
						
 |