jpterry commited on
Commit
b7faf40
·
1 Parent(s): db7592b

trying cached url again

Browse files
Files changed (1) hide show
  1. app.py +20 -15
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
- AutoConfig.register(model_loading_name, EfficientNetConfig)
275
- AutoModel.register(EfficientNetConfig, EfficientNetPreTrained)
 
 
 
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
- # model = EfficientNet(dropout=hparams.dropout,
284
- # num_channels=hparams.num_channels,
285
- # num_classes=hparams.num_classes,
286
- # size=hparams.size,
287
- # stochastic_depth_prob=hparams.stochastic_depth_prob,
288
- # width_mult=hparams.width_mult,
289
- # depth_mult=hparams.depth_mult,)
290
- # model_url = cached_download(hf_hub_url(model_loading_name, filename="pytorch_model.bin"))
291
  # print(model_url)
292
 
293
- # loaded = torch.load(model_url, map_location='cpu')
294
- # print(loaded)
295
 
296
- # model.load_state_dict(loaded)
297
- # print(model)
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()