Skip to content

Latest commit

ย 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒณ Tree Species Classifier

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.


๐Ÿ“‚ Repository Structure

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)

๐Ÿ““ Notebook 1 โ€” CNN Image Classifier (Final_Week_Project.ipynb)

Problem Statement

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.

Model Architecture

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

Training Details

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)

Results

  • Test accuracy: ~90%
  • Model saved as .keras format to Google Drive

๐Ÿ““ Notebook 2 โ€” Urban Tree EDA + KNN Recommender (5M_trees.ipynb)

Dataset

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

What it does

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.


๐Ÿ› ๏ธ Tech Stack

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

๐Ÿš€ Setup & Run

CNN Classifier

# 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 automatically

Urban Tree Recommender

pip install pandas scikit-learn numpy joblib tqdm

# Run 5M_trees.ipynb in Colab or Jupyter
# Dataset CSVs are in the 5M_trees/ folder

Streamlit App

pip install streamlit
streamlit run streamlit_integrated.py

๐Ÿ”ฎ Future Scope

  • 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

๐Ÿ“Š Dataset Credit

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


๐Ÿ”— Resources


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Asmita โ€” @techAsmita
B.E. Computer Engineering | AI/ML Enthusiast
LinkedIn

About

๐ŸŒณ Tree species image classification using transfer learning on EfficientNetB0 โ€” trained on urban tree inventory data from 63 US cities. ~90% accuracy. TensorFlow ยท Keras ยท Google Colab.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages