Skip to content

Commit

Permalink
Fix other Ruff complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jul 19, 2023
1 parent a5eb75d commit 67d4f69
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def init_wandb(save_dir, opt, config, group_name, name_str):
# TODO change once leaving "swiffer" config directory
try:
group_name = nowname.split(now)[-1].split("-")[1]
except:
except Exception:
group_name = nowname
default_logger_cfg["params"]["group"] = group_name
init_wandb(
Expand Down Expand Up @@ -842,7 +842,7 @@ def init_wandb(save_dir, opt, config, group_name, name_str):
print(
f"{k}, {data.datasets[k].__class__.__name__}, {len(data.datasets[k])}"
)
except:
except Exception:
print("datasets not yet initialized.")

# configure learning rate
Expand Down
2 changes: 1 addition & 1 deletion scripts/demo/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def decode(self, cv2Image, method="dwtDct", **configs):
bits = embed.decode(cv2Image)
return self.reconstruct(bits)

except:
except Exception:
raise e


Expand Down
2 changes: 1 addition & 1 deletion scripts/demo/streamlit_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def do_sample(
if isinstance(batch[key], torch.Tensor):
print(key, batch[key].shape)
elif isinstance(batch[key], list):
print(key, [len(l) for l in batch[key]])
print(key, [len(lst) for lst in batch[key]])
else:
print(key, batch[key])
c, uc = model.conditioner.get_unconditional_conditioning(
Expand Down
2 changes: 1 addition & 1 deletion sgm/modules/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import xformers.ops

XFORMERS_IS_AVAILABLE = True
except:
except Exception:
XFORMERS_IS_AVAILABLE = False
print("no module 'xformers'. Processing without...")

Expand Down
2 changes: 1 addition & 1 deletion sgm/modules/diffusionmodules/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import xformers.ops

XFORMERS_IS_AVAILABLE = True
except:
except Exception:
XFORMERS_IS_AVAILABLE = False
print("no module 'xformers'. Processing without...")

Expand Down
3 changes: 2 additions & 1 deletion sgm/modules/diffusionmodules/openaimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ def __init__(

self.use_fairscale_checkpoint = False
checkpoint_wrapper_fn = (
partial(checkpoint_wrapper, offload_to_cpu=offload_to_cpu)
# TODO: this can't work since `checkpoint_wrapper` is not defined
partial(checkpoint_wrapper, offload_to_cpu=offload_to_cpu) # noqa: F821
if self.use_fairscale_checkpoint
else lambda x: x
)
Expand Down
2 changes: 1 addition & 1 deletion sgm/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_string_from_tuple(s):
return t[0]
else:
pass
except:
except Exception:
pass
return s

Expand Down

0 comments on commit 67d4f69

Please sign in to comment.