Skip to content

Add new CSPNet preset and add manual padding. #2212

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sachinprasadhs
Copy link
Collaborator

  • Added Zero padding to maintain same padding across all backends when strides > 1
  • Use manual padding with -inf instead of zeropadding before maxpooling to handle edge case scenario to consider negative values from Leaky Relu activation output.
  • Added 3 more presets and it's timm conversion script.
  • Uploaded all the new weights to Kaggle as mentioned in the preset configuration file.

@sachinprasadhs sachinprasadhs added the kokoro:force-run Runs Tests on GPU label Apr 11, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Apr 11, 2025
@sachinprasadhs sachinprasadhs added the kokoro:force-run Runs Tests on GPU label Apr 11, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Apr 11, 2025
@sachinprasadhs sachinprasadhs added the kokoro:force-run Runs Tests on GPU label Apr 14, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Apr 14, 2025
@sachinprasadhs sachinprasadhs changed the title Add new preset and add manual padding. Add new CSPNet preset and add manual padding. Apr 15, 2025
Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sachinprasadhs code look good except for one minor comment. Are we sure this works with the older cspnet presets?

self.converter = convert_resnet
elif "csp" in architecture:
elif architecture in (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just flip the order of the if and else if? This will be hard to maintain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe better would be to switch all these checks to architecture.startswith("restnet").

You would need two starts with, darknet and csp, joined with an and I guess

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, this would be lot better, made the changes. Thank you.

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one final comment.

@@ -16,9 +16,9 @@ class TimmPresetLoader(PresetLoader):
def __init__(self, preset, config):
super().__init__(preset, config)
architecture = self.config["architecture"]
if "resnet" in architecture:
if architecture.startswith("resnet"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you actually make the startswith change for every elif below? I think it will be a safer and less confusing way to check this overall.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

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

Successfully merging this pull request may close these issues.

3 participants