Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sourcery-ai-bot
Copy link

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:

git fetch https://github.com/sourcery-ai-bot/pytorch-semseg master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Copy link
Author

@sourcery-ai-bot sourcery-ai-bot left a 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}")
Copy link
Author

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:

Comment on lines -84 to +95
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"]}'"""
Copy link
Author

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:

Comment on lines -223 to +221
print("RUNDIR: {}".format(logdir))
print(f"RUNDIR: {logdir}")
Copy link
Author

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:

Comment on lines -14 to -17
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
Copy link
Author

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:

file_path = os.path.join(logdir, "run_{}.log".format(ts))
file_path = os.path.join(logdir, f"run_{ts}.log")
Copy link
Author

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:

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}")
Copy link
Author

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:

os.path.basename(img_path)[:-15] + "gtFine_labelIds.png",
f"{os.path.basename(img_path)[:-15]}gtFine_labelIds.png",
Copy link
Author

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:

for l in range(0, self.n_classes):
for l in range(self.n_classes):
Copy link
Author

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:

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}")
Copy link
Author

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:

print("There are {} labels in the config file".format(len(labels)))
print(f"There are {len(labels)} labels in the config file")
Copy link
Author

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:

@hjhjb
Copy link

hjhjb commented Feb 7, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants