Skip to content

Commit

Permalink
fix import sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
thavlik committed Mar 7, 2024
1 parent 074a1c9 commit e70ff79
Show file tree
Hide file tree
Showing 54 changed files with 116 additions and 132 deletions.
3 changes: 1 addition & 2 deletions src/augmentation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import torch
from torch import Tensor
from torch.nn.parameter import Parameter
from torch.utils.data import Dataset

import os
from typing import Iterator

from base_experiment import BaseExperiment
Expand Down
3 changes: 2 additions & 1 deletion src/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from abc import abstractmethod
from torch import Tensor, optim
from torch.nn.parameter import Parameter
from torch.optim.lr_scheduler import ChainedScheduler, LRScheduler, ReduceLROnPlateau
from torch.optim.lr_scheduler import (ChainedScheduler, LRScheduler,
ReduceLROnPlateau)
from torch.optim.optimizer import Optimizer
from torch.utils.data import DataLoader, Dataset
from typing import Iterator, Optional
Expand Down
3 changes: 1 addition & 2 deletions src/classification.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import torch
from torch import Tensor
from torch.nn.parameter import Parameter
from torch.utils.data import Dataset

import os
from typing import Iterator, List

from base_experiment import BaseExperiment
Expand Down
3 changes: 2 additions & 1 deletion src/compiler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import argparse
import json
import youtube_dl
import os
import sys

import youtube_dl

parser = argparse.ArgumentParser(description='Youtube dataset compiler')
parser.add_argument(
'--input',
Expand Down
1 change: 0 additions & 1 deletion src/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from torch import Size
from torch.utils.data import Dataset
from torch.utils.data.sampler import WeightedRandomSampler

#import nonechucks as nc
from typing import Optional

Expand Down
2 changes: 1 addition & 1 deletion src/dataset/batch_video.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import torch

import os
from decord import VideoLoader, cpu


Expand Down
2 changes: 1 addition & 1 deletion src/dataset/cq500.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import torch
import torch.utils.data as data

import boto3
import os
import pydicom

CQ500_HEADER = 'name,Category,R1:ICH,R1:IPH,R1:IVH,R1:SDH,R1:EDH,R1:SAH,R1:BleedLocation-Left,R1:BleedLocation-Right,R1:ChronicBleed,R1:Fracture,R1:CalvarialFracture,R1:OtherFracture,R1:MassEffect,R1:MidlineShift,R2:ICH,R2:IPH,R2:IVH,R2:SDH,R2:EDH,R2:SAH,R2:BleedLocation-Left,R2:BleedLocation-Right,R2:ChronicBleed,R2:Fracture,R2:CalvarialFracture,R2:OtherFracture,R2:MassEffect,R2:MidlineShift,R3:ICH,R3:IPH,R3:IVH,R3:SDH,R3:EDH,R3:SAH,R3:BleedLocation-Left,R3:BleedLocation-Right,R3:ChronicBleed,R3:Fracture,R3:CalvarialFracture,R3:OtherFracture,R3:MassEffect,R3:MidlineShift\n'
Expand Down
4 changes: 2 additions & 2 deletions src/dataset/deeplesion.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import torch
import torch.utils.data as data
from torch.nn import functional as F
from typing import List

import boto3
import numpy as np
import os
from skimage.io import imread
from skimage.transform import resize
from typing import List


def read_hu(x):
Expand Down
6 changes: 3 additions & 3 deletions src/dataset/forrestgump.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import os
import torch
import torch.utils.data as data
from torch import Tensor
from typing import Optional

import json
import numpy as np
import os
from typing import Optional


def load_scenes(path: str) -> list:
Expand Down
4 changes: 2 additions & 2 deletions src/dataset/forrestgump_converter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import json
import os
import numpy as np
from math import ceil

import nilearn as nl
import nilearn.plotting
from math import ceil
import numpy as np


Expand Down
10 changes: 5 additions & 5 deletions src/dataset/forrestgumpraw.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
import numpy as np
import nilearn as nl
import nilearn.plotting
from math import floor
import numpy as np
import torch
import torch.utils.data as data
from math import floor
from torch import Tensor
from typing import Optional

import nilearn as nl
import nilearn.plotting
import numpy as np


def load_scenes(path: str) -> list:
with open(path, "r") as f:
Expand Down
8 changes: 4 additions & 4 deletions src/dataset/grasp_and_lift_eeg.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
import time
import torch
import torch.nn.functional as F
import torch.utils.data as data
import zipfile
from torch import Tensor
from typing import List, Optional

import numpy as np
import os
import requests
import time
import zipfile
from typing import List, Optional


def recursive_listdir(path: str, suffix: str) -> list:
Expand Down
4 changes: 2 additions & 2 deletions src/dataset/la5c.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import torch.utils.data as data
from torch import Tensor
from typing import List

import nilearn as nl
import numpy as np
import os
from typing import List


class LA5cDataset(data.Dataset):
Expand Down
4 changes: 2 additions & 2 deletions src/dataset/rsna_intracranial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import gzip
import os
import torch
import torch.utils.data as data
from torch import Tensor
from torch.nn import functional as F

import boto3
import gzip
import os
import pydicom

from .dicom_util import normalized_dicom_pixels
Expand Down
19 changes: 11 additions & 8 deletions src/dataset/toy_neural_graphics.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import os
import numpy as np
import torch
import torch.utils.data as data
from pytorch3d.io import load_objs_as_meshes, load_obj
from pytorch3d.transforms import random_rotation, Translate, Rotate, Transform3d
from pytorch3d.renderer import (look_at_view_transform, FoVPerspectiveCameras,
PointLights, DirectionalLights, Materials,
RasterizationSettings, MeshRenderer,
MeshRasterizer, SoftPhongShader,
HardFlatShader, TexturesUV, TexturesVertex)

import numpy as np
from pytorch3d.io import load_obj, load_objs_as_meshes
from pytorch3d.renderer import (DirectionalLights, FoVPerspectiveCameras,
HardFlatShader, Materials, MeshRasterizer,
MeshRenderer, PointLights,
RasterizationSettings, SoftPhongShader,
TexturesUV, TexturesVertex,
look_at_view_transform)
from pytorch3d.transforms import (Rotate, Transform3d, Translate,
random_rotation)


class ToyNeuralGraphicsDataset(data.Dataset):
Expand Down
2 changes: 1 addition & 1 deletion src/dataset/trends_fmri.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import torch
import torch.utils.data as data

import h5py
import nilearn as nl
import numpy as np
import os


def load_subject(filename: str, mask_niimg):
Expand Down
2 changes: 1 addition & 1 deletion src/dataset/video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import torch
import torch.utils.data as data

import os
from decord import VideoReader, cpu


Expand Down
12 changes: 7 additions & 5 deletions src/dataset/video_old.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import json
import os
import numpy as np
import torch
import torch.utils.data as data
from math import floor
import youtube_dl

import cv2
import numpy as np
import youtube_dl
from torchvision.transforms import Resize, ToPILImage, ToTensor
import json


def load_links(path):
Expand Down Expand Up @@ -193,9 +194,10 @@ def __len__(self):


if __name__ == '__main__':
import youtube_dl
import cv2
import time

import cv2
import youtube_dl
width = 640
height = 480
num_frames = 9
Expand Down
3 changes: 2 additions & 1 deletion src/draw_boxes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Source: https://www.kaggle.com/kmader/deeplesion-overview
import os

import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
from matplotlib.patches import Rectangle
from skimage.io import imread
Expand Down
3 changes: 2 additions & 1 deletion src/load_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import yaml
from typing import List, Union

import yaml

from merge_strategy import deep_merge


Expand Down
10 changes: 5 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import torch.backends.cudnn as cudnn

import argparse
import cv2
import decord # must be imported after torch
import gc
import numpy as np
import os
import time
import torch.backends.cudnn as cudnn
from typing import List, Union

import cv2
import decord # must be imported after torch
import numpy as np

from entry import experiment_main
from load_config import load_config

Expand Down
3 changes: 1 addition & 2 deletions src/models/augmenter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch
from torch import Tensor, nn

from abc import abstractmethod
from torch import Tensor, nn
from typing import List


Expand Down
3 changes: 1 addition & 2 deletions src/models/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import torch
from abc import abstractmethod
from torch import Tensor, nn
from torch.nn import functional as F

from abc import abstractmethod
from typing import Any, List

from .util import reparameterize
Expand Down
3 changes: 1 addition & 2 deletions src/models/classifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import torch
from abc import abstractmethod
from torch import Tensor, nn
from torch.nn import functional as F

from abc import abstractmethod
from typing import List


Expand Down
2 changes: 1 addition & 1 deletion src/models/conv4d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import torch
from torch import nn
from typing import Callable, Tuple, Union

import numpy as np
from typing import Callable, Tuple, Union


class Conv4d(nn.Module):
Expand Down
1 change: 0 additions & 1 deletion src/models/encoder_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from torch import Tensor, nn

from typing import List


Expand Down
7 changes: 2 additions & 5 deletions src/models/localizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
from torch.nn import functional as F
from typing import Optional

from torchvision.ops import (
complete_box_iou_loss,
distance_box_iou_loss,
generalized_box_iou_loss,
)
from torchvision.ops import (complete_box_iou_loss, distance_box_iou_loss,
generalized_box_iou_loss)


class Localizer(nn.Module):
Expand Down
3 changes: 1 addition & 2 deletions src/models/renderer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import torch
from abc import abstractmethod
from torch import Tensor, nn
from torch.nn import functional as F

from abc import abstractmethod
from typing import List

from .inception import InceptionV3
Expand Down
1 change: 0 additions & 1 deletion src/models/resnet_augmenter1d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import torch
from torch import Size, Tensor, nn

from typing import List

from .augmenter import Augmenter
Expand Down
3 changes: 1 addition & 2 deletions src/models/resnet_classifier1d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch
from torch import Size, Tensor, nn

from math import ceil
from torch import Size, Tensor, nn
from typing import List

from .classifier import Classifier
Expand Down
3 changes: 1 addition & 2 deletions src/models/resnet_classifier2d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch
from torch import Size, Tensor, nn

from math import ceil
from torch import Size, Tensor, nn
from typing import List

from .classifier import Classifier
Expand Down
3 changes: 1 addition & 2 deletions src/models/resnet_classifier3d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from math import ceil
from torch import Size, Tensor, nn
from torch.nn import functional as F

from math import ceil
from typing import List

from .classifier import Classifier
Expand Down
Loading

0 comments on commit e70ff79

Please sign in to comment.