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

RegNet #16188

Merged
merged 51 commits into from Apr 7, 2022
Merged

RegNet #16188

merged 51 commits into from Apr 7, 2022

Conversation

FrancescoSaverioZuppichini
Copy link
Contributor

What does this PR do?

This WIP PR adds RegNet.

Currently, the model can be used as follows

from transformers import  RegNetConfig, RegNetForImageClassification
import requests
from io import BytesIO
res = requests.get('https://github.com/huggingface/transformers/blob/master/tests/fixtures/tests_samples/COCO/000000039769.png?raw=true')
image = Image.open(BytesIO(res.content))

feature_extractor = AutoFeatureExtractor.from_pretrained("zuppif/regnet-y-040")
model = RegNetForImageClassification.from_pretrained("zuppif/regnet-y-040").eval()

inputs = feature_extractor(image, return_tensors="pt")
outputs = model(**inputs)
print(model.config.id2label[torch.argmax(outputs.logits).item()])
# tiger cat

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 16, 2022

The documentation is not available anymore as the PR was closed or merged.

docs/source/index.mdx Outdated Show resolved Hide resolved
depths (`List[int]`, *optional*, defaults to `[3, 4, 6, 3]`):
Depth (number of layers) for each stage.
layer_type (`str`, *optional*, defaults to `"bottleneck"`):
The layer to use, it can be either `"x" or `"y"` (like `x` but with squeeze and excitation).
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify this?

Copy link
Contributor

Choose a reason for hiding this comment

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

What is x?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the doc

Copy link
Collaborator

Choose a reason for hiding this comment

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

The default needs to be update (it's "y" not "bottleneck") and what "x" and "y" mean should be detailed here in the docstring for people who did not read the paper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, let me know if it is better

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for working on this new model. I left a few comments, but it's in good shape to be merged.

docs/source/_toctree.yml Outdated Show resolved Hide resolved
depths (`List[int]`, *optional*, defaults to `[3, 4, 6, 3]`):
Depth (number of layers) for each stage.
layer_type (`str`, *optional*, defaults to `"bottleneck"`):
The layer to use, it can be either `"x" or `"y"` (like `x` but with squeeze and excitation).
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default needs to be update (it's "y" not "bottleneck") and what "x" and "y" mean should be detailed here in the docstring for people who did not read the paper.

src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
src/transformers/models/regnet/modeling_regnet.py Outdated Show resolved Hide resolved
@FrancescoSaverioZuppichini
Copy link
Contributor Author

Updated the codebase to use config when is possible. I had to update ResNetModel as well to make make fixup happy :)

@FrancescoSaverioZuppichini FrancescoSaverioZuppichini mentioned this pull request Mar 31, 2022
1 task
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/transformers/models/resnet/modeling_resnet.py Outdated Show resolved Hide resolved
@FrancescoSaverioZuppichini
Copy link
Contributor Author

Conversion script for the 10B regnet model added + needed changes inside PretrainedModel._load_pretrained_model_low_mem

@FrancescoSaverioZuppichini
Copy link
Contributor Author

Thanks to all reviewers, I've rebased and updated the code accordingly

@FrancescoSaverioZuppichini FrancescoSaverioZuppichini deleted the modeling_regnet branch April 7, 2022 19:58
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

5 participants