Importazione di dati per il riconoscimento delle azioni video
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Importa i dati per il riconoscimento delle azioni video utilizzando il metodo import_data.
Per saperne di più
Per la documentazione dettagliata che include questo esempio di codice, vedi quanto segue:
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],[],[],[],null,["# Import data for video action recognition\n\nImports data for video action recognition using the import_data method.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Create a dataset for training video action recognition models](/vertex-ai/docs/video-data/action-recognition/create-dataset)\n\nCode sample\n-----------\n\n### Java\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Java API\nreference documentation](/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.api.gax.longrunning.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetName.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceClient.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceSettings.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.GcsSource.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataConfig.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataOperationMetadata.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataResponse.html;\n import java.io.IOException;\n import java.util.ArrayList;\n import java.util.List;\n import java.util.concurrent.ExecutionException;\n\n public class ImportDataVideoActionRecognitionSample {\n\n public static void main(String[] args)\n throws IOException, ExecutionException, InterruptedException {\n // TODO(developer): Replace these variables before running the sample.\n String project = \"PROJECT\";\n String datasetId = \"DATASET_ID\";\n String gcsSourceUri = \"GCS_SOURCE_URI\";\n importDataVideoActionRecognitionSample(project, datasetId, gcsSourceUri);\n }\n\n static void importDataVideoActionRecognitionSample(\n String project, String datasetId, String gcsSourceUri)\n throws IOException, ExecutionException, InterruptedException {\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceSettings.html settings =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceSettings.html.newBuilder()\n .setEndpoint(\"us-central1-aiplatform.googleapis.com:443\")\n .build();\n String location = \"us-central1\";\n\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceClient.html.create(settings)) {\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.GcsSource.html gcsSource = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.GcsSource.html.newBuilder().https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.GcsSource.Builder.html#com_google_cloud_aiplatform_v1_GcsSource_Builder_addUris_java_lang_String_(gcsSourceUri).build();\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataConfig.html importConfig0 =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataConfig.html.newBuilder()\n .setGcsSource(gcsSource)\n .https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataConfig.Builder.html#com_google_cloud_aiplatform_v1_ImportDataConfig_Builder_setImportSchemaUri_java_lang_String_(\n \"gs://google-cloud-aiplatform/schema/dataset/ioformat/\"\n + \"video_action_recognition_io_format_1.0.0.yaml\")\n .build();\n List\u003cImportDataConfig\u003e importConfigs = new ArrayList\u003c\u003e();\n importConfigs.add(importConfig0);\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetName.html name = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetName.html.of(project, location, datasetId);\n OperationFuture\u003cImportDataResponse, ImportDataOperationMetadata\u003e response =\n client.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DatasetServiceClient.html#com_google_cloud_aiplatform_v1_DatasetServiceClient_importDataAsync_com_google_cloud_aiplatform_v1_DatasetName_java_util_List_com_google_cloud_aiplatform_v1_ImportDataConfig__(name, importConfigs);\n\n // You can use OperationFuture.getInitialFuture to get a future representing the initial\n // response to the request, which contains information while the operation is in progress.\n System.out.format(\"Operation name: %s\\n\", response.getInitialFuture().https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFutureImpl.html#com_google_api_gax_longrunning_OperationFutureImpl_get__().getName());\n\n // OperationFuture.get() will block until the operation is finished.\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ImportDataResponse.html importDataResponse = response.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFutureImpl.html#com_google_api_gax_longrunning_OperationFutureImpl_get__();\n System.out.format(\"importDataResponse: %s\\n\", importDataResponse);\n }\n }\n }\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Python API\nreference documentation](/python/docs/reference/aiplatform/latest).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import aiplatform\n\n\n def import_data_video_action_recognition_sample(\n project: str,\n dataset_id: str,\n gcs_source_uri: str,\n location: str = \"us-central1\",\n api_endpoint: str = \"us-central1-aiplatform.googleapis.com\",\n timeout: int = 1800,\n ):\n # The AI Platform services require regional API endpoints.\n client_options = {\"api_endpoint\": api_endpoint}\n # Initialize client that will be used to create and send requests.\n # This client only needs to be created once, and can be reused for multiple requests.\n client = aiplatform.gapic.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.dataset_service.DatasetServiceClient.html(client_options=client_options)\n import_configs = [\n {\n \"gcs_source\": {\"uris\": [gcs_source_uri]},\n \"import_schema_uri\": \"gs://google-cloud-aiplatform/schema/dataset/ioformat/video_action_recognition_io_format_1.0.0.yaml\",\n }\n ]\n name = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.dataset_service.DatasetServiceClient.html#google_cloud_aiplatform_v1_services_dataset_service_DatasetServiceClient_dataset_path(project=project, location=location, dataset=dataset_id)\n response = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.dataset_service.DatasetServiceClient.html#google_cloud_aiplatform_v1_services_dataset_service_DatasetServiceClient_import_data(name=name, import_configs=import_configs)\n print(\"Long running operation:\", response.operation.name)\n import_data_response = response.result(timeout=timeout)\n print(\"import_data_response:\", import_data_response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=aiplatform)."]]