Skip to content

Commit

Permalink
Fixing format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqwang committed Oct 24, 2021
1 parent 9f04811 commit 582d5e5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion yolort/models/darknetv5.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _darknetv5(arch: str, pretrained: bool, progress: bool, *args: Any, **kwargs
if pretrained:
model_url = model_urls[arch]
if model_url is None:
raise NotImplementedError("pretrained {} is not supported as of now".format(arch))
raise NotImplementedError(f"pretrained {arch} is not supported as of now")
else:
state_dict = load_state_dict_from_url(model_url, progress=progress)
model.load_state_dict(state_dict)
Expand Down
4 changes: 2 additions & 2 deletions yolort/models/darknetv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
) -> None:
super().__init__()

assert version == "r4.0", ("Currently the module version used in DarkNetV6 is r4.0",)
assert version == "r4.0", "Currently the module version used in DarkNetV6 is r4.0."

if block is None:
block = C3
Expand Down Expand Up @@ -135,7 +135,7 @@ def _darknetv6(arch: str, pretrained: bool, progress: bool, *args: Any, **kwargs
if pretrained:
model_url = model_urls[arch]
if model_url is None:
raise NotImplementedError("pretrained {} is not supported as of now".format(arch))
raise NotImplementedError(f"pretrained {arch} is not supported as of now")
else:
state_dict = load_state_dict_from_url(model_url, progress=progress)
model.load_state_dict(state_dict)
Expand Down
4 changes: 2 additions & 2 deletions yolort/models/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def forward(

if image.dim() != 3:
raise ValueError(
"images is expected to be a list of 3d tensors "
"of shape [C, H, W], got {}".format(image.shape)
"images is expected to be a list of 3d tensors of "
f"shape [C, H, W], but got '{image.shape}'."
)

image, target_index = self.resize(image, target_index)
Expand Down
4 changes: 2 additions & 2 deletions yolort/v5/utils/autoanchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def metric(k): # compute metric
"to use these anchors in the future."
)
else:
print(f"{prefix}Original anchors better than new anchors. " "Proceeding with original anchors.")
print(f"{prefix}Original anchors better than new anchors. Proceeding with original anchors.")
print("") # newline


Expand Down Expand Up @@ -148,7 +148,7 @@ def print_results(k):
s = wh.std(0) # sigmas for whitening
k, dist = kmeans(wh / s, n, iter=30) # points, mean distance
assert len(k) == n, (
f"{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points " f"but returned only {len(k)}"
f"{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}"
)
k *= s
wh = torch.tensor(wh, dtype=torch.float32) # filtered
Expand Down
2 changes: 1 addition & 1 deletion yolort/v5/utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def __init__(
if cache["msgs"]:
logging.info("\n".join(cache["msgs"])) # display warnings
assert nf > 0 or not augment, (
f"{prefix}No labels in {cache_path}. " f"Can not train without labels. See {HELP_URL}"
f"{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}"
)

# Read cache
Expand Down
4 changes: 2 additions & 2 deletions yolort/v5/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def check_img_size(imgsz, s=32, floor=0):
else: # list i.e. img_size=[640, 480]
new_size = [max(make_divisible(x, int(s)), floor) for x in imgsz]
if new_size != imgsz:
print(f"WARNING: --img-size {imgsz} must be multiple of " f"max stride {s}, updating to {new_size}")
print(f"WARNING: --img-size {imgsz} must be multiple of max stride {s}, updating to {new_size}")
return new_size


Expand Down Expand Up @@ -516,7 +516,7 @@ def non_max_suppression(

# Checks
assert 0 <= conf_thres <= 1, (
f"Invalid Confidence threshold {conf_thres}, " "valid values are between 0.0 and 1.0"
f"Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0"
)
assert 0 <= iou_thres <= 1, f"Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0"

Expand Down
4 changes: 2 additions & 2 deletions yolort/v5/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def select_device(device="", batch_size=None):
for i, d in enumerate(devices):
p = torch.cuda.get_device_properties(i)
# bytes to MB
s += f"{'' if i == 0 else space}CUDA:{d} ({p.name}, " f"{p.total_memory / 1024 ** 2}MB)\n"
s += f"{'' if i == 0 else space}CUDA:{d} ({p.name}, {p.total_memory / 1024 ** 2}MB)\n"
else:
s += "CPU\n"

Expand Down Expand Up @@ -309,7 +309,7 @@ def model_info(model, verbose=False, img_size=640):
fs = ""

LOGGER.info(
f"Model Summary: {len(list(model.modules()))} " f"layers, {n_p} parameters, {n_g} gradients{fs}"
f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}"
)


Expand Down

0 comments on commit 582d5e5

Please sign in to comment.