Training an image classifier starts with photos, sorted by class. The slow part usually isn't taking them: it's moving them off your phone, renaming them and dragging them into the right folders. This guide shows how to collect a labeled dataset on your iPhone so the photos land in your own cloud storage already sorted, then load them in PyTorch or Keras.
What a good image dataset looks like
A few habits while collecting matter more than any later cleanup:
- Enough images per class. If you fine-tune a pretrained model, a few hundred photos per class is a common starting point. Start there, measure, and collect more for the classes the model confuses.
- Variety over volume. Change the background, lighting, angle and distance. Twenty nearly identical shots teach the model less than five different ones.
- Balanced classes. Keep the counts per class roughly similar, or the model learns to favor the biggest one.
- Real conditions. Shoot where the model will be used: the actual bins, shelves, plants or parts, in their actual light.
- A separate test set. Collect test images in a different session, ideally on a different day or in a different place. Photos from the same burst in both train and test make your accuracy look better than it is.
The folder layout ML tools expect
Most image classification tooling reads one folder per class, with the folder name as the label:
dataset/
cardboard/
2026-10-31T14-02-04_5fd3b28e.jpg
2026-10-31T14-02-12_e07a91c6.jpg
glass/
2026-10-31T14-02-15_8b2d5f3a.jpg
metal/
…
PyTorch's torchvision.datasets.ImageFolder and Keras's
image_dataset_from_directory both load this layout directly. It's also
exactly what TagSet writes to your bucket, so there's no sorting step.
Collect it with TagSet
-
Connect your storage
TagSet uploads to storage you own: Cloudflare R2, Amazon S3, MinIO, Backblaze B2, Wasabi or anything else that speaks S3. New to this? The Cloudflare R2 guide is free and takes about 10 minutes. Already on AWS? Use the Amazon S3 guide.
Set Key Prefix to
dataset/train/for now. You'll switch it todataset/test/later. -
Add one label per class
Each label becomes a folder in your bucket. Folder names are your labels in lowercase, with spaces turned into underscores, so keep labels short and plain:
cardboard,glass,metal. -
Shoot in speed mode
Pick the active label once and keep shooting. Every photo is filed under that label and uploaded in the background while you line up the next one. Switch the label when you move on to the next class.
Photos are saved as training-sized JPEGs, 2048 px by default, so you don't fill your bucket with multi-megabyte HEIC originals.
-
Let the queue do the uploading
A local queue tracks every capture. Failed uploads stay visible and retry with a tap. Shooting a big session away from Wi-Fi? Turn on Wi-Fi-only uploads and the queue waits until you're connected.
-
Collect the test set
On another day or in another place, change the Key Prefix to
dataset/test/and shoot a smaller set for each class, with the same labels.
Load it and train
Copy the dataset to your computer or GPU machine. With rclone set up as in the R2 guide:
rclone copy r2:YOUR-BUCKET/dataset ./dataset --progress Then load it in PyTorch:
from torchvision import datasets, transforms
tf = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
])
train = datasets.ImageFolder("dataset/train", transform=tf)
test = datasets.ImageFolder("dataset/test", transform=tf)
print(train.classes) # one class per label folder Or in Keras:
import keras
train = keras.utils.image_dataset_from_directory(
"dataset/train", image_size=(224, 224), batch_size=32
)
test = keras.utils.image_dataset_from_directory(
"dataset/test", image_size=(224, 224), batch_size=32
)
print(train.class_names) From here, fine-tuning a pretrained model such as a ResNet or MobileNet on your classes is the usual next step.
Tips
- Skip near-duplicates. Move a little between shots. Bursts of almost identical frames inflate your counts without adding information.
- Check the counts as you go. Your bucket's dashboard shows how many files each label folder holds, so you can see which class needs more.
- Include the hard cases. Partly hidden objects, unusual angles and borderline examples are what the model gets wrong in practice.
FAQ
How many images do I need?
It depends on how different your classes look. For fine-tuning a pretrained model, a few hundred per class is a reasonable start. Train, check which classes get confused, and collect more of those.
Can I add classes later?
Yes. Add a new label in TagSet and its photos go into a new folder next to the others. Remember to collect test images for it too.
Where are my photos stored?
Only in your own bucket. TagSet has no servers: photos upload straight from your iPhone to your storage, and your keys stay in the iOS Keychain. See the privacy policy.
Does it cost anything?
TagSet is free to download. Storage costs depend on your provider. Cloudflare R2's free tier covers 10 GB, roughly 20,000 photos at TagSet's default size, and downloads are free.
Start collecting
Get TagSet for iPhone and set up your first label in a couple of minutes.
Download on the App Store