Skip to content

Sourcery Starbot ⭐ refactored meetps/pytorch-semseg - #264

Open
SourceryAI wants to merge 1 commit into
meetps:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored meetps/pytorch-semseg#264
SourceryAI wants to merge 1 commit into
meetps:masterfrom
SourceryAI:master

Conversation

@SourceryAI

Copy link
Copy Markdown

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^

@SourceryAI SourceryAI left a comment

Copy link
Copy Markdown
Author

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.

Comment thread test.py

# Setup image
print("Read Input Image from : {}".format(args.img_path))
print(f"Read Input Image from : {args.img_path}")

Copy link
Copy Markdown
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 thread train.py
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
Copy Markdown
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 thread train.py
Comment on lines -223 to +221
print("RUNDIR: {}".format(logdir))
print(f"RUNDIR: {logdir}")

Copy link
Copy Markdown
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 thread ptsemseg/metrics.py
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
Copy Markdown
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:

Comment thread ptsemseg/utils.py
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")

Copy link
Copy Markdown
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:


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}")

Copy link
Copy Markdown
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:

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",

Copy link
Copy Markdown
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:

g = temp.copy()
b = temp.copy()
for l in range(0, self.n_classes):
for l in range(self.n_classes):

Copy link
Copy Markdown
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:


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}")

Copy link
Copy Markdown
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:

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")

Copy link
Copy Markdown
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

hjhjb commented Feb 7, 2023 via email

Copy link
Copy Markdown

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.

2 participants