End-to-end projects
Build an object detector with PetalEdge
Photograph a few small objects, label them, and train a NanoVision model that finds them live with your webcam.
Try it in StudioOn this page
What you will build
A model that finds two or three small objects on your desk (for example a mug, a pen and a pair of scissors) and shows where they are in your webcam picture. You will use the NanoVision model with Studio's default settings.
Time: about 1 to 2 hours, most of it for taking photos and labeling.
What you need
- A PetalEdge account.
- A phone or camera to take photos.
- A computer with a webcam for the live test.
- Two or three small objects that look different from each other.
There is no ready-made dataset for this tutorial: you make your own, which is the best way to learn.
1. Create the project
- In Studio, open the menu under your profile picture and choose Create new project.
- Name it, for example Desk object detector.
- Choose Image and select Create Project.
More: Create a project.
2. Take and upload photos
- Take at least 30 photos of each object. Change the angle, the distance, the background and the light. Put two or three objects in some photos together.
- Take about 10 photos with none of the objects, of the same desk and background.
- Open Data acquisition, keep Upload category on Automatically split between training and testing, select Choose files, pick all your photos, and select Upload.
More: Collecting image data.
3. Label the objects
- Open Data labeling and select Labeling Queue.
- In each photo, draw a box around every object and type its label (
mug,pen,scissors). Press Ctrl/Cmd+S to save and go to the next photo. - For the photos with no objects, use Background... → Mark as background.
- Check the split with Train / Test Split: about 80 % training and 20 % testing.
More: Labeling images.
4. Design the impulse
- Open Create impulse. Keep Width and Height at 96 and Resize mode at Fit shortest axis.
- Add a processing block → Image.
- Add a learning block → Object Detection (Images).
- Select Save Impulse.
- Open Image in the left menu, select Save parameters, then Generate Features.
More: Image block.
5. Train
- Open Object Detection (Images) in the left menu. NanoVision is selected by default.
- Keep the suggested Maximum training cycles and the other defaults.
- Select Start training and wait until it finishes.
More: NanoVision and Training an Image model.
6. Evaluate and test
- Open Evaluation and read F1 Score (non-background). Closer to 1.0 is better.
- Open Model testing and select Classify all to test on your testing photos.
- Open Live classification, select Use webcam, and hold your objects in front of the camera. Each object should get a dot with its label.
If results are poor, add more photos of the object that is missed most and retrain with Retrain model.
More: Evaluating an Image model.
7. Deploy
- Open Deployment and choose Generic tf lite under Select target device.
- Under Precision, keep the option Studio shows.
- Select Build Deployment Package, then Download Latest Build.
More: Deploying an Image model.
What you learned
- How to collect varied photos and why background photos help.
- How to draw consistent bounding boxes.
- How the Image block resizes photos for the model.
- How NanoVision finds objects as points on a grid, and how to read its F1 score.
- How to build a deployment package.