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

refactor all charmory. code to armory. namespace #103

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
385 changes: 385 additions & 0 deletions docs/getting_started.ipynb
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mwartell was this file suppose to be updated like this? It doesn't seem like this is the same file from the master branch

Copy link
Collaborator

Choose a reason for hiding this comment

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

like maybe this was from another branch's update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is accidental You pegged it right, it was an untracked file from #76. I'm removing it in this branch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
import torchmetrics.classification

import armory.baseline_models.pytorch.resnet18
from armory.data import ArmoryDataLoader
import armory.data.datasets
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.metrics.compute import BasicProfiler
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.image_classification import JaticImageClassificationModel
from armory.perturbation import ArtEvasionAttack
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params
from armory.utils import create_jatic_dataset_transform
import armory.version
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.image_classification import JaticImageClassificationModel
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params
from charmory.utils import create_jatic_dataset_transform


def load_huggingface_dataset(transform, batch_size):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import albumentations as A

from armory.engine import AdversarialDatasetEngine
from armory.examples.image_classification.eurosat_precomputed_pgd.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import AdversarialDatasetEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import torch.nn as nn
import torchmetrics.classification

from armory.data import ArmoryDataLoader
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.image_classification import JaticImageClassificationModel
from charmory.perturbation import ArtEvasionAttack, Perturbation
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.image_classification import JaticImageClassificationModel
from armory.perturbation import ArtEvasionAttack, Perturbation
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params

