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

Add Lost in Translation #97

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LeanderK
Copy link

@LeanderK LeanderK commented Jul 22, 2022

Very drafty yet, it's more work than expected to slim down the code and integrate it into the framework. For now only works with pytorch models.

Task Description

Add two datasets showing robustness with regards to translation and rotation, while guaranteeing that both the object is always fully visible and we never leave the image. [Paper]((https://openreview.net/forum?id=L8awC6wq_Fs) published at the Shift-Happens workshop.

Dataset Creation

We only depend on previously released datasets (imagenet-s, which in turn depends on new imagenet-labels).

Evaluation Metrics

Accuracy, base and worst-case

Expected Insights/Relevance

the accuracy decreases significantly for these datasets, even for state of the art models.

Access

Only depends on freely available datasets.

Data

Imagenet-s

License

No data provided, but the data is without a license (after correspondence with the author of imagenet-s).

@github-actions
Copy link

Docstring Coverage Report

Name Total Miss Cover Cover%
init.py 1 0 1 100%
benchmark.py 6 0 6 100%
config.py 4 0 4 100%
model_comparison.py 5 0 5 100%
utils.py 4 0 4 100%
data/init.py 1 0 1 100%
data/base.py 7 0 7 100%
data/imagenet.py 6 0 6 100%
data/torch.py 4 0 4 100%
models/init.py 1 0 1 100%
models/base.py 7 0 7 100%
models/mixins.py 6 0 6 100%
models/torchvision.py 4 0 4 100%
task_data/init.py 1 0 1 100%
task_data/task_metadata.py 2 0 2 100%
task_data/task_registration.py 2 0 2 100%
tasks/init.py 1 0 1 100%
tasks/base.py 8 0 8 100%
tasks/metrics.py 2 0 2 100%
tasks/mixins.py 6 0 6 100%
tasks/task_result.py 2 0 2 100%
tasks/utils.py 3 0 3 100%
tasks/imagenet_c/init.py 1 1 0 0%
tasks/imagenet_c/imagenet_c.py 20 0 20 100%
tasks/imagenet_r/init.py 1 1 0 0%
tasks/imagenet_r/imagenet_r.py 3 0 3 100%
tasks/raccoons_ood/init.py 1 1 0 0%
tasks/raccoons_ood/raccoons_ood.py 3 0 3 100%
TOTAL 112 3 109 97.3%

RESULT: PASSED (minimum: 0.0%, actual: 97.3%)

@LeanderK LeanderK changed the title Add List in Translation Add Lost in Translation Jul 22, 2022
Copy link
Collaborator

@kotekjedi kotekjedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Leander!
I commented on mistakes that did not allow me to run the code.

About the part where only the torchvision models can be used - I am still looking at this code and trying to understand what causes the problem.

If you need any help - feel free to write me!

import math


@sh_benchmark.register_task(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a parent class of tasks here, we don't need to register the task.
Or is this class also a task itself?

default_batch_size: int = 700

resolution: int = parameter(
default=224,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default=224,
default=224,
options=(244,),

We need to add the option's value here.

)

rotation_cutoff: int = parameter(
default=0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default=0,
default=0,
options=(0,),

We need to add the option's value here.

)

translation_cutoff: int = parameter(
default=0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default=0,
default=0,
options=(0,),

We need to add the option's value here.


subdir = 'validation-segmentation'
gt_dir = os.path.join(imagent_s_folder, params['dir'], subdir)
self.dataset = i_s.ImageNetSEvalDataset(imagenet_root_path, gt_dir, name_list, transform=tt,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to pass label_path here after the name_list

)
@dataclasses.dataclass
class LostInTranslationTranslation(LostInTranslationBase):
def _eval_model(model, model_name, batch_size_model, data, eval_device):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _eval_model(model, model_name, batch_size_model, data, eval_device):
def _eval_model(self, model, model_name, batch_size_model, data, eval_device):

)
@dataclasses.dataclass
class LostInTranslationRotation(LostInTranslationBase):
def _eval_model(model, model_name, batch_size_model, data, eval_device):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _eval_model(model, model_name, batch_size_model, data, eval_device):
def _eval_model(self, model, model_name, batch_size_model, data, eval_device):

@kotekjedi kotekjedi added the task label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants