hf_classify_image: Classify Images

View source: R/multimodal.R

hf_classify_imageR Documentation

Classify Images

Description

Classify images using an image-classification model via the Hugging Face Inference Providers API.

Usage

hf_classify_image(
  image,
  top_k = 5L,
  model = hf_default_model("classify_image"),
  token = NULL,
  endpoint_url = NULL,
  content_type = NULL,
  ...
)

Arguments

image

Image input: a local file path, URL, raw vector, or vector/list of paths/URLs.

top_k

Integer. Maximum labels to return per image.

model

Character string. Model ID from Hugging Face Hub. Default: "google/vit-base-patch16-224".

token

Character string or NULL. API token for authentication.

endpoint_url

Character string or NULL. A custom Inference Endpoint URL.

content_type

Character string or NULL. MIME type to use for raw image inputs. Paths and URLs are inferred when possible.

...

Additional arguments (currently unused).

Value

A tibble with columns: image, label, score.

See Also

https://huggingface.co/docs/inference-providers/tasks/image-classification

Examples

## Not run: 
hf_classify_image("cat.png", top_k = 3)

## End(Not run)

huggingfaceR documentation built on Aug. 30, 2026, 1:06 a.m.