Skip to content

Commit

Permalink
run autoflake
Browse files Browse the repository at this point in the history
  • Loading branch information
arnab39 committed Mar 12, 2024
1 parent 7c9e2c1 commit 2e1e90b
Show file tree
Hide file tree
Showing 34 changed files with 22 additions and 84 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ repos:
# - id: pyupgrade
# args: ['--py37-plus']

## If you want to avoid flake8 errors due to unused vars or imports:
# - repo: https://github.com/PyCQA/autoflake
# rev: v2.1.1
# hooks:
# - id: autoflake
# args: [
# --in-place,
# --remove-all-unused-imports,
# ]
# If you want to avoid flake8 errors due to unused vars or imports:
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
hooks:
- id: autoflake
args: [
--in-place,
--remove-all-unused-imports,
]

# - repo: https://github.com/PyCQA/isort
# rev: 5.13.2
Expand Down
1 change: 0 additions & 1 deletion equiadapt/common/basecanonicalization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Tuple, Union

import torch
Expand Down
2 changes: 1 addition & 1 deletion equiadapt/images/canonicalization/discrete_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import math
from typing import Any, List, Tuple, Union
from typing import List, Tuple, Union

import kornia as K
import torch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import math

import kornia as K
import torch
import torch.nn as nn
from .custom_group_equivariant_layers import RotationEquivariantConvLift, RotationEquivariantConv, RotoReflectionEquivariantConvLift, RotoReflectionEquivariantConv
Expand Down
7 changes: 0 additions & 7 deletions equiadapt/nbody/canonicalization/continuous_group.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import torch
import kornia as K
from equiadapt.common.basecanonicalization import ContinuousGroupCanonicalization
from equiadapt.common.utils import gram_schmidt
from torch.nn.modules import Module
from torchvision import transforms
import math
from torch.nn import functional as F
from equiadapt.common.utils import gram_schmidt

class ContinuousGroupNBody(ContinuousGroupCanonicalization):
def __init__(self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import pytorch_lightning as pl
from pytorch3d.transforms import RotateAxisAngle, Rotate, random_rotations
import torchmetrics.functional as tmf
import wandb
import torch_scatter as ts
import math
from equiadapt.nbody.canonicalization_networks.gcl import E_GCL_vel, GCL
from equiadapt.nbody.canonicalization_networks.vn_layers import VNLinearLeakyReLU, VNLinear, VNLeakyReLU, VNSoftplus
from equiadapt.nbody.canonicalization_networks.vn_layers import VNLeakyReLU, VNSoftplus
from equiadapt.nbody.canonicalization_networks.set_base_models import SequentialMultiple


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
import pytorch_lightning as pl
from pytorch3d.transforms import RotateAxisAngle, Rotate, random_rotations
import torchmetrics.functional as tmf
import wandb

from equiadapt.nbody.canonicalization_networks.vn_layers import *
from equiadapt.nbody.canonicalization_networks.euclideangraph_base_models import EGNN_vel, GNN, VNDeepSets, BaseEuclideangraphModel, Transformer
from canonical_network.utils import define_hyperparams, dict_to_object
from canonical_network.utils import define_hyperparams

# Input dim is 6 because location and velocity vectors are concatenated.
NBODY_HYPERPARAMS = {
Expand Down
2 changes: 0 additions & 2 deletions equiadapt/nbody/canonicalization_networks/gcl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from torch import nn
import torch
import torch.nn.functional as F
import torch_scatter as ts


class MLP(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion equiadapt/nbody/canonicalization_networks/image_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from torch import optim, nn
import pytorch_lightning as pl
import torch
from torch.optim.lr_scheduler import OneCycleLR, MultiStepLR
from torch.optim.lr_scheduler import MultiStepLR
from canonical_network.models.image_networks import VanillaNetwork, EquivariantCanonizationNetwork, \
BasicConvEncoder, Identity, PCACanonizationNetwork, RotationEquivariantConvEncoder, OptimizationCanonizationNetwork
from canonical_network.models.resnet import resnet44
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import torch
from canonical_network.models.equivariant_layers import RotationEquivariantConvLift, \
RotoReflectionEquivariantConvLift, RotationEquivariantConv, RotoReflectionEquivariantConv
from torchvision import transforms
from canonical_network.models.set_base_models import SequentialMultiple
import numpy as np

Expand Down
2 changes: 0 additions & 2 deletions equiadapt/nbody/canonicalization_networks/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
If you use this implementation in you work, please don't forget to mention the
author, Yerlan Idelbayev.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init

from torch.autograd import Variable

__all__ = ['ResNet', 'resnet20', 'resnet32', 'resnet44', 'resnet56', 'resnet110', 'resnet1202']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sched import scheduler
import torch
import torch.nn as nn
import torch.nn.functional as F
Expand Down
3 changes: 0 additions & 3 deletions equiadapt/nbody/canonicalization_networks/set_model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from collections import namedtuple

from turtle import forward
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch_scatter as ts
import pytorch_lightning as pl
import torchmetrics.functional as tmf
from einops import rearrange
import wandb

Expand Down
6 changes: 0 additions & 6 deletions equiadapt/nbody/canonicalization_networks/vn_layers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import os
import sys
import copy
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F

EPS = 1e-6

Expand Down
1 change: 0 additions & 1 deletion equiadapt/pointcloud/canonicalization/continuous_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# This is meant to be a proof of concept and we are happy to receive contribution to extend this to other group actions.

import torch
import kornia as K
from equiadapt.common.basecanonicalization import ContinuousGroupCanonicalization
from equiadapt.common.utils import gram_schmidt
from typing import Any, List, Tuple, Union
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
import torch.nn as nn
from equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers import VNLinearLeakyReLU, VNLinear, VNMaxPool, VNBatchNorm
from equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers import VNLinearLeakyReLU, VNMaxPool, VNBatchNorm

def knn(x, k):
inner = -2 * torch.matmul(x.transpose(2, 1), x)
Expand Down
2 changes: 0 additions & 2 deletions examples/images/classification/inference_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import math
from typing import Dict, Union

import torch
from omegaconf import DictConfig
from torchvision import transforms

import wandb


def get_inference_method(canonicalizer: torch.nn.Module,
Expand Down
4 changes: 0 additions & 4 deletions examples/images/classification/prepare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .cifar_data import CIFAR10DataModule, CIFAR100DataModule
from .imagenet_data import ImageNetDataModule
from .rotated_mnist_data import RotatedMNISTDataModule
from .stl10_data import STL10DataModule
2 changes: 1 addition & 1 deletion examples/images/classification/prepare/cifar_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random

import pytorch_lightning as pl
from torch.utils.data import DataLoader, random_split
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import CIFAR10, CIFAR100

Expand Down
4 changes: 1 addition & 3 deletions examples/images/classification/prepare/imagenet_data.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

import os
import random
from typing import List

import pytorch_lightning as pl
import torch
import torchvision
import torchvision.transforms as transforms
from PIL import Image, ImageOps
from PIL import ImageOps
from torch import nn

DEFAULT_CROP_RATIO = 224/256
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import argparse
import os
import urllib.request as url_req
import zipfile
Expand Down
2 changes: 1 addition & 1 deletion examples/images/classification/prepare/stl10_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random

import pytorch_lightning as pl
from torch.utils.data import DataLoader, random_split
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import STL10

Expand Down
2 changes: 1 addition & 1 deletion examples/images/classification/train_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional
from typing import Optional

import dotenv
import pytorch_lightning as pl
Expand Down
1 change: 0 additions & 1 deletion examples/images/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .utils import get_canonicalization_network, get_canonicalizer
1 change: 0 additions & 1 deletion examples/images/segmentation/prepare/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .coco_data import COCODataModule
1 change: 0 additions & 1 deletion examples/images/segmentation/prepare/vision_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import torch
from torch import Tensor, nn
from torchvision import ops
from torchvision.transforms import functional as F
from torchvision.transforms import transforms as T

Expand Down
2 changes: 1 addition & 1 deletion examples/images/segmentation/train_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional
from typing import Optional

import dotenv
import pytorch_lightning as pl
Expand Down
4 changes: 1 addition & 3 deletions examples/nbody/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import torch
import pytorch_lightning as pl
from torch.optim.lr_scheduler import MultiStepLR
from examples.nbody.model_utils import get_canonicalization_network, get_prediction_network, get_edges
import torch.nn as nn
from omegaconf import OmegaConf, DictConfig
from omegaconf import DictConfig
from equiadapt.nbody.canonicalization.continuous_group import ContinuousGroupNBody
import wandb

class NBodyPipeline(pl.LightningModule):
def __init__(self, hyperparams: DictConfig):
Expand Down
2 changes: 0 additions & 2 deletions examples/nbody/model_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from equiadapt.nbody.canonicalization_networks.euclideangraph_base_models import EGNN_vel, VNDeepSets, GNN, Transformer
from collections import namedtuple
from omegaconf import OmegaConf
import torch


Expand Down
5 changes: 1 addition & 4 deletions examples/nbody/prepare/nbody_data.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset
from torch.utils.data import DataLoader
import pytorch_lightning as pl
import os
import json
import numpy as np
from torch.utils.data import Dataset
import pathlib

SRC_PATH = pathlib.Path(__file__).parent.parent
Expand Down
3 changes: 1 addition & 2 deletions examples/nbody/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import pytorch_lightning as pl
import wandb
import os
from omegaconf import DictConfig, OmegaConf
from omegaconf import OmegaConf
from examples.nbody.model import NBodyPipeline
import torch

from examples.nbody.prepare.nbody_data import NBodyDataModule

Expand Down
1 change: 0 additions & 1 deletion examples/pointcloud/classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from omegaconf import DictConfig, OmegaConf
import pytorch_lightning as pl
from pytorch_lightning.loggers import WandbLogger
from argparse import ArgumentParser

from prepare import ModelNetDataModule
from train_utils import get_model_pipeline, get_callbacks, get_checkpoint_name, get_trainer, load_envs
Expand Down
3 changes: 0 additions & 3 deletions examples/pointcloud/common/networks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from omegaconf import DictConfig
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pytorch_lightning as pl
from torch.autograd import Variable
import torch.nn.init as init

def knn(x, k):
Expand Down
1 change: 0 additions & 1 deletion examples/pointcloud/part_segmentation/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from omegaconf import DictConfig, OmegaConf
import pytorch_lightning as pl
from pytorch_lightning.loggers import WandbLogger
from argparse import ArgumentParser

from prepare import ShapeNetDataModule
from train_utils import get_model_pipeline, get_callbacks, get_checkpoint_name, get_trainer, load_envs
Expand Down

0 comments on commit 2e1e90b

Please sign in to comment.