Videotrainingsdaten für die Klassifizierung vorbereiten
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie Videotrainingsdaten zur Verwendung in einem Vertex AI-Dataset vorbereiten, um ein Videoklassifizierungsmodell zu trainieren.
Die folgenden Abschnitte enthalten Informationen zu Datenanforderungen, Schemadateien und dem Format der Datenimportdateien ( JSONL& CSV), die vom Schema definiert werden.
Alternativ können Sie Videos, die noch nicht annotiert wurden, importieren und später mit der Google Cloud Console annotieren (siehe Labels mit der Google Cloud Console erstellen).
Datenanforderungen
Die folgenden Anforderungen gelten für Datasets, die zum Trainieren von AutoML- oder benutzerdefinierten Modellen verwendet werden.
Vertex AI unterstützt die folgenden Videoformate, um Ihr Modell zu trainieren oder eine Vorhersage anzufordern (annotieren eines Videos).
.MOV
.MPEG4
.MP4
.AVI
Wenn Sie sich die Videoinhalte in der Webkonsole ansehen oder ein Video annotieren möchten, muss das Video in einem Format vorliegen, das von Ihrem Browser nativ unterstützt wird.
Da MOV- oder AVI-Inhalte nicht von allen Browsern nativ verarbeitet werden, empfiehlt sich die Verwendung des Videoformats MPEG4 oder MP4.
Die maximale Dateigröße beträgt 50 GB (maximale Dauer von 3 Stunden). Einzelne Videodateien mit fehlerhaften oder leeren Zeitstempeln im Container werden nicht unterstützt.
Die maximale Anzahl von Labels in jedem Dataset ist derzeit auf 1.000 begrenzt.
Sie können den Videos in den Importdateien Labels vom Typ "ML_USE" zuweisen. Zur Trainingszeit können Sie diese Labels verwenden, um die Videos und die zugehörigen Annotationen in Trainings- oder Test-Datasets aufzuteilen. Beachten Sie zur Klassifizierung von Videos Folgendes:
Für das Modelltraining sind mindestens zwei verschiedene Klassen erforderlich. Zum Beispiel "Nachrichten" und "MTV" oder "Spiel" und "Andere".
Schließen Sie gegebenenfalls die Klasse „None_of_the_above“ und Videosegmente ein, die keiner Ihrer definierten Klassen entsprechen.
Best Practices für Videodaten zum Trainieren von AutoML-Modellen
Die folgenden Vorgehensweisen gelten für Datasets, die zum Trainieren von AutoML-Modellen verwendet werden.
Die Trainingsdaten sollten den Daten, für die Vorhersagen getroffen werden sollen, möglichst ähnlich sein. Wenn Ihr Anwendungsfall beispielsweise verschwommene Videos mit niedriger Auflösung (zum Beispiel von einer Überwachungskamera) beinhaltet, sollten Ihre Trainingsdaten aus verschwommenen Videos mit niedriger Auflösung bestehen. Sie sollten außerdem mehrere Blickwinkel, Auflösungen und Hintergründe für Ihre Trainingsvideos bereitstellen.
Vertex-KI-Modelle können in der Regel keine Labels vorhersagen, die von Menschen nicht zugewiesen werden können. Wenn bei einem bestimmten Video ein Mensch nicht fähig wäre, nach einer oder zwei Sekunden Betrachtung ein Label zuzuweisen, kann Ihr Modell höchstwahrscheinlich auch nicht dafür trainiert werden.
Das Modell funktioniert am besten, wenn für das am häufigsten verwendete Label höchstens 100-mal mehr Videos vorhanden sind als für das am wenigsten verwendete Label. Es wird empfohlen, Labels mit geringer Häufigkeit zu entfernen. Für die Videoklassifizierung beträgt die empfohlene Anzahl an Trainingsvideos pro Label etwa 1.000. Die Mindestanzahl pro Label ist 10, für fortgeschrittene Modelle liegt sie bei 50. Im Allgemeinen sind mehr Beispiele pro Label nötig, um Modelle mit mehreren Labels pro Video zu trainieren. Die Konfidenzwerte sind dann schwieriger zu interpretieren.
Schemadateien
Verwenden Sie beim Erstellen der JSONL-Datei zum Importieren von Annotationen die folgende öffentlich zugängliche Schemadatei. Diese Schemadatei bestimmt das Format der Dateneingabedateien. Die Struktur der Datei folgt dem OpenAPI-Schematest.
title: VideoClassification
description: >
Import and export format for importing/exporting videos together with
classification annotations with time segment. Can be used in
Dataset.import_schema_uri field.
type: object
required:
- videoGcsUri
properties:
videoGcsUri:
type: string
description: >
A Cloud Storage URI pointing to a video. Up to 50 GB in size and
up to 3 hours in duration. Supported file mime types: `video/mp4`,
`video/avi`, `video/quicktime`.
timeSegmentAnnotations:
type: array
description: >
Multiple classification annotations. Each on a time segment of the video.
items:
type: object
description: Annotation with a time segment on media (e.g., video).
properties:
displayName:
type: string
description: >
It will be imported as/exported from AnnotationSpec's display name.
startTime:
type: string
description: >
The start of the time segment. Expressed as a number of seconds as
measured from the start of the video, with "s" appended at the end.
Fractions are allowed, up to a microsecond precision.
default: 0s
endTime:
type: string
description: >
The end of the time segment. Expressed as a number of seconds as
measured from the start of the video, with "s" appended at the end.
Fractions are allowed, up to a microsecond precision, and "Infinity"
is allowed, which corresponds to the end of the video.
default: Infinity
annotationResourceLabels:
description: Resource labels on the Annotation.
type: object
additionalProperties:
type: string
dataItemResourceLabels:
description: Resource labels on the DataItem.
type: object
additionalProperties:
type: string
Eingabedateien
Das Format Ihrer Trainingsdaten für die Videoklassifizierung sieht so aus:
Erstellen Sie zum Importieren Ihrer Daten entweder eine JSONL- oder eine CSV-Datei.
ML_USE (Optional). Zum Aufteilen von Daten beim Trainieren eines Modells. Verwenden Sie TRAINING oder TEST.
VIDEO_URI. Dieses Feld enthält den Cloud Storage-URI für das Video. Bei Cloud Storage-URIs wird zwischen Groß- und Kleinschreibung unterschieden.
LABEL. Labels müssen mit einem Buchstaben beginnen und dürfen nur Buchstaben, Zahlen und Unterstriche enthalten. Sie können mehrere Labels für ein Video festlegen. Dazu müssen Sie in der CSV-Datei mehrere Zeilen hinzufügen, die jeweils dasselbe Videosegment mit einem anderen Label kennzeichnen.
START,END. Diese beiden Spalten START und ENDE geben jeweils die Start- und Endzeit des zu analysierenden Videosegments an. Die Startzeit muss kleiner sein als die Endzeit. Beide Werte dürfen nicht negativ sein und müssen innerhalb des Zeitbereichs des Videos liegen. Beispiel: 0.09845,1.36005. Legen Sie eine Startzeit von 0 und eine Endzeit entsprechend der Länge des Videos oder "inf" fest, um den gesamten Inhalt des Videos verwenden zu können. Beispiel: 0,inf
Beispiel-CSV – Klassifizierung mit einem einzigen Label
Sie können Videos auch in der Datendatei bereitstellen, ohne Labels anzugeben. Anschließend müssen Sie mithilfe der Google Cloud Console Labels auf Ihre Daten anwenden, bevor Sie Ihr Modell trainieren. Dazu müssen Sie nur den Cloud Storage-URI für das Video gefolgt von drei Kommas angeben, wie im folgenden Beispiel gezeigt.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-07 (UTC)."],[],[],null,["# Prepare video training data for classification\n\nThis page describes how to prepare video training data for use in a Vertex AI dataset to train a video classification model.\n\n\u003cbr /\u003e\n\nThe following sections provide information about data requirements,\nschema files, and the format of the data import files (JSONL \\& CSV) that are\ndefined by the schema.\n\nAlternatively, you can import videos that have not been annotated and\nannotate them later using the Google Cloud console\n(see [Labeling using the Google Cloud console](/vertex-ai/docs/datasets/label-using-console)).\n\nData requirements\n-----------------\n\nThe following requirements apply to datasets used to train AutoML\nor custom-trained models.\n\n- Vertex AI supports the following video formats for training\n your model or requesting a prediction (annotating a video).\n\n - .MOV\n - .MPEG4\n - .MP4\n - .AVI\n- To view the video content in the web console or to annotate a video, the video\n must be in a format that your browser natively supports.\n Since not all browsers handle .MOV or .AVI content natively, the\n recommendation is to use either .MPEG4 or .MP4 video format.\n\n- Maximum file size is 50 GB (up to 3 hours in duration). Individual video\n files with malformed or empty timestamps in the container aren't supported.\n\n- The maximum number of labels in each dataset is limited to 1,000.\n\n- You may assign \"ML_USE\" labels to the videos in the import files. At\n training time, you may choose to use those labels to split the videos and\n their corresponding annotations into \"training\" or \"test\" sets. For video\n classification, note the following:\n\n - At least two different classes are required for model training. For example, \"news\" and \"MTV\", or \"game\" and \"others\".\n - Consider including a \"None_of_the_above\" class and video segments that do not match any of your defined classes.\n\nBest practices for video data used to train AutoML models\n---------------------------------------------------------\n\nThe following practices apply to datasets used to train AutoML\nmodels.\n\n- The training data should be as close as possible to the data on which\n predictions are to be made. For example, if your use case involves blurry and\n low-resolution videos (such as from a security camera), your training data\n should be composed of blurry, low-resolution videos. In general, you should\n also consider providing multiple angles, resolutions, and backgrounds for\n your training videos.\n\n- Vertex AI models can't generally predict labels that humans\n can't assign. If a human can't be trained to assign labels by looking at the\n video for 1-2 seconds, the model likely can't be trained to do it either.\n\n- The model works best when there are at most 100 times more videos for the\n most common label than for the least common label. We recommend removing low\n frequency labels. For video classification, the recommended number of training\n videos per label is about 1,000. The minimum per label is 10, or 50 for advanced\n models. In general, it takes more examples per label to train models with\n multiple labels per video, and resulting scores are harder to interpret.\n\nSchema files\n------------\n\n- Use the following publicly accessible schema file when creating the\n jsonl file for importing annotations. This schema file dictates the format of\n the data input files. The structure of the file follows the\n [OpenAPI Schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schema)\n test.\n\n **Video classification schema file**:\n\n [gs://google-cloud-aiplatform/schema/dataset/ioformat/video_classification_io_format_1.0.0.yaml](https://storage.cloud.google.com/google-cloud-aiplatform/schema/dataset/ioformat/video_classification_io_format_1.0.0.yaml)\n\n \u003cbr /\u003e\n\n #### **Full schema file**\n\n ```\n\n\n title: VideoClassification\n description: \u003e\n Import and export format for importing/exporting videos together with\n classification annotations with time segment. Can be used in\n Dataset.import_schema_uri field.\n type: object\n required:\n - videoGcsUri\n properties:\n videoGcsUri:\n type: string\n description: \u003e\n A Cloud Storage URI pointing to a video. Up to 50 GB in size and\n up to 3 hours in duration. Supported file mime types: `video/mp4`,\n `video/avi`, `video/quicktime`.\n timeSegmentAnnotations:\n type: array\n description: \u003e\n Multiple classification annotations. Each on a time segment of the video.\n items:\n type: object\n description: Annotation with a time segment on media (e.g., video).\n properties:\n displayName:\n type: string\n description: \u003e\n It will be imported as/exported from AnnotationSpec's display name.\n startTime:\n type: string\n description: \u003e\n The start of the time segment. Expressed as a number of seconds as\n measured from the start of the video, with \"s\" appended at the end.\n Fractions are allowed, up to a microsecond precision.\n default: 0s\n endTime:\n type: string\n description: \u003e\n The end of the time segment. Expressed as a number of seconds as\n measured from the start of the video, with \"s\" appended at the end.\n Fractions are allowed, up to a microsecond precision, and \"Infinity\"\n is allowed, which corresponds to the end of the video.\n default: Infinity\n annotationResourceLabels:\n description: Resource labels on the Annotation.\n type: object\n additionalProperties:\n type: string\n dataItemResourceLabels:\n description: Resource labels on the DataItem.\n type: object\n additionalProperties:\n type: string\n ```\n\n \u003cbr /\u003e\n\nInput files\n-----------\n\nThe format of your training data for video classification are as follows.\n| **Note:** When manually managing which videos are used for training or test purposes, be sure each instance of a video in the dataset has been assigned the *same* designation. If there's a contradiction, the dataset reverts to random assignments.\n\nTo import your data, create either a JSONL or CSV file.\n\n\u003cbr /\u003e\n\n### JSONL\n\nJSON on each line: \n\nSee [Classification schema (global)](/vertex-ai/docs/training-overview#video_data) file for details.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n```\n\n\n{\n\t\"videoGcsUri\": \"gs://bucket/filename.ext\",\n\t\"timeSegmentAnnotations\": [{\n\t\t\"displayName\": \"LABEL\",\n\t\t\"startTime\": \"start_time_of_segment\",\n\t\t\"endTime\": \"end_time_of_segment\"\n\t}],\n\t\"dataItemResourceLabels\": {\n\t\t\"aiplatform.googleapis.com/ml_use\": \"train|test\"\n\t}\n}\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n#### Example JSONL - Video classification:\n\n```\n\n\n{\"videoGcsUri\": \"gs://demo/video1.mp4\", \"timeSegmentAnnotations\": [{\"displayName\": \"cartwheel\", \"startTime\": \"1.0s\", \"endTime\": \"12.0s\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"training\"}}\n{\"videoGcsUri\": \"gs://demo/video2.mp4\", \"timeSegmentAnnotations\": [{\"displayName\": \"swing\", \"startTime\": \"4.0s\", \"endTime\": \"9.0s\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"test\"}}\n...\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### CSV\n\n\nFormat of a row in the CSV:\n\n\u003cbr /\u003e\n\n```\n[ML_USE,]VIDEO_URI,LABEL,START,END\n```\n\n**List of columns**\n\n1. `ML_USE` (Optional). For data split purposes when training a model. Use TRAINING or TEST.\n2. `VIDEO_URI`. This field contains the Cloud Storage URI for the video. Cloud Storage URIs are case-sensitive.\n3. `LABEL`. Labels must start with a letter and only contain letters, numbers, and underscores. You can specify multiple labels for a video by adding multiple rows in the CSV file that each identify the same video segment, with a different label for each row.\n4. `START,END`. These two columns, START and END, respectively, identify the start and end time of the video segment to analyze, in seconds. The start time must be less than the end time. Both values must be non-negative and within the time range of the video. For example, `0.09845,1.36005`. To use the entire content of the video, specify a start time of `0` and an end time of the full-length of the video or \"inf\". For example, `0,inf`.\n\n#### Example CSV - Classification using single label\n\nSingle-label on the same video segment: \n\n```\nTRAINING,gs://YOUR_VIDEO_PATH/vehicle.mp4,mustang,0,5.4\n...\n```\n\n#### Example CSV - multiple labels:\n\nMulti-label on the same video segment: \n\n```\ngs://YOUR_VIDEO_PATH/vehicle.mp4,fiesta,0,8.285\ngs://YOUR_VIDEO_PATH/vehicle.mp4,ranger,0,8.285\ngs://YOUR_VIDEO_PATH/vehicle.mp4,explorer,0,8.285\n...\n```\n\n#### Example CSV - no labels:\n\n\nYou can also provide videos in the data file *without* specifying\nany labels. You must then use the Google Cloud console to apply labels to\nyour data before you train your model. To do so, you only need to\nprovide the Cloud Storage URI for the video followed by three commas,\nas shown in the following example. \n\n```\ngs://YOUR_VIDEO_PATH/vehicle.mp4,,,\n...\n```"]]