classify: Classify images using the trained model

Description Usage Arguments

View source: R/classify.R

Description

classify Uses the Species Level model from Tabak et al. (the built in model) to predict the species in each image. This function uses absolute paths, but if you are unfamilliar with this process, you can put all of your images, the image label csv ("data_info") and the L1 folder that you downloaded following the directions at https://github.com/mikeyEcology/MLWIC into one directory on your computer. Then set your working directory to this location and the function will find the absolute paths for you. If you trained a model using train, this function can also be used to evalute images using the model developed by train by specifying the log_dir of the trained model. If this is your first time using this function, you should see additional documentation at https://github.com/mikeyEcology/MLWIC .

Usage

1
2
3
4
5
6
classify(path_prefix = paste0(getwd(), "/images"),
  data_info = paste0(getwd(), "/image_labels.csv"),
  model_dir = getwd(), save_predictions = "model_predictions.txt",
  python_loc = "/anaconda3/bin/", os = "Mac", num_classes = 28,
  delimiter = ",", architecture = "resnet", depth = "18",
  top_n = "5", log_dir = "USDA182")

Arguments

path_prefix

Absolute path to location of the images on your computer (or computing cluster). All images must be stored in one folder.

data_info

Name of a csv containing the file names of each image (including absolute path). This file must have Unix linebreaks! This file must have only two columns and NO HEADERS. The first column must be the file name of the image The second column can be the number corresponding to the species or group in the image. See Table 1 in Tabak et al. for the numbers (if using the built in model. If you do not know the species in the image, put a zero in each row of column 2.

model_dir

Absolute path to the location where you stored the L1 folder that you downloaded from github.

save_predictions

File name where model predictions will be stored. You should not need to change this parameter. After running this function, you will run make_output to make the output in a more viewer friendly format

python_loc

The location of python on your machine.

os

the operating system you are using. If you are using windows, set this to "Windows", otherwise leave as default

num_classes

The number of classes in your model. If you are using the Species Level model from Tabak et al., the number is '28'.

delimiter

this will be a ',' for a csv.

depth

the number of layers in the DNN. If you are using the built in model, do not adjust this parameter. If you are using a model that you trained, use the same architecture and depth as that model.

top_n

the number of guesses you want the model to make (how many species do you want to see the confidence for?). This number must be less than or equal to 'num_classes'.

log_dir

If you trained a model with train, this will be the log_directory that you specified when using that function. If you are using the built in model, the default is appropriate. @param architecture the architecture of the deep neural network (DNN). Resnet-18 is the default. Options are c("alexnet", "densenet", "googlenet", "nin", "resnet", "vgg"). If you are using the trained model that comes with MLWIC, use resnet 18 (the default). If you trained a model using a different architechture, you need to specify this same architechture and depth that you used for training.


mikeyEcology/MLWIC documentation built on Aug. 23, 2020, 7:30 a.m.