RobustBench / robustbench

RobustBench: a standardized adversarial robustness benchmark [NeurIPS 2021 Benchmarks and Datasets Track]
https://robustbench.github.io
Other
669 stars 99 forks source link

Error in loading CIFAR-10C #146

Closed mayank010698 closed 1 year ago

mayank010698 commented 1 year ago

When I run the example code, corruptions = ['fog'] x_test, y_test = load_cifar10c(n_examples=1000, corruptions=corruptions, severity=5)

I get the error, File "/projects/dali/mayanks4/TPGM-CIFAR10/DomainNet_ResNet_Exp/robustbench/data.py", line 323, in load_corruptions_cifar data_root_dir = data_dir / CORRUPTIONS_DIR_NAMES[dataset] TypeError: unsupported operand type(s) for /: 'PosixPath' and 'dict'

Katono5 commented 1 year ago

Facing the same problem...Any methods so far?

mayank010698 commented 1 year ago

I copied the following line in the load_cifar10c function: https://github.com/RobustBench/robustbench/blob/ec26a6cd0b0812135270c3659caabcab80701b15/robustbench/data.py#L254

Katono5 commented 1 year ago

I copied the following line in the load_cifar10c function:

https://github.com/RobustBench/robustbench/blob/ec26a6cd0b0812135270c3659caabcab80701b15/robustbench/data.py#L254

Sorry I don't get it, I know that the original version is:

def load_cifar10c(
        n_examples: int,
        severity: int = 5,
        data_dir: str = './data',
        shuffle: bool = False,
        corruptions: Sequence[str] = CORRUPTIONS,
        _: Callable = PREPROCESSINGS[None]
) -> Tuple[torch.Tensor, torch.Tensor]:
    return load_corruptions_cifar(BenchmarkDataset.cifar_10, n_examples,
                                  severity, data_dir, corruptions, shuffle)

And it would return an Error, could you please tell me how exactly your method works? I would really appreciate it Where should I copy it since there's no definition of

mayank010698 commented 1 year ago

Replace this line https://github.com/RobustBench/robustbench/blob/ec26a6cd0b0812135270c3659caabcab80701b15/robustbench/data.py#L309

and instead for data_root_dir use Path(data_dir) / CORRUPTIONS_DIR_NAMES[ BenchmarkDataset.cifar10[ThreatModel.corruptions] / corruptions[0] / str(severity)

or something similar

Katono5 commented 1 year ago

Replace this line

https://github.com/RobustBench/robustbench/blob/ec26a6cd0b0812135270c3659caabcab80701b15/robustbench/data.py#L309

and instead for data_root_dir use Path(data_dir) / CORRUPTIONS_DIR_NAMES[ BenchmarkDataset.cifar10[ThreatModel.corruptions] / corruptions[0] / str(severity)

or something similar

Sorry Im still so confused, first of all I need to copy one line of code in function, and I don't know why you would copy

data_folder_path = Path(data_dir) / CORRUPTIONS_DIR_NAMES[
        BenchmarkDataset.imagenet][ThreatModel.corruptions] / corruptions[0] / str(severity)

this line since I don't know why it would work, and why replace 'this' line when you quoted a definition line of the . Could you please show me a more complete explanation of how you make it work? It would really help me a lot

dedeswim commented 1 year ago

Hi! This should have been solved in #144, thanks to @craymichael's contribution. Let us know if you still face the issue!