Spaces:
Running
on
Zero
Running
on
Zero
2025-07-31 22:05 π
Browse files- models/clip_ebc/convnext.py +2 -1
- models/clip_ebc/mobileclip.py +2 -1
- models/clip_ebc/resnet.py +2 -1
- models/clip_ebc/vit.py +2 -1
- models/ebc/csrnet.py +1 -1
- models/ebc/hrnet.py +2 -1
- models/ebc/timm_models.py +2 -1
- models/ebc/vgg.py +8 -8
- models/ebc/vit.py +2 -1
models/clip_ebc/convnext.py
CHANGED
|
@@ -53,7 +53,8 @@ class ConvNeXt(nn.Module):
|
|
| 53 |
self.model_name, self.weight_name = model_name, weight_name
|
| 54 |
self.block_size = block_size
|
| 55 |
|
| 56 |
-
model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
|
|
|
| 57 |
|
| 58 |
self.adapter = adapter
|
| 59 |
if adapter:
|
|
|
|
| 53 |
self.model_name, self.weight_name = model_name, weight_name
|
| 54 |
self.block_size = block_size
|
| 55 |
|
| 56 |
+
# model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
| 57 |
+
model = open_clip.create_model(model_name=model_name, pretrained=False, load_weights=False, return_transform=False).visual
|
| 58 |
|
| 59 |
self.adapter = adapter
|
| 60 |
if adapter:
|
models/clip_ebc/mobileclip.py
CHANGED
|
@@ -41,7 +41,8 @@ class MobileCLIP(nn.Module):
|
|
| 41 |
self.model_name, self.weight_name = model_name, weight_name
|
| 42 |
self.block_size = block_size
|
| 43 |
|
| 44 |
-
model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
|
|
|
| 45 |
|
| 46 |
self.adapter = adapter
|
| 47 |
if adapter:
|
|
|
|
| 41 |
self.model_name, self.weight_name = model_name, weight_name
|
| 42 |
self.block_size = block_size
|
| 43 |
|
| 44 |
+
# model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
| 45 |
+
model = open_clip.create_model(model_name=model_name, pretrained=False, load_weights=False, return_transform=False).visual
|
| 46 |
|
| 47 |
self.adapter = adapter
|
| 48 |
if adapter:
|
models/clip_ebc/resnet.py
CHANGED
|
@@ -49,7 +49,8 @@ class ResNet(nn.Module):
|
|
| 49 |
self.model_name, self.weight_name = model_name, weight_name
|
| 50 |
self.block_size = block_size
|
| 51 |
|
| 52 |
-
model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
|
|
|
| 53 |
|
| 54 |
self.adapter = adapter
|
| 55 |
if adapter:
|
|
|
|
| 49 |
self.model_name, self.weight_name = model_name, weight_name
|
| 50 |
self.block_size = block_size
|
| 51 |
|
| 52 |
+
# model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
| 53 |
+
model = open_clip.create_model(model_name=model_name, pretrained=False, load_weights=False, return_transform=False).visual
|
| 54 |
|
| 55 |
self.adapter = adapter
|
| 56 |
if adapter:
|
models/clip_ebc/vit.py
CHANGED
|
@@ -95,7 +95,8 @@ class ViT(nn.Module):
|
|
| 95 |
self.vpt_drop = vpt_drop
|
| 96 |
self.adapter = adapter
|
| 97 |
|
| 98 |
-
model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
|
|
|
| 99 |
|
| 100 |
# Always freeze the parameters of the model
|
| 101 |
for param in model.parameters():
|
|
|
|
| 95 |
self.vpt_drop = vpt_drop
|
| 96 |
self.adapter = adapter
|
| 97 |
|
| 98 |
+
# model = open_clip.create_model_from_pretrained(model_name, weight_name, return_transform=False).visual
|
| 99 |
+
model = open_clip.create_model(model_name=model_name, pretrained=False, load_weights=False, return_transform=False).visual
|
| 100 |
|
| 101 |
# Always freeze the parameters of the model
|
| 102 |
for param in model.parameters():
|
models/ebc/csrnet.py
CHANGED
|
@@ -27,7 +27,7 @@ class CSRNet(nn.Module):
|
|
| 27 |
self.model_name = model_name
|
| 28 |
|
| 29 |
vgg = VGG(make_vgg_layers(encoder_cfg, in_channels=3, batch_norm="bn" in model_name, dilation=1))
|
| 30 |
-
vgg.load_state_dict(load_state_dict_from_url(vgg_urls[model_name]), strict=False)
|
| 31 |
self.encoder = vgg.features
|
| 32 |
self.encoder_reduction = 8
|
| 33 |
self.encoder_channels = 512
|
|
|
|
| 27 |
self.model_name = model_name
|
| 28 |
|
| 29 |
vgg = VGG(make_vgg_layers(encoder_cfg, in_channels=3, batch_norm="bn" in model_name, dilation=1))
|
| 30 |
+
# vgg.load_state_dict(load_state_dict_from_url(vgg_urls[model_name]), strict=False)
|
| 31 |
self.encoder = vgg.features
|
| 32 |
self.encoder_reduction = 8
|
| 33 |
self.encoder_channels = 512
|
models/ebc/hrnet.py
CHANGED
|
@@ -27,7 +27,8 @@ class HRNet(nn.Module):
|
|
| 27 |
self.model_name = model_name
|
| 28 |
self.block_size = block_size if block_size is not None else 32
|
| 29 |
|
| 30 |
-
model = timm.create_model(model_name, pretrained=True)
|
|
|
|
| 31 |
|
| 32 |
self.conv1 = model.conv1
|
| 33 |
self.bn1 = model.bn1
|
|
|
|
| 27 |
self.model_name = model_name
|
| 28 |
self.block_size = block_size if block_size is not None else 32
|
| 29 |
|
| 30 |
+
# model = timm.create_model(model_name, pretrained=True)
|
| 31 |
+
model = timm.create_model(model_name, pretrained=False)
|
| 32 |
|
| 33 |
self.conv1 = model.conv1
|
| 34 |
self.bn1 = model.bn1
|
models/ebc/timm_models.py
CHANGED
|
@@ -151,7 +151,8 @@ class TIMMModel(nn.Module):
|
|
| 151 |
assert model_name in supported_models, f"Backbone {model_name} not supported. Supported models are {supported_models}"
|
| 152 |
assert block_size is None or block_size in [8, 16, 32], f"Block size should be one of [8, 16, 32], but got {block_size}."
|
| 153 |
self.model_name = model_name
|
| 154 |
-
self.encoder = create_model(model_name, pretrained=True, features_only=True, out_indices=[-1])
|
|
|
|
| 155 |
self.encoder_channels = self.encoder.feature_info.channels()[-1]
|
| 156 |
self.encoder_reduction = self.encoder.feature_info.reduction()[-1]
|
| 157 |
self.block_size = block_size if block_size is not None else self.encoder_reduction
|
|
|
|
| 151 |
assert model_name in supported_models, f"Backbone {model_name} not supported. Supported models are {supported_models}"
|
| 152 |
assert block_size is None or block_size in [8, 16, 32], f"Block size should be one of [8, 16, 32], but got {block_size}."
|
| 153 |
self.model_name = model_name
|
| 154 |
+
# self.encoder = create_model(model_name, pretrained=True, features_only=True, out_indices=[-1])
|
| 155 |
+
self.encoder = create_model(model_name, pretrained=False, features_only=True, out_indices=[-1])
|
| 156 |
self.encoder_channels = self.encoder.feature_info.channels()[-1]
|
| 157 |
self.encoder_reduction = self.encoder.feature_info.reduction()[-1]
|
| 158 |
self.block_size = block_size if block_size is not None else self.encoder_reduction
|
models/ebc/vgg.py
CHANGED
|
@@ -210,42 +210,42 @@ class VGG(nn.Module):
|
|
| 210 |
|
| 211 |
def vgg11() -> VGG:
|
| 212 |
model = VGG(make_vgg_layers(vgg_cfgs["A"]))
|
| 213 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg11"]), strict=False)
|
| 214 |
return model
|
| 215 |
|
| 216 |
def vgg11_bn() -> VGG:
|
| 217 |
model = VGG(make_vgg_layers(vgg_cfgs["A"], batch_norm=True))
|
| 218 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg11_bn"]), strict=False)
|
| 219 |
return model
|
| 220 |
|
| 221 |
def vgg13() -> VGG:
|
| 222 |
model = VGG(make_vgg_layers(vgg_cfgs["B"]))
|
| 223 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg13"]), strict=False)
|
| 224 |
return model
|
| 225 |
|
| 226 |
def vgg13_bn() -> VGG:
|
| 227 |
model = VGG(make_vgg_layers(vgg_cfgs["B"], batch_norm=True))
|
| 228 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg13_bn"]), strict=False)
|
| 229 |
return model
|
| 230 |
|
| 231 |
def vgg16() -> VGG:
|
| 232 |
model = VGG(make_vgg_layers(vgg_cfgs["D"]))
|
| 233 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg16"]), strict=False)
|
| 234 |
return model
|
| 235 |
|
| 236 |
def vgg16_bn() -> VGG:
|
| 237 |
model = VGG(make_vgg_layers(vgg_cfgs["D"], batch_norm=True))
|
| 238 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg16_bn"]), strict=False)
|
| 239 |
return model
|
| 240 |
|
| 241 |
def vgg19() -> VGG:
|
| 242 |
model = VGG(make_vgg_layers(vgg_cfgs["E"]))
|
| 243 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg19"]), strict=False)
|
| 244 |
return model
|
| 245 |
|
| 246 |
def vgg19_bn() -> VGG:
|
| 247 |
model = VGG(make_vgg_layers(vgg_cfgs["E"], batch_norm=True))
|
| 248 |
-
model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg19_bn"]), strict=False)
|
| 249 |
return model
|
| 250 |
|
| 251 |
def _vgg_encoder(model_name: str, block_size: Optional[int] = None, norm: str = "none", act: str = "none") -> VGGEncoder:
|
|
|
|
| 210 |
|
| 211 |
def vgg11() -> VGG:
|
| 212 |
model = VGG(make_vgg_layers(vgg_cfgs["A"]))
|
| 213 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg11"]), strict=False)
|
| 214 |
return model
|
| 215 |
|
| 216 |
def vgg11_bn() -> VGG:
|
| 217 |
model = VGG(make_vgg_layers(vgg_cfgs["A"], batch_norm=True))
|
| 218 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg11_bn"]), strict=False)
|
| 219 |
return model
|
| 220 |
|
| 221 |
def vgg13() -> VGG:
|
| 222 |
model = VGG(make_vgg_layers(vgg_cfgs["B"]))
|
| 223 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg13"]), strict=False)
|
| 224 |
return model
|
| 225 |
|
| 226 |
def vgg13_bn() -> VGG:
|
| 227 |
model = VGG(make_vgg_layers(vgg_cfgs["B"], batch_norm=True))
|
| 228 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg13_bn"]), strict=False)
|
| 229 |
return model
|
| 230 |
|
| 231 |
def vgg16() -> VGG:
|
| 232 |
model = VGG(make_vgg_layers(vgg_cfgs["D"]))
|
| 233 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg16"]), strict=False)
|
| 234 |
return model
|
| 235 |
|
| 236 |
def vgg16_bn() -> VGG:
|
| 237 |
model = VGG(make_vgg_layers(vgg_cfgs["D"], batch_norm=True))
|
| 238 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg16_bn"]), strict=False)
|
| 239 |
return model
|
| 240 |
|
| 241 |
def vgg19() -> VGG:
|
| 242 |
model = VGG(make_vgg_layers(vgg_cfgs["E"]))
|
| 243 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg19"]), strict=False)
|
| 244 |
return model
|
| 245 |
|
| 246 |
def vgg19_bn() -> VGG:
|
| 247 |
model = VGG(make_vgg_layers(vgg_cfgs["E"], batch_norm=True))
|
| 248 |
+
# model.load_state_dict(state_dict=load_state_dict_from_url(vgg_urls["vgg19_bn"]), strict=False)
|
| 249 |
return model
|
| 250 |
|
| 251 |
def _vgg_encoder(model_name: str, block_size: Optional[int] = None, norm: str = "none", act: str = "none") -> VGGEncoder:
|
models/ebc/vit.py
CHANGED
|
@@ -86,7 +86,8 @@ class ViT(nn.Module):
|
|
| 86 |
self.num_vpt = num_vpt
|
| 87 |
self.vpt_drop = vpt_drop
|
| 88 |
|
| 89 |
-
model = timm.create_model(model_name, pretrained=True)
|
|
|
|
| 90 |
|
| 91 |
self.input_size = input_size if input_size is not None else model.patch_embed.img_size
|
| 92 |
self.pretrain_size = model.patch_embed.img_size
|
|
|
|
| 86 |
self.num_vpt = num_vpt
|
| 87 |
self.vpt_drop = vpt_drop
|
| 88 |
|
| 89 |
+
# model = timm.create_model(model_name, pretrained=True)
|
| 90 |
+
model = timm.create_model(model_name, pretrained=False)
|
| 91 |
|
| 92 |
self.input_size = input_size if input_size is not None else model.patch_embed.img_size
|
| 93 |
self.pretrain_size = model.patch_embed.img_size
|