_MODELS = {
"untrained": f"{os.path.dirname(__file__)}/finetuned_eurosat_final/",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pprint import pprint

from armory.engine import EvaluationEngine
from armory.examples.image_classification.eurosat_precomputed_pgd.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import EvaluationEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pprint import pprint

from armory.engine import EvaluationEngine
from armory.examples.image_classification.eurosat_precomputed_pgd.evaluation import (
create_evaluation_task,
)
from armory.examples.utils.args import create_parser
from armory.matrix import matrix
from armory.matrix.range import frange
from charmory.engine import EvaluationEngine
from charmory.track import track_param
from armory.track import track_param


@matrix(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pprint import pprint

from armory.engine import EvaluationEngine
from armory.examples.image_classification.eurosat_precomputed_pgd.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import EvaluationEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from torchvision import transforms as T

import armory.baseline_models.pytorch.food101
from armory.data import ArmoryDataLoader
import armory.data.datasets
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model, SysConfig
from armory.metrics.compute import BasicProfiler
from armory.metrics.perturbation import PerturbationNormMetric
from armory.perturbation import ArtEvasionAttack
from armory.tasks.image_classification import ImageClassificationTask
from armory.utils import PILtoNumpy
import armory.version
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model, SysConfig
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.utils import PILtoNumpy

BATCH_SIZE = 16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
import torch.nn as nn
import torchmetrics.classification

from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.experimental.transforms import create_image_classification_transform
from armory.metrics.compute import BasicProfiler
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.image_classification import JaticImageClassificationModel
from armory.perturbation import ArtEvasionAttack
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params
import armory.version
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.experimental.transforms import create_image_classification_transform
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.image_classification import JaticImageClassificationModel
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params

BATCH_SIZE = 16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import torchmetrics.classification
from transformers.image_utils import infer_channel_dimension_format

from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.image_classification import JaticImageClassificationModel
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params
from charmory.utils import create_jatic_dataset_transform
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.image_classification import JaticImageClassificationModel
from armory.perturbation import ArtEvasionAttack
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params
from armory.utils import create_jatic_dataset_transform


def get_cli_args():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
from torchvision.transforms.v2 import GaussianBlur
from transformers import AutoImageProcessor, AutoModelForImageClassification

from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
import armory.evaluation as ev
from armory.examples.utils.args import create_parser
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
import charmory.evaluation as ev
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.image_classification import JaticImageClassificationModel
from charmory.perturbation import ArtEvasionAttack, TorchTransformPerturbation
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params
from charmory.utils import Unnormalize
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.image_classification import JaticImageClassificationModel
from armory.perturbation import ArtEvasionAttack, TorchTransformPerturbation
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params
from armory.utils import Unnormalize


def get_cli_args():
Expand Down
16 changes: 8 additions & 8 deletions examples/src/armory/examples/image_classification/pokemon_pgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import torchmetrics.classification

import armory.baseline_models.pytorch.pokemon
from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.experimental.transforms import create_image_classification_transform
from armory.metrics.compute import BasicProfiler
from armory.metrics.perturbation import PerturbationNormMetric
from armory.perturbation import ArtEvasionAttack
from armory.tasks.image_classification import ImageClassificationTask
from armory.track import track_init_params, track_params
import armory.version
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.experimental.transforms import create_image_classification_transform
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.image_classification import ImageClassificationTask
from charmory.track import track_init_params, track_params

BATCH_SIZE = 16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
import numpy as np
import torchmetrics.detection

from armory.art_experimental.attacks.patch import AttackWrapper
from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.experimental.patch import AttackWrapper
from armory.experimental.transforms import BboxFormat, create_object_detection_transform
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.experimental.transforms import (
BboxFormat,
create_object_detection_transform,
)
from charmory.model.object_detection import JaticObjectDetectionModel
from charmory.perturbation import ArtEvasionAttack
from charmory.tasks.object_detection import ObjectDetectionTask
from charmory.track import track_init_params, track_params
from charmory.utils import create_jatic_dataset_transform
from armory.model.object_detection import JaticObjectDetectionModel
from armory.perturbation import ArtEvasionAttack
from armory.tasks.object_detection import ObjectDetectionTask
from armory.track import track_init_params, track_params
from armory.utils import create_jatic_dataset_transform


def get_cli_args():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import torch
from torchvision.ops import box_convert

from armory.engine import AdversarialDatasetEngine
from armory.examples.object_detection.coco_precomputed_patch.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import AdversarialDatasetEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
import torchmetrics.detection
from transformers import AutoImageProcessor, AutoModelForObjectDetection

from armory.art_experimental.attacks.patch import AttackWrapper
from armory.data import ArmoryDataLoader
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.experimental.patch import AttackWrapper
from armory.experimental.transforms import BboxFormat, create_object_detection_transform
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.experimental.transforms import (
BboxFormat,
create_object_detection_transform,
)
from charmory.model.object_detection import YolosTransformer
from charmory.perturbation import ArtEvasionAttack, Perturbation
from charmory.tasks.object_detection import ObjectDetectionTask
from charmory.track import track_init_params, track_params
from armory.model.object_detection import YolosTransformer
from armory.perturbation import ArtEvasionAttack, Perturbation
from armory.tasks.object_detection import ObjectDetectionTask
from armory.track import track_init_params, track_params


def get_cli_args(with_attack: bool):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pprint import pprint

from armory.engine import EvaluationEngine
from armory.examples.object_detection.coco_precomputed_patch.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import EvaluationEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pprint import pprint

from armory.engine import EvaluationEngine
from armory.examples.object_detection.coco_precomputed_patch.evaluation import (
create_evaluation_task,
get_cli_args,
)
from charmory.engine import EvaluationEngine
from charmory.track import track_param
from armory.track import track_param

if __name__ == "__main__":
args = get_cli_args(with_attack=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@
from torchvision.transforms.v2 import GaussianBlur
from transformers import AutoImageProcessor, AutoModelForObjectDetection

from armory.art_experimental.attacks.patch import AttackWrapper
from armory.data import ArmoryDataLoader
from armory.engine import EvaluationEngine
from armory.evaluation import Dataset, Evaluation, Metric, Model
from armory.examples.utils.args import create_parser
from armory.experimental.patch import AttackWrapper
from armory.experimental.transforms import BboxFormat, create_object_detection_transform
from armory.metrics.compute import BasicProfiler
from charmory.data import ArmoryDataLoader
from charmory.engine import EvaluationEngine
from charmory.evaluation import Dataset, Evaluation, Metric, Model
from charmory.experimental.transforms import (
BboxFormat,
create_object_detection_transform,
)
from charmory.metrics.perturbation import PerturbationNormMetric
from charmory.model.object_detection import YolosTransformer
from charmory.perturbation import ArtEvasionAttack, TorchTransformPerturbation
from charmory.tasks.object_detection import ObjectDetectionTask
from charmory.track import track_init_params, track_params
from armory.metrics.perturbation import PerturbationNormMetric
from armory.model.object_detection import YolosTransformer
from armory.perturbation import ArtEvasionAttack, TorchTransformPerturbation
from armory.tasks.object_detection import ObjectDetectionTask
from armory.track import track_init_params, track_params


def get_cli_args():
Expand Down
Loading
Loading