Skip to content

Commit 5afca5f

Browse files
amyreesefacebook-github-bot
authored andcommitted
apply import merging for fbcode (11 of 11)
Summary: Applies new import merging and sorting from µsort v1.0. When merging imports, µsort will make a best-effort to move associated comments to match merged elements, but there are known limitations due to the diynamic nature of Python and developer tooling. These changes should not produce any dangerous runtime changes, but may require touch-ups to satisfy linters and other tooling. Note that µsort uses case-insensitive, lexicographical sorting, which results in a different ordering compared to isort. This provides a more consistent sorting order, matching the case-insensitive order used when sorting import statements by module name, and ensures that "frog", "FROG", and "Frog" always sort next to each other. For details on µsort's sorting and merging semantics, see the user guide: https://usort.readthedocs.io/en/stable/guide.html#sorting Reviewed By: lisroach Differential Revision: D36402260 fbshipit-source-id: 7cb52f09b740ccc580e61e6d1787d27381a8ce00
1 parent 825e8aa commit 5afca5f

24 files changed

+35
-35
lines changed

hubconf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
slow_r50,
1515
slow_r50_detection,
1616
slowfast_16x8_r101_50_50,
17+
slowfast_r101,
1718
slowfast_r50,
1819
slowfast_r50_detection,
19-
slowfast_r101,
2020
x3d_l,
2121
x3d_m,
2222
x3d_s,

pytorchvideo/data/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
from .epic_kitchen_recognition import EpicKitchenRecognition # noqa
1414
from .hmdb51 import Hmdb51 # noqa
1515
from .kinetics import Kinetics # noqa
16-
from .labeled_video_dataset import LabeledVideoDataset, labeled_video_dataset # noqa
16+
from .labeled_video_dataset import labeled_video_dataset, LabeledVideoDataset # noqa
1717
from .ssv2 import SSv2
1818
from .ucf101 import Ucf101 # noqa

pytorchvideo/data/epic_kitchen/epic_kitchen_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import torch
88
from pytorchvideo.data.dataset_manifest_utils import (
99
EncodedVideoInfo,
10+
get_seconds_from_hms_time,
1011
VideoClipInfo,
1112
VideoDataset,
1213
VideoDatasetType,
1314
VideoFrameInfo,
1415
VideoInfo,
15-
get_seconds_from_hms_time,
1616
)
1717
from pytorchvideo.data.frame_video import FrameVideo
1818
from pytorchvideo.data.utils import DataclassFieldCaster, load_dataclass_dict_from_csv

pytorchvideo/data/kinetics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import torch
66
from pytorchvideo.data.clip_sampling import ClipSampler
77

8-
from .labeled_video_dataset import LabeledVideoDataset, labeled_video_dataset
8+
from .labeled_video_dataset import labeled_video_dataset, LabeledVideoDataset
99

1010

1111
"""

pytorchvideo/data/ucf101.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import torch
66
from pytorchvideo.data.clip_sampling import ClipSampler
77

8-
from .labeled_video_dataset import LabeledVideoDataset, labeled_video_dataset
8+
from .labeled_video_dataset import labeled_video_dataset, LabeledVideoDataset
99

1010

1111
"""

pytorchvideo/layers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .attention import Mlp, MultiScaleAttention, MultiScaleBlock
44
from .attention_torchscript import ScriptableMultiScaleBlock
55
from .drop_path import DropPath
6-
from .fusion import ConcatFusion, ReduceFusion, make_fusion_layer
6+
from .fusion import ConcatFusion, make_fusion_layer, ReduceFusion
77
from .mlp import make_multilayer_perceptron
88
from .positional_encoding import PositionalEncoding, SpatioTemporalClsPositionalEncoding
99
from .positional_encoding_torchscript import (

pytorchvideo/models/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
22

33
from .csn import create_csn
4-
from .head import ResNetBasicHead, create_res_basic_head
4+
from .head import create_res_basic_head, ResNetBasicHead
55
from .masked_multistream import (
6-
LSTM,
76
LearnMaskedDefault,
7+
LSTM,
88
MaskedMultiPathWay,
99
MaskedSequential,
1010
MaskedTemporalPooling,
@@ -14,6 +14,6 @@
1414
from .net import MultiPathWayWithFuse, Net
1515
from .resnet import BottleneckBlock, create_bottleneck_block, create_resnet
1616
from .slowfast import create_slowfast
17-
from .stem import ResNetBasicStem, create_conv_patch_embed, create_res_basic_stem
17+
from .stem import create_conv_patch_embed, create_res_basic_stem, ResNetBasicStem
1818
from .vision_transformers import create_multiscale_vision_transformers
1919
from .weight_init import init_net_weights

pytorchvideo/models/csn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import torch
66
import torch.nn as nn
77
from pytorchvideo.models.head import create_res_basic_head
8-
from pytorchvideo.models.resnet import Net, create_bottleneck_block, create_res_stage
8+
from pytorchvideo.models.resnet import create_bottleneck_block, create_res_stage, Net
99
from pytorchvideo.models.stem import create_res_basic_stem
1010

1111

pytorchvideo/models/hub/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from .resnet import c2d_r50, i3d_r50, slow_r50, slow_r50_detection
77
from .slowfast import (
88
slowfast_16x8_r101_50_50,
9+
slowfast_r101,
910
slowfast_r50,
1011
slowfast_r50_detection,
11-
slowfast_r101,
1212
)
1313
from .vision_transformers import mvit_base_16, mvit_base_16x4, mvit_base_32x3
1414
from .x3d import x3d_l, x3d_m, x3d_s, x3d_xs

pytorchvideo/models/hub/vision_transformers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
create_multiscale_vision_transformers,
88
)
99

10-
from .utils import MODEL_ZOO_ROOT_DIR, hub_model_builder
10+
from .utils import hub_model_builder, MODEL_ZOO_ROOT_DIR
1111

1212

1313
checkpoint_paths = {

pytorchvideo/transforms/augmix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import torch
66
from pytorchvideo.transforms.augmentations import (
77
_AUGMENTATION_MAX_LEVEL,
8-
AugmentTransform,
98
_decreasing_int_to_arg,
109
_decreasing_to_arg,
1110
_increasing_magnitude_to_arg,
1211
_increasing_randomly_negate_to_arg,
12+
AugmentTransform,
1313
)
1414
from pytorchvideo.transforms.transforms import OpSampler
1515

pytorchvideo_trainer/pytorchvideo_trainer/module/byol.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from omegaconf import MISSING
1111
from pytorchvideo.models.resnet import create_resnet
1212
from pytorchvideo.models.weight_init import init_net_weights
13-
from pytorchvideo_trainer.module.ssl_helper import SSLBaseModule, create_mlp_util
13+
from pytorchvideo_trainer.module.ssl_helper import create_mlp_util, SSLBaseModule
1414
from pytorchvideo_trainer.module.video_classification import (
1515
Batch,
1616
BatchKey,

pytorchvideo_trainer/pytorchvideo_trainer/module/moco_v2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from omegaconf import MISSING
1313
from pytorchvideo.models.resnet import create_resnet
1414
from pytorchvideo.models.weight_init import init_net_weights
15-
from pytorchvideo_trainer.module.ssl_helper import SSLBaseModule, create_mlp_util
15+
from pytorchvideo_trainer.module.ssl_helper import create_mlp_util, SSLBaseModule
1616
from pytorchvideo_trainer.module.video_classification import (
1717
Batch,
1818
BatchKey,

pytorchvideo_trainer/pytorchvideo_trainer/module/video_classification.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from omegaconf import MISSING, OmegaConf
2727
from pytorch_lightning.utilities import rank_zero_info
2828
from pytorchvideo_trainer.datamodule.transforms import MixVideoBatchWrapper
29-
from pytorchvideo_trainer.module.lr_policy import LRSchedulerConf, get_epoch_lr, set_lr
29+
from pytorchvideo_trainer.module.lr_policy import get_epoch_lr, LRSchedulerConf, set_lr
3030
from pytorchvideo_trainer.module.optimizer import construct_optimizer
3131
from torch import nn
3232
from torch.optim.lr_scheduler import _LRScheduler

tests/test_data_dataset_manifest_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
VideoFrameInfo,
1010
VideoInfo,
1111
)
12-
from utils import MOCK_VIDEO_IDS, MOCK_VIDEO_INFOS, get_flat_video_frames
12+
from utils import get_flat_video_frames, MOCK_VIDEO_IDS, MOCK_VIDEO_INFOS
1313

1414

1515
class TestDatasetManifestUtils(unittest.TestCase):

tests/test_data_domsev_dataset.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
from parameterized import parameterized
1111
from pytorchvideo.data.dataset_manifest_utils import VideoClipInfo, VideoDatasetType
1212
from pytorchvideo.data.domsev import (
13-
DomsevVideoDataset,
14-
LabelData,
1513
_get_overlap_for_time_range_pair,
1614
_seconds_to_frame_index,
15+
DomsevVideoDataset,
16+
LabelData,
1717
)
1818
from pytorchvideo.data.utils import save_dataclass_objs_to_headered_csv
1919
from utils import (
20-
MOCK_VIDEO_IDS,
21-
MOCK_VIDEO_INFOS,
2220
get_encoded_video_infos,
2321
get_flat_video_frames,
22+
MOCK_VIDEO_IDS,
23+
MOCK_VIDEO_INFOS,
2424
)
2525

2626

tests/test_data_epic_kitchen_dataset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from pytorchvideo.data.epic_kitchen import ActionData, EpicKitchenDataset
1313
from pytorchvideo.data.utils import save_dataclass_objs_to_headered_csv
1414
from utils import (
15-
MOCK_VIDEO_IDS,
16-
MOCK_VIDEO_INFOS,
1715
get_encoded_video_infos,
1816
get_flat_video_frames,
17+
MOCK_VIDEO_IDS,
18+
MOCK_VIDEO_INFOS,
1919
)
2020

2121

tests/test_data_labeled_video_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
from pytorchvideo.data import Hmdb51
2323
from pytorchvideo.data.clip_sampling import make_clip_sampler
2424
from pytorchvideo.data.labeled_video_dataset import (
25-
LabeledVideoDataset,
2625
labeled_video_dataset,
26+
LabeledVideoDataset,
2727
)
2828
from pytorchvideo.data.labeled_video_paths import LabeledVideoPaths
2929
from pytorchvideo.data.utils import MultiProcessSampler, thwc_to_cthw

tests/test_layers_nonlocal_net.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88
import torch
9-
from pytorchvideo.layers.nonlocal_net import NonLocal, create_nonlocal
9+
from pytorchvideo.layers.nonlocal_net import create_nonlocal, NonLocal
1010
from torch import nn
1111

1212

tests/test_models_head.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import numpy as np
77
import torch
88
from pytorchvideo.models.head import (
9-
ResNetBasicHead,
10-
ResNetRoIHead,
11-
SequencePool,
129
create_res_basic_head,
1310
create_res_roi_pooling_head,
1411
create_vit_basic_head,
12+
ResNetBasicHead,
13+
ResNetRoIHead,
14+
SequencePool,
1515
)
1616
from torch import nn
1717
from torchvision.ops import RoIAlign

tests/test_models_masked_multistream.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import torch
77
import torch.nn
8-
from pytorchvideo.layers import PositionalEncoding, make_multilayer_perceptron
8+
from pytorchvideo.layers import make_multilayer_perceptron, PositionalEncoding
99
from pytorchvideo.models.masked_multistream import (
10-
LSTM,
1110
LearnMaskedDefault,
11+
LSTM,
1212
MaskedSequential,
1313
MaskedTemporalPooling,
1414
TransposeMultiheadAttention,

tests/test_models_resnet.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
from pytorchvideo.models.net import Net
1111
from pytorchvideo.models.resnet import (
1212
BottleneckBlock,
13-
ResBlock,
14-
ResStage,
15-
SeparableBottleneckBlock,
1613
create_acoustic_bottleneck_block,
1714
create_acoustic_resnet,
1815
create_bottleneck_block,
1916
create_res_block,
2017
create_res_stage,
2118
create_resnet,
2219
create_resnet_with_roi_head,
20+
ResBlock,
21+
ResStage,
22+
SeparableBottleneckBlock,
2323
)
2424
from pytorchvideo.models.stem import ResNetBasicStem
2525
from torch import nn

tests/test_models_stem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import torch
88
from pytorchvideo.layers.convolutions import ConvReduce3D
99
from pytorchvideo.models.stem import (
10-
ResNetBasicStem,
1110
create_acoustic_res_basic_stem,
1211
create_res_basic_stem,
12+
ResNetBasicStem,
1313
)
1414
from torch import nn
1515

tests/test_transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pytorchvideo.transforms import (
1111
ApplyTransformToKey,
1212
AugMix,
13+
create_video_transform,
1314
CutMix,
1415
MixUp,
1516
MixVideo,
@@ -22,7 +23,6 @@
2223
ShortSideScale,
2324
UniformCropVideo,
2425
UniformTemporalSubsample,
25-
create_video_transform,
2626
)
2727
from pytorchvideo.transforms.functional import (
2828
clip_boxes_to_image,

0 commit comments

Comments
 (0)