Image Classification
Transformers
Safetensors
nula
computer-vision
cnn
cifar10
adversarial-robustness
stress-test
downsampling
anti-aliasing
custom_code
Instructions to use MamaPearl/nula-cifar10-robust-v0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MamaPearl/nula-cifar10-robust-v0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="MamaPearl/nula-cifar10-robust-v0", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained("MamaPearl/nula-cifar10-robust-v0", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update modeling_nula.py
Browse files- modeling_nula.py +4 -4
modeling_nula.py
CHANGED
|
@@ -55,7 +55,7 @@ class SEBlock(nn.Module):
|
|
| 55 |
return x * z
|
| 56 |
|
| 57 |
|
| 58 |
-
class
|
| 59 |
def __init__(self, in_ch, out_ch, downsample=False, use_se=False, se_reduction=16):
|
| 60 |
super().__init__()
|
| 61 |
stride = 1
|
|
@@ -122,9 +122,9 @@ class NulaForImageClassification(PreTrainedModel):
|
|
| 122 |
self.stem_bn = nn.BatchNorm2d(c1)
|
| 123 |
self.stem_act = nn.SiLU(inplace=True)
|
| 124 |
|
| 125 |
-
self.s1 =
|
| 126 |
-
self.s2 =
|
| 127 |
-
self.s3 =
|
| 128 |
self.global_pool = nn.AdaptiveAvgPool2d((1,1))
|
| 129 |
self.head = nn.Sequential(
|
| 130 |
nn.Linear(c3, config.classifier_hidden_dim),
|
|
|
|
| 55 |
return x * z
|
| 56 |
|
| 57 |
|
| 58 |
+
class NulaConvBlock(nn.Module):
|
| 59 |
def __init__(self, in_ch, out_ch, downsample=False, use_se=False, se_reduction=16):
|
| 60 |
super().__init__()
|
| 61 |
stride = 1
|
|
|
|
| 122 |
self.stem_bn = nn.BatchNorm2d(c1)
|
| 123 |
self.stem_act = nn.SiLU(inplace=True)
|
| 124 |
|
| 125 |
+
self.s1 = NulaConvBlock(c1, c1, False, config.use_se, config.se_reduction)
|
| 126 |
+
self.s2 = NulaConvBlock(c1, c2, True, config.use_se, config.se_reduction)
|
| 127 |
+
self.s3 = NulaConvBlock(c2, c3, True, config.use_se, config.se_reduction)
|
| 128 |
self.global_pool = nn.AdaptiveAvgPool2d((1,1))
|
| 129 |
self.head = nn.Sequential(
|
| 130 |
nn.Linear(c3, config.classifier_hidden_dim),
|