Skip to content

Conversation

FrancescoSaverioZuppichini
Copy link
Contributor

@FrancescoSaverioZuppichini FrancescoSaverioZuppichini commented Mar 16, 2022

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.

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.

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.

@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
@FrancescoSaverioZuppichini FrancescoSaverioZuppichini force-pushed the modeling_regnet branch 2 times, most recently from 303c1a6 to 45319dd Compare April 5, 2022 17:21
@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

FrancescoSaverioZuppichini commented Apr 7, 2022

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.

5 participants