File size: 5,730 Bytes
717b440
 
 
 
 
 
 
ad8063a
717b440
ad8063a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717b440
 
 
 
 
 
 
 
 
72e2c0c
 
 
 
 
 
717b440
 
72e2c0c
717b440
 
 
72e2c0c
 
 
 
717b440
 
 
 
72e2c0c
717b440
 
 
 
 
72e2c0c
 
 
 
 
717b440
 
 
 
 
 
 
 
72e2c0c
13ec6b4
72e2c0c
 
 
07506ed
72e2c0c
 
 
 
 
 
 
 
ad8063a
07506ed
 
 
 
 
 
 
 
72e2c0c
 
13ec6b4
72e2c0c
 
 
07506ed
 
13ec6b4
 
07506ed
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import streamlit as st
import pandas as pd
from transformers import pipeline

# Load the NLP model from Hugging Face
nlp_model = pipeline('text-classification', model='distilbert-base-uncased')

# Enhanced tree dataset with more trees, climates, and soil types
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']
}

# Convert to DataFrame
df = pd.DataFrame(data)

# Streamlit UI
st.title('Environmentally Friendly Tree Recommender')

# User inputs
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())

# Recommendation logic
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

# Get recommendations
recommended_trees = recommend_trees(climate, soil_type, goal, height, leaf_color, growth_rate)

# Display recommendations
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.")

# Optional: Use NLP model to process natural language inputs
user_input = st.text_area("Describe your requirements (optional):", "")
if user_input:
    classification = nlp_model(user_input)
    st.write("NLP Model Classification:", classification)

# Sidebar enhancements
st.sidebar.header('Tree Information')
st.sidebar.write('Use the sidebar to get more information about different trees and their characteristics.')

# Tree images from free sources
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'
}

# Dynamic sidebar content
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)
    # Add a tooltip or additional info for each tree
    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:
    # Handle the case where there is no image URL
    st.sidebar.write("No image available for the selected tree.")