View source: R/ifcb_classify_sample.R
| ifcb_classify_sample | R Documentation |
Extracts PNG images from an IFCB sample (.roi file) using
ifcb_extract_pngs() into a temporary directory, then classifies each
image through a CNN model served by a Gradio application. Per-class F2
optimal thresholds are applied automatically. The temporary directory is
automatically removed when the function exits.
ifcb_classify_sample(
roi_file,
gradio_url = "https://irfcb-classify.hf.space",
top_n = 1,
model_name = "SMHI NIVA ResNet50 V5",
verbose = TRUE,
...
)
roi_file |
A character string specifying the path to the |
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 |
... |
Additional arguments passed to |
To classify individual pre-extracted PNG files, use ifcb_classify_images()
directly.
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_images() to classify pre-extracted PNG files
directly. ifcb_classify_models() to list available CNN models.
ifcb_extract_pngs() to extract PNG images from IFCB ROI files.
## Not run:
# Classify all ROIs in a sample (top prediction per image)
result <- ifcb_classify_sample("path/to/D20220522T003051_IFCB134.roi")
head(result)
# Return top 3 predictions per image
result <- ifcb_classify_sample(
"path/to/D20220522T003051_IFCB134.roi",
top_n = 3
)
# Classify only specific ROI numbers
result <- ifcb_classify_sample(
"path/to/D20220522T003051_IFCB134.roi",
ROInumbers = c(1, 5, 10)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.