Skip to content

Commit

Permalink
Update black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Gofinge committed Feb 25, 2024
1 parent 8c3b8ff commit 72a7993
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 112 deletions.
8 changes: 5 additions & 3 deletions libs/pointops/functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 103,11 @@ def offset2batch(offset):
return (
torch.cat(
[
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
(
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
)
for i, o in enumerate(offset)
],
dim=0,
Expand Down
1 change: 1 addition & 0 deletions libs/pointops2/functions/pointops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@
The part of attention operations is written by Xin Lai.
Email: [email protected]
"""

from typing import Tuple

import torch
Expand Down
1 change: 0 additions & 1 deletion pointcept/datasets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,6 @@
Please cite our work if the code is helpful to you.
"""


from pointcept.utils.registry import Registry

DATASETS = Registry("datasets")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
"""
Preprocessing ArkitScenes
"""

import os
import argparse
import glob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 109,6 @@ def make2d(array, cols=None, dtype=None):


class PlyParseError(Exception):

"""
Raised when a PLY file cannot be parsed.
Expand Down Expand Up @@ -145,7 144,6 @@ def __repr__(self):


class PlyData(object):

"""
PLY file header and data.
Expand Down Expand Up @@ -361,7 359,6 @@ def _open_stream(stream, read_or_write):


class PlyElement(object):

"""
PLY file element.
Expand Down Expand Up @@ -702,7 699,6 @@ def __repr__(self):


class PlyProperty(object):

"""
PLY property description. This class is pure metadata; the data
itself is contained in PlyElement instances.
Expand Down Expand Up @@ -801,7 797,6 @@ def __repr__(self):


class PlyListProperty(PlyProperty):

"""
PLY list property description.
Expand Down
8 changes: 5 additions & 3 deletions pointcept/engines/hooks/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 178,11 @@ def after_epoch(self):
"state_dict": self.trainer.model.state_dict(),
"optimizer": self.trainer.optimizer.state_dict(),
"scheduler": self.trainer.scheduler.state_dict(),
"scaler": self.trainer.scaler.state_dict()
if self.trainer.cfg.enable_amp
else None,
"scaler": (
self.trainer.scaler.state_dict()
if self.trainer.cfg.enable_amp
else None
),
"best_metric_value": self.trainer.best_metric_value,
},
filename ".tmp",
Expand Down
6 changes: 3 additions & 3 deletions pointcept/models/octformer/octformer_v1m1_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 352,9 @@ def __init__(
qk_scale=qk_scale,
attn_drop=attn_drop,
proj_drop=proj_drop,
drop_path=drop_path[i]
if isinstance(drop_path, list)
else drop_path,
drop_path=(
drop_path[i] if isinstance(drop_path, list) else drop_path
),
nempty=nempty,
activation=activation,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@
Author: Xiaoyang Wu ([email protected])
Please cite our work if the code is helpful to you.
"""

from functools import partial
from collections import OrderedDict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@
Author: Xiaoyang Wu ([email protected])
Please cite our work if the code is helpful to you.
"""

from functools import partial
from collections import OrderedDict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@
Author: Xiaoyang Wu ([email protected])
Please cite our work if the code is helpful to you.
"""

from functools import partial
from copy import deepcopy
import math
Expand Down
8 changes: 5 additions & 3 deletions pointcept/models/sparse_unet/mink_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 22,11 @@ def offset2batch(offset):
return (
torch.cat(
[
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
(
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
)
for i, o in enumerate(offset)
],
dim=0,
Expand Down
72 changes: 38 additions & 34 deletions pointcept/models/sparse_unet/spconv_unet_v1m1_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 186,25 @@ def __init__(
OrderedDict(
[
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
)
for i in range(layers[len(channels) - s - 1])
]
Expand Down Expand Up @@ -377,23 379,25 @@ def __init__(
OrderedDict(
[
(
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
(
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
)
for i in range(layers[len(channels) - s - 1])
]
Expand Down
44 changes: 24 additions & 20 deletions pointcept/models/sparse_unet/spconv_unet_v1m2_bn_momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 26,11 @@ def offset2batch(offset):
return (
torch.cat(
[
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
(
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
)
for i, o in enumerate(offset)
],
dim=0,
Expand Down Expand Up @@ -203,23 205,25 @@ def __init__(
OrderedDict(
[
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
)
for i in range(layers[len(channels) - s - 1])
]
Expand Down
37 changes: 20 additions & 17 deletions pointcept/models/sparse_unet/spconv_unet_v1m3_pdnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@
Author: Xiaoyang Wu ([email protected])
Please cite our work if the code is helpful to you.
"""

from functools import partial
from collections import OrderedDict

Expand Down Expand Up @@ -328,23 329,25 @@ def __init__(
OrderedDict(
[
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
(
f"block{i}",
block(
dec_channels enc_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
if i == 0
else (
f"block{i}",
block(
dec_channels,
dec_channels,
norm_fn=norm_fn,
indice_key=f"subm{s}",
),
)
)
for i in range(layers[len(channels) - s - 1])
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 29,11 @@ def offset2batch(offset):
return (
torch.cat(
[
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
(
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
)
for i, o in enumerate(offset)
],
dim=0,
Expand Down Expand Up @@ -432,9 434,9 @@ def __init__(
rel_query=rel_query,
rel_key=rel_key,
rel_value=rel_value,
drop_path=drop_path[i]
if isinstance(drop_path, list)
else drop_path,
drop_path=(
drop_path[i] if isinstance(drop_path, list) else drop_path
),
mlp_ratio=mlp_ratio,
qkv_bias=qkv_bias,
qk_scale=qk_scale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 39,11 @@ def offset2batch(offset):
return (
torch.cat(
[
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
(
torch.tensor([i] * (o - offset[i - 1]))
if i > 0
else torch.tensor([i] * o)
)
for i, o in enumerate(offset)
],
dim=0,
Expand Down
1 change: 1 addition & 0 deletions pointcept/models/swin3d/mink_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""

import torch
import torch.nn as nn
import torch.nn.functional as F
Expand Down
Loading

0 comments on commit 72a7993

Please sign in to comment.