Classifying New Images

Models produced by PhenoCamSnow can be used to generate predictions for all images in a local directory, or to generate a prediction for a single image as pointed to by URL.

Local Prediction

To get predictions for a local directory of canadaojp images, use the following command.

1python -m phenocam_snow.predict \
2    canadaojp \
3    canadaojp_lightning_logs/version_0/checkpoints/epoch=12-step=78.ckpt \
4    resnet18 \
5    --categories snow no_snow too_dark
6    --directory canadaojp_test

The file path provided in the third line is printed by the model training script. It is also saved in a file called best_model_paths.csv. Ensure that the categories provided are the same name and in the same order as provided during training. Similarly, ensure that the ResNet variant specified is the same as in training.

The program will then print out its predictions to a CSV file that looks like this:

 1# Site: canadaojp
 2# Categories:
 3# 0. snow
 4# 1. no_snow
 5# 2. too_dark
 6timestamp,label
 72016-04-01 17:29:59,snow
 82017-11-13 13:59:59,snow
 92019-01-24 16:59:59,snow
102016-04-09 20:29:59,snow
112020-02-26 09:59:59,snow
122016-12-21 11:29:59,snow
132017-03-19 11:59:59,snow
142020-10-29 13:29:59,snow
152018-03-01 19:00:00,snow
162016-04-24 07:29:59,no_snow
172016-05-14 04:00:00,no_snow
182019-09-25 09:30:00,no_snow
192018-07-20 17:00:00,no_snow
202017-05-27 16:29:59,no_snow
212016-08-28 20:29:59,no_snow
222017-06-06 09:30:00,no_snow
232017-09-02 08:29:59,no_snow
242019-09-09 16:00:00,no_snow
252019-01-07 01:29:59,too_dark
262020-01-07 23:30:00,too_dark
272017-09-05 01:59:59,too_dark
282018-07-24 01:30:00,too_dark
292017-11-21 18:59:59,too_dark
302020-01-01 03:29:59,too_dark
312019-02-01 05:29:59,too_dark
322020-10-14 06:30:00,too_dark
332020-05-31 02:59:59,too_dark
342018-12-22 02:29:59,too_dark
352019-05-01 04:30:00,too_dark
362020-07-22 04:00:00,too_dark

Online Prediction

PhenoCamSnow is also capable of generating a prediction for a single online image, as pointed to by a URL. For example, using canadaojp again:

1python -m phenocam_snow.predict \
2    canadaojp \
3    canadaojp_lightning_logs/version_0/checkpoints/epoch=12-step=78.ckpt \
4    resnet18 \
5    --categories snow no_snow too_dark
6    --url https://phenocam.nau.edu/data/latest/canadaojp.jpg

The program will print its prediction to the console. E.g., no_snow.

If you have further questions, please raise an issue on the GitHub repository.