0%
BuildBuild your first image classifierabout 30 min, 4 steps

Your first training run

Train the model on your photos, try it on a few photos it has never seen, read its scores, and save the result.

Check your photos before you train

Open Train in the image lab. The two numbers are your training photos for each class. Only photos with the Training job are counted here. Development, final-test, and target photos are never used for training.

Before you press anything, check three things:

  • Each class has a spread of angles, distances, objects, backgrounds, and lighting, like the table in Setting up your image lab.
  • Both classes appear on the same backgrounds, so the background cannot become a shortcut.
  • No reserved object has slipped into Training.

If you loaded the shape demonstration, the counts are already 12 and 12.

Build with me · 1

Press Train model and watch the run

Training is the step where the program adjusts the model to fit your labelled photos. People also call it fitting the model. It is the guess, check, adjust loop from Level 1: the model guesses a class for a training photo, a loss number measures how wrong the guess was, and the learned numbers inside the model are nudged to make the loss smaller.

The Training rounds menu sets how many times that happens across your whole collection. One round is one pass through every training photo. The usual technical name for a round is an epoch. Leave it at 20 for your first run, so later runs have the same setting to compare against.

Press Train model once. The first time, the lab downloads its image engine and the engine's starting numbers, so it needs an internet connection and may take a little while. Then it reads each training photo and runs the rounds. The status line at the bottom shows the round and the loss. The loss should mostly shrink as the rounds go by. It measures mistakes on the training photos only, so a small loss is not a score on new photos.

Everything runs in your browser; your photos are not uploaded anywhere. Pressing Train model again does not make it faster. To cancel, press Stop and wait a moment for the current step to finish.

Your image lab at this stageWorked example
Text
Train  mug: 50 training images      glass: 48 training images  Training rounds (epochs): 20 rounds  Train modelStatus: Training round 7 of 20 · loss 0.214(Example numbers. Yours will differ.)

In Train, check both counts, keep 20 rounds, and press Train model. Wait until the status says training is complete; the lab then switches to Test & export by itself. If an error appears instead, read it. The usual causes are a class with fewer than two training photos or a download that failed. Download your project before reloading the page, and never fix a failed run by moving reserved photos into Training.

What to look for

A message such as 'Training complete: 98 training images, 20 rounds. Development and final-test images were excluded.' All your photos are still in Photos.

Make it yours

Note how long the first run took and which messages appeared. A second run is usually quicker, because the engine has already been downloaded.

Build with me · 2

Try the model on a few reserved photos

A trained model is ready to answer questions. The fair question is one about photos it has never seen: your reserved development objects.

In Photos, switch These photos are for to Development. Press the correct label button for each reserved object before adding it. You decide the right answer with your rule, before the model has a say. Add two or three photos: a mug, a glass, and one unusual angle. If you loaded the shape demonstration, its development drawings are already there.

In Test & export, choose Development under Predict this collection and press Predict collection. Each development photo goes through the trained model, which gives it a score for each class. The class with the bigger score is the model's answer, its prediction. Because you supplied the right answer for each development photo, the lab can mark each prediction correct or incorrect. Predicting never changes the model: nothing is learned from these photos. Above the results the lab also shows an Accuracy line and a small table. With only two or three photos they mean very little, so leave them until Test it honestly.

Each result starts with an ID. It is the uploaded file's name without its ending (dev01.jpg becomes dev01), or a generated name for a camera photo. If two files share a name, the lab adds a number to the second so every ID stays different.

Your image lab at this stageWorked example
Text
Photos         These photos are for: Development               add 2 or 3 photos, correct label selectedTest & export  Predict this collection: Development               Predict collectionOne result     dev01: mug               Actual: mug · correct               mug 91.2%   glass 8.8%

Add two or three development photos, predict the Development collection, and match one result to its photo. For that result, read the ID, the predicted class, the actual class, and both scores.

What to look for

One result for every development photo, each marked correct or incorrect. The counts in Train have not changed.

Make it yours

Before predicting, write in Notes what makes each development photo different: a new mug, a dim room, a side view. A wrong answer then tells you something instead of just being a surprise.

Build with me · 3

Read the two scores without treating them as a promise

