Py Editor MAC USER MANUALpythoneditor.io ↗ · Version 27.0.3 (33)

Train and evaluate the AI Vision Lab example

AI Vision Lab is a bundled project that generates its own images, trains a small image classifier on them and writes a visual report. Everything runs on your Mac, with no dataset to download and no AI account.

The project uses PyTorch, NumPy and Matplotlib, so it needs Py Editor Helper and a project environment. Set those up first with Set up Helper, a project environment, packages and services.

1. Open the example and prepare it

  1. Choose File → Recent Projects → 08_AI_Vision_Lab.
  2. Select main.py in Project.
  3. If the status bar says Project .venv not created, click it and wait for the environment to be created.
  4. Leave the run configuration at Current Selected File.
  5. Click the run button in the toolbar.
  6. If Run reports missing project dependencies, click Install Dependencies and wait for the confirmation that the project is ready.

Installing the packages downloads a few hundred megabytes the first time.

2. Train the model

  1. Select main.py again and click the run button.
  2. Watch the ten training epochs in Run.
  3. Read the final test accuracy and the confusion matrix at the end of the output.

The model's source beside its completed training resultsOpen the screenshot to view it at full size.

Training takes a minute or two. To stop early, click the stop button in the toolbar; the report file then belongs to an earlier run, not this one.

The accuracy you see describes this small generated dataset. It is not a benchmark for real photographs.

3. Open the visual report

  1. Right-click the 08_AI_Vision_Lab folder in Project and choose Reload from Disk so the new file appears.
  2. Right-click ai_vision_report.png and choose Open In → Finder.
  3. With the file selected in Finder, press Command-O to open it in Preview.

The generated report: training loss, validation accuracy, a confusion matrix and sample predictionsOpen the screenshot to view it at full size.

4. Read the four panels

  • Training loss — how the training error changed across the epochs.
  • Validation accuracy — the share of validation patterns classified correctly.
  • Confusion matrix — expected classes are rows, predicted classes are columns; the diagonal holds the correct predictions.
  • Sample predictions — a few images with their expected and predicted labels.

Next steps

Keep the example unchanged for your first run. Then open data.py to see how the patterns are generated and model.py for the classifier and its training loop.