Image Classification
PyTorch
Safetensors
Transformers
English
resnet10
feature-extraction
jax-conversion
resnet
hil-serl
Lerobot
vision
custom_code
Instructions to use lilkm/resnet10 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lilkm/resnet10 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="lilkm/resnet10", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lilkm/resnet10", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload ResNet10
Browse files- config.json +6 -1
- modeling_resnet.py +9 -5
config.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
{
|
|
|
|
|
|
|
|
|
|
| 2 |
"auto_map": {
|
| 3 |
-
"AutoConfig": "configuration_resnet.ResNet10Config"
|
|
|
|
| 4 |
},
|
| 5 |
"depths": [
|
| 6 |
1,
|
|
@@ -8,6 +12,7 @@
|
|
| 8 |
1,
|
| 9 |
1
|
| 10 |
],
|
|
|
|
| 11 |
"embedding_size": 64,
|
| 12 |
"hidden_act": "relu",
|
| 13 |
"hidden_sizes": [
|
|
|
|
| 1 |
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ResNet10"
|
| 4 |
+
],
|
| 5 |
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_resnet.ResNet10Config",
|
| 7 |
+
"AutoModel": "modeling_resnet.ResNet10"
|
| 8 |
},
|
| 9 |
"depths": [
|
| 10 |
1,
|
|
|
|
| 12 |
1,
|
| 13 |
1
|
| 14 |
],
|
| 15 |
+
"dtype": "float32",
|
| 16 |
"embedding_size": 64,
|
| 17 |
"hidden_act": "relu",
|
| 18 |
"hidden_sizes": [
|
modeling_resnet.py
CHANGED
|
@@ -20,7 +20,7 @@ import torch.nn as nn
|
|
| 20 |
from torch import Tensor
|
| 21 |
from transformers import PreTrainedModel
|
| 22 |
from transformers.activations import ACT2FN
|
| 23 |
-
from transformers.modeling_outputs import
|
| 24 |
|
| 25 |
from .configuration_resnet import ResNet10Config
|
| 26 |
|
|
@@ -204,7 +204,9 @@ class Encoder(nn.Module):
|
|
| 204 |
)
|
| 205 |
)
|
| 206 |
|
| 207 |
-
def forward(
|
|
|
|
|
|
|
| 208 |
hidden_states: Optional[tuple[Tensor, ...]] = () if output_hidden_states else None
|
| 209 |
|
| 210 |
for stage in self.stages:
|
|
@@ -217,8 +219,8 @@ class Encoder(nn.Module):
|
|
| 217 |
hidden_states = hidden_states + (hidden_state,) # type: ignore
|
| 218 |
|
| 219 |
return BaseModelOutputWithPoolingAndNoAttention(
|
| 220 |
-
last_hidden_state=hidden_state,
|
| 221 |
-
hidden_states=hidden_states,
|
| 222 |
)
|
| 223 |
|
| 224 |
|
|
@@ -254,7 +256,9 @@ class ResNet10(PreTrainedModel):
|
|
| 254 |
else:
|
| 255 |
self.pooler = None
|
| 256 |
|
| 257 |
-
def forward(
|
|
|
|
|
|
|
| 258 |
output_hidden_states = (
|
| 259 |
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 260 |
)
|
|
|
|
| 20 |
from torch import Tensor
|
| 21 |
from transformers import PreTrainedModel
|
| 22 |
from transformers.activations import ACT2FN
|
| 23 |
+
from transformers.modeling_outputs import BaseModelOutputWithPoolingAndNoAttention
|
| 24 |
|
| 25 |
from .configuration_resnet import ResNet10Config
|
| 26 |
|
|
|
|
| 204 |
)
|
| 205 |
)
|
| 206 |
|
| 207 |
+
def forward(
|
| 208 |
+
self, hidden_state: Tensor, output_hidden_states: bool = False
|
| 209 |
+
) -> BaseModelOutputWithPoolingAndNoAttention:
|
| 210 |
hidden_states: Optional[tuple[Tensor, ...]] = () if output_hidden_states else None
|
| 211 |
|
| 212 |
for stage in self.stages:
|
|
|
|
| 219 |
hidden_states = hidden_states + (hidden_state,) # type: ignore
|
| 220 |
|
| 221 |
return BaseModelOutputWithPoolingAndNoAttention(
|
| 222 |
+
last_hidden_state=hidden_state, # type: ignore[arg-type]
|
| 223 |
+
hidden_states=hidden_states, # type: ignore[arg-type]
|
| 224 |
)
|
| 225 |
|
| 226 |
|
|
|
|
| 256 |
else:
|
| 257 |
self.pooler = None
|
| 258 |
|
| 259 |
+
def forward(
|
| 260 |
+
self, x: Tensor, output_hidden_states: Optional[bool] = None
|
| 261 |
+
) -> BaseModelOutputWithPoolingAndNoAttention:
|
| 262 |
output_hidden_states = (
|
| 263 |
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 264 |
)
|