trying cached url again
Browse files
app.py
CHANGED
@@ -127,6 +127,8 @@ def get_activations(model, image: list, model_name: str,
|
|
127 |
break
|
128 |
output = model(image).detach().cpu().numpy()
|
129 |
|
|
|
|
|
130 |
image = image.detach().cpu().numpy()
|
131 |
output_1 = layer_outputs[activation_indices[model_name][0]].detach().cpu().numpy()
|
132 |
output_2 = layer_outputs[activation_indices[model_name][1]].detach().cpu().numpy()
|
@@ -271,30 +273,33 @@ def predict_and_analyze(model_name, num_channels, dim, input_channel, image):
|
|
271 |
# width_mult=hparams.width_mult,
|
272 |
# depth_mult=hparams.depth_mult,)
|
273 |
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
276 |
# config = EfficientNetConfig.from_pretrained(model_loading_name)
|
277 |
|
278 |
# model = EfficientNetPreTrained.from_pretrained(model_loading_name)
|
279 |
# model = AutoModel.from_pretrained(model_loading_name, trust_remote_code=True)
|
280 |
|
281 |
-
model = AutoModel.from_pretrained(model_path + model_loading_name)
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
# print(model_url)
|
292 |
|
293 |
-
|
294 |
-
|
295 |
|
296 |
-
|
297 |
-
|
298 |
|
299 |
# model = EfficientNetPreTrained(config)
|
300 |
# config.register_for_auto_class()
|
|
|
127 |
break
|
128 |
output = model(image).detach().cpu().numpy()
|
129 |
|
130 |
+
print(model(image), model.model(image))
|
131 |
+
|
132 |
image = image.detach().cpu().numpy()
|
133 |
output_1 = layer_outputs[activation_indices[model_name][0]].detach().cpu().numpy()
|
134 |
output_2 = layer_outputs[activation_indices[model_name][1]].detach().cpu().numpy()
|
|
|
273 |
# width_mult=hparams.width_mult,
|
274 |
# depth_mult=hparams.depth_mult,)
|
275 |
|
276 |
+
###### kinda working #####
|
277 |
+
# AutoConfig.register(model_loading_name, EfficientNetConfig)
|
278 |
+
# AutoModel.register(EfficientNetConfig, EfficientNetPreTrained)
|
279 |
+
# model = AutoModel.from_pretrained(model_path + model_loading_name)
|
280 |
+
|
281 |
# config = EfficientNetConfig.from_pretrained(model_loading_name)
|
282 |
|
283 |
# model = EfficientNetPreTrained.from_pretrained(model_loading_name)
|
284 |
# model = AutoModel.from_pretrained(model_loading_name, trust_remote_code=True)
|
285 |
|
286 |
+
# model = AutoModel.from_pretrained(model_path + model_loading_name)
|
287 |
|
288 |
+
model = EfficientNet(dropout=hparams.dropout,
|
289 |
+
num_channels=hparams.num_channels,
|
290 |
+
num_classes=hparams.num_classes,
|
291 |
+
size=hparams.size,
|
292 |
+
stochastic_depth_prob=hparams.stochastic_depth_prob,
|
293 |
+
width_mult=hparams.width_mult,
|
294 |
+
depth_mult=hparams.depth_mult,)
|
295 |
+
model_url = cached_download(hf_hub_url(model_loading_name, filename="pytorch_model.bin"))
|
296 |
# print(model_url)
|
297 |
|
298 |
+
loaded = torch.load(model_url, map_location='cpu')
|
299 |
+
print(loaded)
|
300 |
|
301 |
+
model.load_state_dict(loaded)
|
302 |
+
print(model)
|
303 |
|
304 |
# model = EfficientNetPreTrained(config)
|
305 |
# config.register_for_auto_class()
|