Skip to content

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 Studio
On 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

  1. In Studio, open the menu under your profile picture and choose Create new project.
  2. Name it, for example Desk object detector.
  3. Choose Image and select Create Project.

More: Create a project.

2. Take and upload photos

  1. 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.
  2. Take about 10 photos with none of the objects, of the same desk and background.
  3. 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

  1. Open Data labeling and select Labeling Queue.
  2. 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.
  3. For the photos with no objects, use Background... → Mark as background.
  4. Check the split with Train / Test Split: about 80 % training and 20 % testing.

More: Labeling images.

4. Design the impulse

  1. Open Create impulse. Keep Width and Height at 96 and Resize mode at Fit shortest axis.
  2. Add a processing block → Image.
  3. Add a learning block → Object Detection (Images).
  4. Select Save Impulse.
  5. Open Image in the left menu, select Save parameters, then Generate Features.

More: Image block.

5. Train

  1. Open Object Detection (Images) in the left menu. NanoVision is selected by default.
  2. Keep the suggested Maximum training cycles and the other defaults.
  3. Select Start training and wait until it finishes.

More: NanoVision and Training an Image model.

6. Evaluate and test

  1. Open Evaluation and read F1 Score (non-background). Closer to 1.0 is better.
  2. Open Model testing and select Classify all to test on your testing photos.
  3. 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

  1. Open Deployment and choose Generic tf lite under Select target device.
  2. Under Precision, keep the option Studio shows.
  3. 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.