Suppose a result shows mug at 82% and glass at 18%. The two scores always add up to 100%. The model answered mug because mug got the bigger share. That is all the scores say: how the model split its preference between the two answers it knows. People call them confidence scores.

Confidence is not accuracy. 82% does not mean the model is right 82% of the time, and it does not even mean this answer is right: a model can give 95% to a wrong answer. How often a model is right can only be measured by checking many predictions against known answers, which the next module does.

Remember too that this model knows only two answers. Show it an empty table or a shoe and it still has to share 100% between mug and glass, so it may say mug at 90%. A photo outside the task like this is called out of scope. A high score on it shows a limit of the model; it is not evidence that the shoe is a mug.

Your image lab at this stageWorked example
Text
Example result  dev01: mug  Actual: mug · correct  mug   82.0%  glass 18.0%

Pick one correct result, and one wrong result if you have one. In Notes, copy each ID, the prediction, the two scores, and the actual answer. Label them as observations from a few photos, not a measurement.

What to look for

You can explain the difference between 'the model strongly preferred mug' and 'this photo really is a mug under our rule'. The two can disagree.

Make it yours

Optional: in Photos, choose Unlabelled targets and add a photo of an empty table. Predict that collection. The model still picks mug or glass, and no correct or incorrect mark appears, because there is no right answer to compare with.

Keep a first-run record

In Notes, under your run name, write today's date, your two label rules, the number of training photos in each class, how many different objects you used, the conditions you photographed, and the number of rounds. Add the two or three predictions you just read.

That record is run 1. It is not an accuracy score yet. A score needs many reserved photos with known answers, a count of how many the model got right, and the total you divided by. The next module builds exactly that.

Build with me · 4

Save the trained model separately

Your trained model stays in this page while you move between Level 2 readings, but a refresh or a closed tab loses it. Your photos and notes survive, because the browser saves them; the training would have to be run again.

To keep the model itself, press Download model in Test & export. The file holds the learned numbers inside the model and its two class names. It does not hold your photos or notes. Open model loads it back, so you can predict again without retraining. When you open one, check that the class names it reports match your project.

So there are three kinds of file, each with its own job. The project is what you edit and retrain from. The model is what you predict with. A predictions file, which you will make in a later reading, is a record of answers for particular photos. None of them can stand in for another.

Your image lab at this stageWorked example
Text
Download project          photos, jobs, class names, notes (what you edit)Download model            learned numbers + class names (what you predict with)Download predictions.csv  answers for particular photos (a later reading)

Press Download model in Test & export. Press Download project again too, since you have added development photos. Rename both files so they start with the same run name, such as run1, so you can tell later which model came from which photos.

What to look for

You can say which file lets you add photos and retrain, which lets you predict without training again, and which only records past answers.

Make it yours

Refresh the page, press Open model, and choose your downloaded model. Predict the Development collection again and check that the answers match the ones you recorded.

Full reference solution

The whole Level 2 workflow on one page. Each reading covers part of it; this list shows where that part fits. The numbers in the readings are examples, and your own results will differ.

Text
1. Name the two classes and write a one-sentence rule for each.2. Reserve objects or sessions for Development and Final test before collecting.3. In Photos, choose Training and a label, then add varied photos of both classes.4. Add reserved photos under Development and Final test, never under Training.5. In Notes, record label rules, objects, conditions, the split, and a run name.6. In Train, check both counts, keep 20 rounds for the first run, and press Train model.7. Download project and Download model, with matching run names.8. In Test & export, predict Development and read every ID, actual label, prediction, and score.9. Work out accuracy yourself, read the confusion matrix, and compare with the Always- baseline.10. Write one hypothesis. Change only the Training photos (or one stated setting), retrain, and predict the same Development collection.11. Choose a version using Development results. Open its saved model if needed.12. Predict Final test once, after choosing, and report its fraction, conditions, and limits.13. For photos with no known answer, use Unlabelled targets, predict, and Download predictions.csv.14. Keep project, model, notes, and predictions file together under one run name. None of them replaces another.

Compare this with your version. Different names and personal choices are fine when the program follows the same logic.

Keep your progress

Sign in and every reading, quiz, and exercise you finish is saved.

Sign in