-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery Starbot ⭐ refactored meetps/pytorch-semseg #264
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to GitHub API limits, only the first 60 comments can be shown.
print("Read Input Image from : {}".format(args.img_path)) | ||
print(f"Read Input Image from : {args.img_path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function test
refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
logger.info("Using optimizer {}".format(optimizer)) | ||
logger.info(f"Using optimizer {optimizer}") | ||
|
||
scheduler = get_scheduler(optimizer, cfg["training"]["lr_schedule"]) | ||
|
||
loss_fn = get_loss_function(cfg) | ||
logger.info("Using loss {}".format(loss_fn)) | ||
logger.info(f"Using loss {loss_fn}") | ||
|
||
start_iter = 0 | ||
if cfg["training"]["resume"] is not None: | ||
if os.path.isfile(cfg["training"]["resume"]): | ||
logger.info( | ||
"Loading model and optimizer from checkpoint '{}'".format(cfg["training"]["resume"]) | ||
f"""Loading model and optimizer from checkpoint '{cfg["training"]["resume"]}'""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function train
refactored with the following changes:
- Replace call to format with f-string [×10] (
use-fstring-for-formatting
) - Use previously assigned local variable (
use-assigned-variable
)
print("RUNDIR: {}".format(logdir)) | ||
print(f"RUNDIR: {logdir}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 223-223
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
hist = np.bincount( | ||
n_class * label_true[mask].astype(int) + label_pred[mask], minlength=n_class ** 2 | ||
return np.bincount( | ||
n_class * label_true[mask].astype(int) + label_pred[mask], | ||
minlength=n_class**2, | ||
).reshape(n_class, n_class) | ||
return hist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function runningScore._fast_hist
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
file_path = os.path.join(logdir, "run_{}.log".format(ts)) | ||
file_path = os.path.join(logdir, f"run_{ts}.log") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_logger
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
raise Exception("No files for split=[%s] found in %s" % (split, self.images_base)) | ||
raise Exception(f"No files for split=[{split}] found in {self.images_base}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function cityscapesLoader.__init__
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
os.path.basename(img_path)[:-15] + "gtFine_labelIds.png", | ||
f"{os.path.basename(img_path)[:-15]}gtFine_labelIds.png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function cityscapesLoader.__getitem__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
for l in range(0, self.n_classes): | ||
for l in range(self.n_classes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function cityscapesLoader.decode_segmap
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
raise Exception("No files for split=[%s] found in %s" % (split, self.images_base)) | ||
raise Exception(f"No files for split=[{split}] found in {self.images_base}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function mapillaryVistasLoader.__init__
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("There are {} labels in the config file".format(len(labels))) | ||
print(f"There are {len(labels)} labels in the config file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function mapillaryVistasLoader.parse_config
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
我已收到,谢谢
|
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: