Spaces:
Build error
Build error
doing create_a_model method
Browse files
app.py
CHANGED
|
@@ -203,7 +203,7 @@ def predict_and_analyze(model_name, num_channels, dim, input_channel, image):
|
|
| 203 |
print("Data loaded")
|
| 204 |
|
| 205 |
print("Loading model")
|
| 206 |
-
model_loading_name = "%s_%i_planet_detection" % (model_name, num_channels)
|
| 207 |
|
| 208 |
if 'eff' in model_name:
|
| 209 |
hparams = effnet_hparams[num_channels]
|
|
@@ -220,21 +220,20 @@ def predict_and_analyze(model_name, num_channels, dim, input_channel, image):
|
|
| 220 |
depth_mult=hparams.depth_mult,
|
| 221 |
)
|
| 222 |
|
| 223 |
-
config.save_pretrained(model_loading_name)
|
| 224 |
-
config = EfficientNetConfig.from_pretrained(model_loading_name)
|
| 225 |
|
| 226 |
-
model = EfficientNetPreTrained(config)
|
| 227 |
|
|
|
|
| 228 |
# config.register_for_auto_class()
|
| 229 |
# model.register_for_auto_class("AutoModelForImageClassification")
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
model.model.load_state_dict(pretrained_model.state_dict())
|
| 233 |
-
|
| 234 |
# pipeline = pipeline(task="image-classification", model=model_loading_name)
|
| 235 |
-
|
| 236 |
# model = load_model(model_name, activation=True)
|
| 237 |
# model = AutoModel.from_pretrained(model_loading_name)
|
|
|
|
| 238 |
print("Model loaded")
|
| 239 |
|
| 240 |
print("Looking at activations")
|
|
|
|
| 203 |
print("Data loaded")
|
| 204 |
|
| 205 |
print("Loading model")
|
| 206 |
+
model_loading_name = model_path + "%s_%i_planet_detection" % (model_name, num_channels)
|
| 207 |
|
| 208 |
if 'eff' in model_name:
|
| 209 |
hparams = effnet_hparams[num_channels]
|
|
|
|
| 220 |
depth_mult=hparams.depth_mult,
|
| 221 |
)
|
| 222 |
|
| 223 |
+
config.save_pretrained(save_directory=model_loading_name)
|
| 224 |
+
# config = EfficientNetConfig.from_pretrained(model_loading_name)
|
| 225 |
|
| 226 |
+
model = EfficientNetPreTrained.from_pretrained(model_loading_name + '/config.json')
|
| 227 |
|
| 228 |
+
# model = EfficientNetPreTrained(config)
|
| 229 |
# config.register_for_auto_class()
|
| 230 |
# model.register_for_auto_class("AutoModelForImageClassification")
|
| 231 |
+
# pretrained_model = timm.create_model(model_loading_name, pretrained=True)
|
| 232 |
+
# model.model.load_state_dict(pretrained_model.state_dict())
|
|
|
|
|
|
|
| 233 |
# pipeline = pipeline(task="image-classification", model=model_loading_name)
|
|
|
|
| 234 |
# model = load_model(model_name, activation=True)
|
| 235 |
# model = AutoModel.from_pretrained(model_loading_name)
|
| 236 |
+
|
| 237 |
print("Model loaded")
|
| 238 |
|
| 239 |
print("Looking at activations")
|