import streamlit as st
import base64
import predictor
def add_bg_from_local(image_file):
with open(image_file, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
st.markdown(
f"""
""",
unsafe_allow_html=True
)
def header_white_bg(text, fontsize = 40, bold = True):
st.markdown(
f"""
{text}
""",
unsafe_allow_html=True
)
def diagnose_health(file):
prediction = predict(file)
return prediction
def app():
add_bg_from_local('assets/background.png')
header_white_bg(f'PlantDx: Diagnosis in a Snap! ')
# Upload image of plant
header_white_bg("Upload an image of your plant:", fontsize=32)
uploaded_file = st.file_uploader("", type=["jpg", "jpeg", "png"])
if uploaded_file:
header_white_bg("Preview of the selected image:", fontsize=28, bold=False)
st.image(uploaded_file)
# Get diagnosis button
if st.button("Get Diagnosis"):
if uploaded_file is not None:
# Diagnose plant health and display results
result = diagnose_health(uploaded_file)
st.success(f"Your plant is {result}")
else:
st.warning("Please upload an image of your plant first")
# Create user profile button
if st.button("Create User Profile"):
st.subheader("User Profile")
# Prompt user to add their name and the plant they own
user_name = st.text_input("Enter your name:")
plant_name = st.text_input("Enter the plant you own:")
if user_name and plant_name:
st.success(f"User profile created for {user_name} with plant {plant_name}")
# Run Streamlit app
if __name__ == "__main__":
app()