Deprecated

Vision

Start vision extract job

async VisionAPI.extract(
features: VisionFeature | list[VisionFeature],
file_ids: list[int] | None = None,
file_external_ids: list[str] | None = None,
parameters: FeatureParameters | None = None,
) VisionExtractJob

Start an asynchronous job to extract features from image files.

Parameters:
  • features (VisionFeature | list[VisionFeature]) – The feature(s) to extract from the provided image files.

  • file_ids (list[int] | None) – IDs of the image files to analyze. The images must already be uploaded in the same CDF project.

  • file_external_ids (list[str] | None) – The external file ids of the image files to analyze.

  • parameters (FeatureParameters | None) – No description.

Returns:

Resulting queued job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.

Return type:

VisionExtractJob

Examples

Start a job, wait for completion and then get the parsed results:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.contextualization import VisionFeature
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> extract_job = client.vision.extract(features=VisionFeature.ASSET_TAG_DETECTION, file_ids=[1])
>>> extract_job.wait_for_completion()
>>> for item in extract_job.items:
...     predictions = item.predictions
...     # do something with the predictions
>>> # Save predictions in CDF using Annotations API:
>>> extract_job.save_predictions()

Retrieve vision extract job

async VisionAPI.get_extract_job(
job_id: int,
) VisionExtractJob

Retrieve an existing extract job by ID.

Parameters:

job_id (int) – ID of an existing feature extraction job.

Returns:

Vision extract job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.

Return type:

VisionExtractJob

Examples

Retrieve a vision extract job by ID:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> extract_job = client.vision.get_extract_job(job_id=1)
>>> extract_job.wait_for_completion()
>>> for item in extract_job.items:
...     predictions = item.predictions
...     # do something with the predictions