Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import dataset into Pytorch (saved locally). #6047

Closed
ANTUMN0S opened this issue Apr 19, 2023 · 2 comments · Fixed by #6396
Closed

Can't import dataset into Pytorch (saved locally). #6047

ANTUMN0S opened this issue Apr 19, 2023 · 2 comments · Fixed by #6396
Assignees

Comments

@ANTUMN0S
Copy link

ANTUMN0S commented Apr 19, 2023

I'm currently trying to import a small dataset I've created from CVAT into PyTorch, so that I can use it in combination with DeepLabV3+. However it always fails, giving me the AttributeError '_OfflineTaskModel' object has no attribute 'updated_date'.

My actions before raising this issue

I've searched for the error message and gone through the documentation. Neither has mentioned anything about it.

Steps to Reproduce (for bugs)

  1. Have any small dataset that is not stored on a cloud service
  2. Install cvat_sdk[pytorch]
  3. Set either app.cvat.ai or localhost:8080 (if you have docker) as CVAT_HOST, and username and password as CVAT_USER and CVAT_PASS
  4. make the client:
    client = make_client(CVAT_HOST, credentials=(CVAT_USER, CVAT_PASS)
  5. train_set = ProjectVisionDataset(client, TASK_ID)
  6. get said Attribute Error

Expected Behaviour

I'd expect the dataset to properly load.

Current Behaviour

It doesn't load, because it doesn't have the Attribute 'updated_date'

Context

My Master Thesis revolves around computer vision and I also need to annotate a lot of data, that needs to be segmented later on. I was advised to use CVAT for annotation and should try to do segmentation with the DeepLabV3+ Architecture. As my data is not yet generated, I've found a small dataset that's similar to what I'll be doing and I wanted to use it as a small proof of concept. But right now, I can't load the dataset, because of that attribute error. I don't know if there is a seperate command for loading datasets that are not stored on a cloud service, but my search so far does not support that claim.

Your Environment

  • To code I use VSC and Python 3.10.6
  • The Docker container runs CVAT 2.4.0, because that's the version the sdk is on
  • The Docker works fine, I can access and use it with chrome.
  • My OS is Ubuntu 22.04 LTS
@josiahls
Copy link

Same issue, same version. I'm copying the modules I need and making the fix myself on my end.

@josiahls
Copy link

Changing that line to saved_task.api_model['updated_date'] fixes it.

If the task is a OpenApiModel (downloaded from online), then doing something like saved_task.updated_date' will work, since OpenApiModel` provides machinery to grab nested attributes.

The problem is when a model is cached, and loaded back, it is loaded as a _OfflineTaskModel

    def _deserialize_model(self, obj: _CacheObject, model_type: _ModelType) -> _ModelType:
        if issubclass(model_type, OpenApiModel):
            return cast(OpenApiModel, model_type)._new_from_openapi_data(**obj)
        elif issubclass(model_type, _CacheObjectModel):
            return cast(_CacheObjectModel, model_type).load(obj)
        else:
            raise NotImplementedError("Unexpected model type")

I think the idea is that we are using the attrs package to grab the nested attributes:

@define
class _OfflineTaskModel(_CacheObjectModel):
    api_model: models.ITaskRead
    labels: List[models.ILabel]

However this doesnt actually work in 23.1.0 or 22.2.0 versions of the package. Looking at https://www.attrs.org/en/stable/examples.html it looks like you need things like attr.s decorator and attr.ib, but even then, searching for "nested" behaviors doesn't seem to be a major feature of this package (?)

@SpecLad SpecLad self-assigned this Jun 27, 2023
nmanovic pushed a commit that referenced this issue Jun 28, 2023
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
This was broken in 4fc494f.

Add a test to cover this case.

Fixes #6047.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants