You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
re: tutorials/mct_model_garden/models_keras/nanodet/nanodet_keras_model.py
nanodet_keras_model.py can only handle 80 classes
Can be made more general by replacing the value of 80 with a class parameter
- see def nanodet_box_decoding()
Moreover, in nanodet_plus_head(n, feat_channels=128)
h[idx] = Conv2D(112, 1, name='head.gfl_cls.' + str(idx))(h[idx])
should probably be replaced with
h[idx] = Conv2D(32+num_of_classes, 1, name='head.gfl_cls.' + str(idx))(h[idx])
where num_of_classes corresponds to a new input parameter (default is 80 as in coco)
Expected behaviour
expected to be able to load pth file with a different number of classes than in coco (80)
Code to reproduce the issue
# see https://github.com/sony/model_optimization/blob/main/tutorials/notebooks/keras/ptq/example_keras_nanodet_plus.ipynb
PRETRAINED_WEIGHTS_FILE = <pth file with num of classes != 80># Parameters for nanodet-plus-m-1.5x_416
INPUT_RESOLUTION = 416
INPUT_SHAPE = (INPUT_RESOLUTION, INPUT_RESOLUTION, 3)
SCALE_FACTOR = 1.5
BOTTLENECK_RATIO = 0.5
FEATURE_CHANNELS = 128
pretrained_weights = torch.load(PRETRAINED_WEIGHTS_FILE, map_location=torch.device('cpu'))['state_dict']
model = nanodet_plus_m(INPUT_SHAPE, SCALE_FACTOR, BOTTLENECK_RATIO, FEATURE_CHANNELS)
load_state_dict(model, state_dict_torch=pretrained_weights) # ValueError
...
Log output
(tested with 5 classes instead of 80)
...torch2keras_weights_translation.py", line 15ValueError: Cannot assign value to variable ' head.gfl_cls.0/kernel:0': Shape mismatch.The variable shape (1, 1, 128, 112), and the assigned value shape (1, 1, 128, 37) are incompatible
The text was updated successfully, but these errors were encountered:
Issue Type
Bug
Source
source
MCT Version
1.10.0
OS Platform and Distribution
Ubuntu 20.04
Python version
3.10.12
Describe the issue
Expected behaviour
expected to be able to load pth file with a different number of classes than in coco (80)
Code to reproduce the issue
Log output
The text was updated successfully, but these errors were encountered: