A two-part deep learning and data science project combining image-based tree species classification using a custom CNN with location-aware tree species recommendation powered by KNN on the Open Urban Tree Inventory โ a dataset of 5 million street trees across 63 US cities.
tree-species-classifier/
โโโ Final_Week_Project.ipynb โ CNN image classifier (custom architecture)
โโโ 5M_trees.ipynb โ Urban tree EDA + KNN species recommender
โโโ amla/ โ Sample leaf/tree images (33 images)
โโโ 5M_trees/ โ Open Urban Tree Inventory CSVs (63 US cities)
โ โโโ NewYork_Final_2022-06-18.csv
โ โโโ LosAngeles_Final_2022-06-18.csv
โ โโโ ... (63 city files)
โโโ streamlit_integrated.py โ Streamlit app (integration layer)
Manual identification of tree species from images is time-consuming and requires expert botanical knowledge. This notebook automates species identification using a custom CNN trained on leaf images.
Input (150ร150ร3)
โ Conv2D(32) + ReLU + MaxPool
โ Conv2D(64) + ReLU + MaxPool
โ Conv2D(128) + ReLU + MaxPool
โ Flatten
โ Dense(128) + ReLU + Dropout(0.5)
โ Dense(num_classes) + Softmax
| Parameter | Value |
|---|---|
| Input size | 150 ร 150 px |
| Batch size | 32 |
| Epochs | 50 |
| Optimizer | Adam |
| Loss | Categorical Crossentropy |
| Data split | 80% train / 20% validation |
| Augmentation | Rescaling (1/255) |
- Test accuracy: ~90%
- Model saved as
.kerasformat to Google Drive
Open Urban Tree Inventory โ 5,132,890 street trees across 63 of the 150 largest US cities, standardized from city-specific inventories into 28 common columns.
Source: Dryad โ 5 Million Trees Dataset
Key columns used: common_name, scientific_name, city, state, latitude_coordinate, longitude_coordinate, condition, native, diameter_breast_height_CM
1. Data Cleaning & EDA
- Merged 63 city CSVs into a single dataframe
- Dropped columns with >60% missing values
- Filtered species with fewer than 3 samples
- Removed rows with missing critical fields
2. KNN-Based Species Recommender Given a location (lat/lon), tree diameter, native status, and city โ recommends the most ecologically appropriate tree species based on what's already thriving nearby.
recommendation = recommend_species(
lat=38.2274,
lon=-85.8009,
diameter_cm=1.2,
native='naturally_occurring',
city='Louisville',
state='Kentucky',
top_n=5
)
# โ Bur oak (seen 42 times nearby), Silver maple (seen 38 times nearby) ...3. Location Lookup Given a tree species name, returns the top cities/states where it is most commonly found.
| Component | Technology |
|---|---|
| Deep Learning | TensorFlow, Keras |
| Data Processing | Pandas, NumPy |
| ML | Scikit-learn (KNN, StandardScaler) |
| Visualization | Matplotlib |
| Environment | Google Colab |
| App Layer | Streamlit |
| Model Persistence | joblib, .keras |
# Open in Google Colab
# Mount Google Drive and set dataset path:
data_dir = '/content/drive/MyDrive/Tree_Species_Dataset'
# Run all cells โ model saved to Drive automaticallypip install pandas scikit-learn numpy joblib tqdm
# Run 5M_trees.ipynb in Colab or Jupyter
# Dataset CSVs are in the 5M_trees/ folderpip install streamlit
streamlit run streamlit_integrated.py- Add transfer learning (EfficientNetB0 / ResNet50) for higher accuracy
- Integrate Grad-CAM for visual model explainability
- Deploy as a mobile app for real-time field identification
- Extend recommender with climate and soil condition features
- Add Hindi/regional language support for Indian tree species
Chamberlain, S. et al. (2022). A 5 million tree inventory of urban forests across the contiguous USA. Open Urban Tree Inventory. Dryad. https://doi.org/10.5061/dryad.2jm63xsrf
Asmita โ @techAsmita
B.E. Computer Engineering | AI/ML Enthusiast
LinkedIn