Skip to content

Commit

Permalink
Add try expect
Browse files Browse the repository at this point in the history
  • Loading branch information
Halim, Calvin Janitra | Calvin | CTMO authored and magnusbarata committed Sep 29, 2021
1 parent 4bfa518 commit 2b37931
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions models/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ def efficientnet(input_shape, n_class=2, variant='B0', **kwargs):
'pooling': None,
'classes': n_class,
}
if len(input_shape) == 4:
effnet_layer = getattr(efn, f'EfficientNet{variant}')(**default_effnet_params)
modal = '3D'
elif len(input_shape) == 3:
effnet_layer = getattr(keras.applications, f'EfficientNet{variant}')(
classifier_activation='softmax', **default_effnet_params
)
modal = '2D'
else:
raise ValueError('input_shape is expected as an array ranked 3 or 4')
try:
if len(input_shape) == 4:
effnet_layer = getattr(efn, f'EfficientNet{variant}')(**default_effnet_params)
modal = '3D'
elif len(input_shape) == 3:
effnet_layer = getattr(keras.applications, f'EfficientNet{variant}')(
classifier_activation='softmax', **default_effnet_params
)
modal = '2D'
else:
raise ValueError('input_shape is expected as an array ranked 3 or 4')
except AttributeError:
print(f'No EfficientNet variation found for {variant}')
raise SystemExit

inputs = keras.Input(input_shape)
outputs = effnet_layer(inputs)
Expand Down

0 comments on commit 2b37931

Please sign in to comment.