Instructions to use Mamba824/custom_resnet50d with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Mamba824/custom_resnet50d with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Mamba824/custom_resnet50d", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Mamba824/custom_resnet50d", trust_remote_code=True) model = AutoModelForImageClassification.from_pretrained("Mamba824/custom_resnet50d", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
| from transformers import PretrainedConfig | |
| from typing import List | |
| class ResnetConfig(PretrainedConfig): | |
| model_type = "resnet" | |
| def __init__( | |
| self, | |
| block_type="bottleneck", | |
| layers: list[int] = [3, 4, 6, 3], | |
| num_classes: int = 1000, | |
| input_channels: int = 3, | |
| cardinality: int = 1, | |
| base_width: int = 64, | |
| stem_width: int = 64, | |
| stem_type: str = "", | |
| avg_down: bool = False, | |
| **kwargs, | |
| ): | |
| if block_type not in ["basic", "bottleneck"]: | |
| raise ValueError(f"`block_type` must be 'basic' or bottleneck', got {block_type}.") | |
| if stem_type not in ["", "deep", "deep-tiered"]: | |
| raise ValueError(f"`stem_type` must be '', 'deep' or 'deep-tiered', got {stem_type}.") | |
| self.block_type = block_type | |
| self.layers = layers | |
| self.num_classes = num_classes | |
| self.input_channels = input_channels | |
| self.cardinality = cardinality | |
| self.base_width = base_width | |
| self.stem_width = stem_width | |
| self.stem_type = stem_type | |
| self.avg_down = avg_down | |
| super().__init__(**kwargs) | |
| resnet50d_config = ResnetConfig(block_type="bottleneck", stem_width=32, stem_type="deep", | |
| avg_down=True) | |
| resnet50d_config.save_pretrained("custom-resnet") | |
| resnet50d_config = ResnetConfig.from_pretrained("custom-resnet") | |