Skip to content

[WIP] Create Jupyter notebook for tomato classifier training pipeline#5

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/create-tomato-classifier-notebook
Draft

[WIP] Create Jupyter notebook for tomato classifier training pipeline#5
Copilot wants to merge 1 commit into
mainfrom
copilot/create-tomato-classifier-notebook

Conversation

Copilot AI commented Dec 1, 2025

Copy link
Copy Markdown
Contributor
  • Create tomato_classifier_kaggle.ipynb Jupyter notebook with all required sections:
    • Cell 1: Title, description, and badges (Kaggle/Colab compatible)
    • Cell 2: Install dependencies (if needed)
    • Cell 3: Import libraries
    • Cell 4: Configuration section with easy-to-modify parameters
    • Cell 5: Utility functions
    • Cell 6: Dataset loading functions
    • Cell 7: Model building function
    • Cell 8: Training functions
    • Cell 9: Metrics computation functions
    • Cell 10: Visualization functions
    • Cell 11: Report generation functions
    • Cell 12: Main training pipeline
    • Cell 13: Execute training
    • Cell 14: Display results and download outputs
  • Include Kaggle-specific optimizations (GPU detection, paths, memory growth)
  • Include user-friendly configuration cell
  • Add interactive features (tqdm, matplotlib inline, emojis)
  • Include all features from original tomato_classifier.py
  • Add proper Jupyter notebook metadata
Original prompt

Problem

Create a Jupyter notebook version (.ipynb) of the tomato classifier training pipeline that is fully optimized for Kaggle/Colab environments.

Requirements

Create a new file tomato_classifier_kaggle.ipynb that includes:

1. Notebook Structure with Clear Sections

  • Cell 1: Title, description, and badges (Kaggle/Colab compatible)
  • Cell 2: Install dependencies (if needed)
  • Cell 3: Import libraries
  • Cell 4: Configuration section with easy-to-modify parameters
  • Cell 5: Utility functions
  • Cell 6: Dataset loading functions
  • Cell 7: Model building function
  • Cell 8: Training functions
  • Cell 9: Metrics computation functions
  • Cell 10: Visualization functions
  • Cell 11: Report generation functions
  • Cell 12: Main training pipeline
  • Cell 13: Execute training
  • Cell 14: Display results and download outputs

2. Kaggle-Specific Optimizations

  • Auto-detect Kaggle input paths (/kaggle/input/)
  • Use Kaggle output directory (/kaggle/working/)
  • Enable GPU detection and memory growth
  • Support for Kaggle datasets API

3. User-Friendly Configuration Cell

# ============================================
# 🔧 CONFIGURATION - MODIFY HERE
# ============================================
CONFIG = {
    'dataset_path': '/kaggle/input/tomato-dataset',  # Change this to your dataset path
    'epochs_feature_extraction': 20,
    'epochs_fine_tuning': 50,
    'batch_size': 32,
    'dry_run': False,  # Set True for quick testing (1 epoch)
    'use_mixed_precision': True,
    'output_dir': '/kaggle/working/outputs'
}

4. Interactive Features

  • Progress bars using tqdm
  • Inline plot display with %matplotlib inline
  • Clear output messages and emojis for better UX
  • Markdown cells with explanations for each section

5. All Features from Original Script

Include all functionality from tomato_classifier.py:

  • DenseNet121 with transfer learning
  • Data augmentation
  • AdamW optimizer with weight decay
  • Label smoothing and class weights
  • Comprehensive metrics (ROC-AUC, PR-AUC, Cohen's Kappa, MCC, etc.)
  • All visualizations (confusion matrix, ROC curves, PR curves, radar charts, etc.)
  • CSV and TXT report generation
  • TFLite model conversion
  • Model checkpointing

6. Notebook Metadata

Include proper Jupyter notebook metadata for:

  • Python 3 kernel
  • GPU accelerator hint for Kaggle/Colab

File Location

Create the file at: tomato_classifier_kaggle.ipynb in the repository root

Additional Notes

  • Use markdown cells to explain each section
  • Include sample output comments where helpful
  • Add a "Quick Start" section at the top
  • Include troubleshooting tips for common Kaggle issues

This pull request was created as a result of the following prompt from Copilot chat.

Problem

Create a Jupyter notebook version (.ipynb) of the tomato classifier training pipeline that is fully optimized for Kaggle/Colab environments.

Requirements

Create a new file tomato_classifier_kaggle.ipynb that includes:

1. Notebook Structure with Clear Sections

  • Cell 1: Title, description, and badges (Kaggle/Colab compatible)
  • Cell 2: Install dependencies (if needed)
  • Cell 3: Import libraries
  • Cell 4: Configuration section with easy-to-modify parameters
  • Cell 5: Utility functions
  • Cell 6: Dataset loading functions
  • Cell 7: Model building function
  • Cell 8: Training functions
  • Cell 9: Metrics computation functions
  • Cell 10: Visualization functions
  • Cell 11: Report generation functions
  • Cell 12: Main training pipeline
  • Cell 13: Execute training
  • Cell 14: Display results and download outputs

2. Kaggle-Specific Optimizations

  • Auto-detect Kaggle input paths (/kaggle/input/)
  • Use Kaggle output directory (/kaggle/working/)
  • Enable GPU detection and memory growth
  • Support for Kaggle datasets API

3. User-Friendly Configuration Cell

# ============================================
# 🔧 CONFIGURATION - MODIFY HERE
# ============================================
CONFIG = {
    'dataset_path': '/kaggle/input/tomato-dataset',  # Change this to your dataset path
    'epochs_feature_extraction': 20,
    'epochs_fine_tuning': 50,
    'batch_size': 32,
    'dry_run': False,  # Set True for quick testing (1 epoch)
    'use_mixed_precision': True,
    'output_dir': '/kaggle/working/outputs'
}

4. Interactive Features

  • Progress bars using tqdm
  • Inline plot display with %matplotlib inline
  • Clear output messages and emojis for better UX
  • Markdown cells with explanations for each section

5. All Features from Original Script

Include all functionality from tomato_classifier.py:

  • DenseNet121 with transfer learning
  • Data augmentation
  • AdamW optimizer with weight decay
  • Label smoothing and class weights
  • Comprehensive metrics (ROC-AUC, PR-AUC, Cohen's Kappa, MCC, etc.)
  • All visualizations (confusion matrix, ROC curves, PR curves, radar charts, etc.)
  • CSV and TXT report generation
  • TFLite model conversion
  • Model checkpointing

6. Notebook Metadata

Include proper Jupyter notebook metadata for:

  • Python 3 kernel
  • GPU accelerator hint for Kaggle/Colab

File Location

Create the file at: tomato_classifier_kaggle.ipynb in the repository root

Additional Notes

  • Use markdown cells to explain each section
  • Include sample output comments where helpful
  • Add a "Quick Start" section at the top
  • Include troubleshooting tips for common Kaggle issues

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants