Sourcery Starbot ⭐ refactored meetps/pytorch-semseg#264
Sourcery Starbot ⭐ refactored meetps/pytorch-semseg#264SourceryAI wants to merge 1 commit intomeetps:masterfrom
Conversation
SourceryAI
left a comment
There was a problem hiding this comment.
Due to GitHub API limits, only the first 60 comments can be shown.
|
|
||
| # Setup image | ||
| 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.
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.
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.
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.
Function runningScore._fast_hist refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| ts = str(datetime.datetime.now()).split(".")[0].replace(" ", "_") | ||
| ts = ts.replace(":", "_").replace("-", "_") | ||
| 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.
Function get_logger refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
|
|
||
| if not self.files[split]: | ||
| 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.
Function cityscapesLoader.__init__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| self.annotations_base, | ||
| img_path.split(os.sep)[-2], | ||
| 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.
Function cityscapesLoader.__getitem__ refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| g = temp.copy() | ||
| b = temp.copy() | ||
| for l in range(0, self.n_classes): | ||
| for l in range(self.n_classes): |
There was a problem hiding this comment.
Function cityscapesLoader.decode_segmap refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range)
|
|
||
| if not self.files[split]: | ||
| 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.
Function mapillaryVistasLoader.__init__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| class_ids = [] | ||
| class_colors = [] | ||
| 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.
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
masterbranch, then run: