View source: R/ifcb_classify_images.R
| ifcb_classify_images | R Documentation |
Classifies one or more pre-extracted IFCB PNG images through a CNN model
served by a Gradio application. Each PNG is uploaded to the Gradio server
and the prediction result is returned as a data frame. Per-class F2 optimal
thresholds are applied automatically; predictions scoring below the
threshold for their class are labeled "unclassified" in class_name.
ifcb_classify_images(
png_file,
gradio_url = "https://irfcb-classify.hf.space",
top_n = 1,
model_name = "SMHI NIVA ResNet50 V5",
verbose = TRUE
)
png_file |
A character vector of paths to PNG files to classify. |
gradio_url |
A character string specifying the base URL of the Gradio
application. Default is |
top_n |
An integer specifying the number of top predictions to return
per image. Default is |
model_name |
A character string specifying the name of the CNN model
to use for classification. Default is |
verbose |
A logical value indicating whether to print progress messages.
Default is |
To classify all images in a raw IFCB sample (.roi file) without first
extracting them manually, use ifcb_classify_sample() instead.
A data frame with the following columns:
file_nameThe PNG file name of the classified image.
class_nameThe predicted class name with per-class thresholds
applied; "unclassified" if the score is below the threshold.
class_name_autoThe winning class name without any threshold applied (argmax of scores).
scoreThe prediction confidence score (0–1).
model_nameThe name of the CNN model used for classification.
Images that could not be classified have NA in class_name,
class_name_auto, and score.
When top_n > 1, multiple rows are returned per image (one per prediction).
ifcb_classify_sample() to classify all images in a raw IFCB
sample without prior extraction. ifcb_classify_models() to list
available CNN models. ifcb_extract_pngs() to extract PNG images from
IFCB ROI files.
## Not run:
# Classify a single pre-extracted PNG
result <- ifcb_classify_images("path/to/D20220522T003051_IFCB134_00001.png")
# Classify several PNGs at once
pngs <- list.files("path/to/png_folder", pattern = "\\.png$",
full.names = TRUE)
result <- ifcb_classify_images(pngs, top_n = 3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.