cvatfiftyone

Load (import) an existing non-sample CVAT Project to fiftyone as Dataset


I am trying

import fiftyone as fo
dataset = fo.load_dataset("import_test")

the project which exists and have such project name, I've created in CVAT before.

Such call was used in https://githubhelp.com/voxel51/fiftyone/issues/1611

but I am getting

ValueError: Dataset 'import_test' not found

In the documentation: https://voxel51.com/docs/fiftyone/integrations/cvat.html examples and other questions:

  1. https://colab.research.google.com/github/voxel51/fiftyone-examples/blob/master/examples/pytorch_detection_training.ipynb#scrollTo=5crNDNsRWdPT
  2. Uploading large dataset from FiftyOne to CVAT
  3. https://medium.com/voxel51/loading-open-images-v6-and-custom-datasets-with-fiftyone-18b5334851c3

there are only usage of sample fiftyone dataet:

dataset = foz.load_zoo_dataset("...")

which works correctly for me as CVAT server connection check, but don't suit my work needs. In https://towardsdatascience.com/tools-to-annotate-and-improve-computer-vision-datasets-f9b99cdb0e04 using local machine stored dataset

dataset = fo.Dataset.from_dir("...")

Can I load already created project initially created in CVAT from server, what argument is supposed to be used except it's CVAT's name of project? Is it possible or it has to be initially fiftyone dataset?


Solution

  • Yes, you can use the fiftyone.utils.cvat.import_annotations() method to import labels that are already in a CVAT project or task into a FiftyOne Dataset.

    Note that in order to use fo.load_dataset(), the dataset needs to already exist in FiftyOne. You can initialize an empty dataset like so as shown in the import annotations example:

    dataset = fo.Dataset("my-dataset-name")
    

    Then, you can call import_annotations(), providing a project name and optionally a data_path and export_media=True to download all of the media from your project to a local directory as well as all of the labels in your project, then import them into the dataset you just created.

    dataset = fo.Dataset("my-dataset-name")
    fouc.import_annotations(
        dataset,
        project_name=project_name,
        data_path="/tmp/cvat_import",
        download_media=True,
    )
    

    If your media already exists in disk, then see the linked example for how to provide a data_map mapping the CVAT filename to filepath of the media on the local disk.