|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
nlp_model = pipeline('text-classification', model='distilbert-base-uncased') |
|
|
|
|
|
|
|
|
data = { |
|
|
'Tree': ['Neem', 'Peepal', 'Mango', 'Bamboo', 'Chili', 'Guava', 'Coconut', 'Papaya', |
|
|
'Pine', 'Oak', 'Acacia', 'Eucalyptus', 'Teak', 'Date Palm', 'Banana', 'Apple'], |
|
|
'Climate': ['Tropical', 'Tropical', 'Tropical', 'Tropical', 'Tropical', 'Tropical', |
|
|
'Tropical', 'Tropical', 'Temperate', 'Temperate', 'Arid', 'Temperate', |
|
|
'Tropical', 'Arid', 'Tropical', 'Temperate'], |
|
|
'Soil': ['Loamy', 'Sandy', 'Loamy', 'Loamy', 'Sandy', 'Loamy', 'Sandy', 'Loamy', |
|
|
'Loamy', 'Clay', 'Sandy', 'Sandy', 'Loamy', 'Sandy', 'Loamy', 'Loamy'], |
|
|
'Use': ['Shade', 'Shade', 'Fruit', 'Construction', 'Spice', 'Fruit', 'Fruit', 'Fruit', |
|
|
'Timber', 'Timber', 'Shade', 'Timber', 'Timber', 'Fruit', 'Fruit', 'Fruit'], |
|
|
'Height': ['Medium', 'Medium', 'Tall', 'Tall', 'Short', 'Medium', 'Tall', 'Medium', |
|
|
'Tall', 'Tall', 'Medium', 'Tall', 'Tall', 'Tall', 'Medium', 'Medium'], |
|
|
'Leaf Color': ['Green', 'Green', 'Green', 'Green', 'Green', 'Green', 'Green', 'Green', |
|
|
'Green', 'Green', 'Green', 'Green', 'Green', 'Green', 'Green', 'Green'], |
|
|
'Growth Rate': ['Fast', 'Fast', 'Fast', 'Fast', 'Medium', 'Fast', 'Fast', 'Fast', |
|
|
'Slow', 'Slow', 'Medium', 'Fast', 'Medium', 'Slow', 'Fast', 'Medium'] |
|
|
} |
|
|
|
|
|
|
|
|
df = pd.DataFrame(data) |
|
|
|
|
|
|
|
|
st.title('Environmentally Friendly Tree Recommender') |
|
|
|
|
|
|
|
|
climate = st.selectbox('Select your climate:', df['Climate'].unique()) |
|
|
soil_type = st.selectbox('Select your soil type:', df['Soil'].unique()) |
|
|
goal = st.selectbox('Select your goal:', df['Use'].unique()) |
|
|
height = st.selectbox('Select desired height:', df['Height'].unique()) |
|
|
leaf_color = st.selectbox('Select desired leaf color:', df['Leaf Color'].unique()) |
|
|
growth_rate = st.selectbox('Select desired growth rate:', df['Growth Rate'].unique()) |
|
|
|
|
|
|
|
|
def recommend_trees(climate, soil_type, goal, height, leaf_color, growth_rate): |
|
|
recommendations = df[ |
|
|
(df['Climate'] == climate) & |
|
|
(df['Soil'] == soil_type) & |
|
|
(df['Use'] == goal) & |
|
|
(df['Height'] == height) & |
|
|
(df['Leaf Color'] == leaf_color) & |
|
|
(df['Growth Rate'] == growth_rate) |
|
|
] |
|
|
return recommendations |
|
|
|
|
|
|
|
|
recommended_trees = recommend_trees(climate, soil_type, goal, height, leaf_color, growth_rate) |
|
|
|
|
|
|
|
|
st.subheader('Recommended Trees:') |
|
|
if not recommended_trees.empty: |
|
|
for index, row in recommended_trees.iterrows(): |
|
|
st.write(f"**Tree**: {row['Tree']}") |
|
|
st.write(f" - **Use**: {row['Use']}") |
|
|
st.write(f" - **Height**: {row['Height']}") |
|
|
st.write(f" - **Leaf Color**: {row['Leaf Color']}") |
|
|
st.write(f" - **Growth Rate**: {row['Growth Rate']}") |
|
|
else: |
|
|
st.write("No suitable trees found for your criteria.") |
|
|
|
|
|
|
|
|
user_input = st.text_area("Describe your requirements (optional):", "") |
|
|
if user_input: |
|
|
classification = nlp_model(user_input) |
|
|
st.write("NLP Model Classification:", classification) |
|
|
|
|
|
|
|
|
st.sidebar.header('Tree Information') |
|
|
st.sidebar.write('Use the sidebar to get more information about different trees and their characteristics.') |
|
|
|
|
|
|
|
|
tree_images = { |
|
|
'Neem': 'https://upload.wikimedia.org/wikipedia/commons/0/0a/Neem_tree_2.jpg', |
|
|
'Peepal': 'https://upload.wikimedia.org/wikipedia/commons/2/23/Ficus_religiosa.JPG', |
|
|
'Mango': 'https://upload.wikimedia.org/wikipedia/commons/6/6e/Mango_Tree.jpg', |
|
|
'Bamboo': 'https://upload.wikimedia.org/wikipedia/commons/e/e2/Bamboo_forest_in_Mingxi%2C_Fujian%2C_China.jpg', |
|
|
'Chili': 'https://upload.wikimedia.org/wikipedia/commons/f/fd/Chili_pepper_1.jpg', |
|
|
'Guava': 'https://upload.wikimedia.org/wikipedia/commons/7/7e/Guava_Fruit.jpg', |
|
|
'Coconut': 'https://upload.wikimedia.org/wikipedia/commons/7/7b/Coconut_%28fruit%29.jpg', |
|
|
'Papaya': 'https://upload.wikimedia.org/wikipedia/commons/4/4e/Papaya_fruit.jpg', |
|
|
'Pine': 'https://images.pexels.com/photos/1420402/pexels-photo-1420402.jpeg', |
|
|
'Oak': 'https://images.pexels.com/photos/1001682/pexels-photo-1001682.jpeg', |
|
|
'Acacia': 'https://images.pexels.com/photos/69570/acacia-tree-sunset-tree-africa-69570.jpeg', |
|
|
'Eucalyptus': 'https://images.pexels.com/photos/4587979/pexels-photo-4587979.jpeg', |
|
|
'Teak': 'https://images.pexels.com/photos/1003865/pexels-photo-1003865.jpeg', |
|
|
'Date Palm': 'https://images.pexels.com/photos/235525/pexels-photo-235525.jpeg', |
|
|
'Banana': 'https://images.pexels.com/photos/131365/pexels-photo-131365.jpeg', |
|
|
'Apple': 'https://images.pexels.com/photos/712021/pexels-photo-712021.jpeg' |
|
|
} |
|
|
|
|
|
|
|
|
st.sidebar.subheader('Tree Images') |
|
|
selected_tree = st.sidebar.selectbox('Select a tree to view image:', df['Tree'].unique()) |
|
|
if selected_tree in tree_images: |
|
|
image_url = tree_images[selected_tree] |
|
|
st.sidebar.image(image_url, caption=selected_tree, use_column_width=True) |
|
|
|
|
|
st.sidebar.markdown(f"*Additional Info*: The {selected_tree} tree is beneficial for {df[df['Tree'] == selected_tree]['Use'].values[0]} purposes and thrives in {df[df['Tree'] == selected_tree]['Climate'].values[0]} climates.") |
|
|
else: |
|
|
|
|
|
st.sidebar.write("No image available for the selected tree.") |
|
|
|