Memuat
Memuat
Watch every step above performed live, with English narration.
2 plays
Class book
Page 1 / 6
Cover: Class Transfer Learning Plant Disease #1: Dataset PlantVillage: Folder Structure, Class Distribution & Data Split
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Transfer Learning Plant Disease #1: PlantVillage Dataset: Folder Structure, Class Distribution & Data Split”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
This is the final result, 2000 tomato leaf images from 10 classes, starting from healthy leaves, bacterial spots, blight, fungi, up to viruses, complete with data splitting and visualizations. This is the first step of our series in building a leaf disease detection system using transfer learning and hyperparameter optimization. Let's get started. Hello, welcome to the AI research tutorial series, detecting and classifying leaf diseases in plants using transfer learning and hyperparameter optimization. Leaf diseases can drastically reduce tomato harvests, and farmers often detect them too late. In this 6-episode series, we build a model that recognizes 10 tomato leaf conditions from photos, understand the dataset, data pipeline, transfer learning with MobileNet V2 and ResNet 50, fine-tuning, automatic optimization with Optuna, up to a web application. In this first episode, we get to know the data. We open the terminal through the terminal menu, new terminal, and then install the libraries for this series, Torche, Torchvision, Optuna, scikit-learn, matplotlib, and streamlit.
The dataset is PlantVillage, a very popular collection of leaf images in agricultural AI research. We use the tomato leaf portion, 10 classes, each with 200 images. The dataset folder is already available in the customer's premium project file. Notice the folder structure in the explorer, dataset, tomato leaves, then one subfolder per class, and each subfolder contains the images.
This structure is standard for image classification. Create a file named data_underscore_leaf_dot_py. The list_classes function reads the subfolder names, the list_files function generates a pair of each image with its label, 0 to 9.
Still in the same file, the split_data function divides the data into 70% train, 15% validation, and 15% test, with train test split twice. The stratify parameter ensures each class has the same proportion in all three parts, and random state 0 makes the split consistent every time it is run.
Now create a file named exploration_underscore_leaf_dot_py and run it. There are 10 classes with a total of 2000 images, exactly 200 per class, so the data is balanced. Each image is 160 by 160 pixels in RGB mode. The split is 1,400 train, 300 validation, and 300 test, and thanks to stratify, each class gets exactly 140, 30, and 30 images.
Let's look at one example from each class. Bacterial spots and target spots show dark spots, blight has a large brown area, virus curling yellow makes the leaves yellow and curled, while healthy leaves are uniformly green. Some classes are very similar to each other, which is why the task is challenging.
Finally, is color alone enough to distinguish the diseases? We calculate the average red and green color values for each image, then plot them as colored points according to their class. The results have points from different classes overlapping in the same region. That means the average color is not enough, the model must understand texture and spot patterns. Here is where CNN and transfer learning come into play. Done
We have already learned about the PlantVillage dataset for tomato leaf diseases, folder structure per class, creating a list of files and labels, stratified data splitting, and viewing visual differences for each disease. In the next episode, we will build leaf image augmentation and an efficient data pipeline. Currently working on a thesis, dissertation, or AI research in the field of agricultural AI? Cerdas Inovasi Digital helps with the implementation of deep learning, from transfer learning with MobileNet and ResNet, fine-tuning, hyperparameter optimization with Optuna, up to web application development and writing results, as well as offering deep learning courses with Python. Want to master the entire series, from the PlantVillage dataset to the web app for leaf disease detection? All 6 episodes, complete with step-by-step PDF guides and source code, are available to premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want just one class? Buy a single class with lifetime access. Subscribe now on the premium page cerdasinovasidigital.com Contact our WhatsApp or visit cerdasinovasidigital.com Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →