What is Tagging?

Tagging applies custom and automated tags to a video.

The path to use tagging:

core/tagging

Running Tagging

The basic use of tagging to get AI generated tags:

resp = moonshine.run(
    flow="core/tagging",
    index="your-index",
    video_id="[file_id].mp4",
)

Tagging only runs on one video at a time. It will have to be run multiple times to tag multiple videos.

Custom Tags

To use custom tags, add a the tags parameter:

resp = moonshine.run(
    flow="core/tagging",
    index="your-index",
    video_id="[file_id].mp4",
    tags=["basketball", "baseball", "soccer"],

)

Multiple Tags

By default, tagging will assign multiple tags to a video. To set the number of tags use num_tags:

resp = moonshine.run(
    flow="core/tagging",
    index="your-index",
    video_id="[file_id].mp4",
    tags=["basketball", "baseball", "soccer"],
    num_tags = 2
)

Note that num_tags is the maximum number of tags that will be assigned to the video and can be lower.

Tagging Response Format

Tagging returns a json with the following structure:

[output]
List[str]

List of tags assigned to the video

Example:

{
    "output": ["basketball"],
    "status": "complete",
    "video_id": "[file_id].mp4"
}

Tagging Complete Example

A complete example that runs tagging over an entire index:

import moonshine

moonshine.configure("YOUR-TOKEN-HERE")
index = "my-sports-videos"

items = moonshine.items(index=index)
tags_to_use = ["basketball", "baseball", "soccer"]

for item in items:
    file_id = item["file_id"]
    file_name = item["file_name"]
    print(f"Tagging video: {file_name} (ID: {file_id})")
    resp = moonshine.run(
        flow="core/tagging",
        index=index,
        video_id=file_id,
        tags=tags_to_use,
        num_tags=1
    )
    print(f"Tagging results for {file_name}: {resp}")

Tagging JSON

Workflows are in a private beta. Please contact us at team@usemoonshine.com to request access.