Closed Choneke closed 1 year ago
Hi, I seems that the provided model weights are not matched to the model.
The convert.py
script is to convert models before re-param to fast ones after re-param, that is, the input to convert.py
should be weights of a model before re-param, for example
python convert.py model_weights_before_reparam.pkl model_weights_after_reparam.pkl -m repghost.repghostnet
Thank you for your reply, I tried the above command, it load the model but it raise an error:
python convert.py repghost1_trained.pkl repghost1_converted.pkl -m repghost.repghostnet
=> loading checkpoint 'repghost1_trained.pkl'
Traceback (most recent call last):
File "convert.py", line 60, in <module>
convert()
File "convert.py", line 38, in convert
checkpoint = checkpoint['state_dict']
KeyError: 'state_dict'
The model pkl you provided contains only pure model weights, but our script is set default for pkl files containing more infos, e.g., optimizer, state_dict, epochs, and etc. Thus, you can directly use the weights after the loading.
To solve you problem:
checkpoint = checkpoint['state_dict'] if 'state_dict' in checkpoint else checkpoint
Thank you @ChengpengChen the problem has been solved using your suggested solution. One more question, does this not affecting the inference time? As I can see there is no any changes (in inference time) between original model and the converted model. There is a change in size (MB) only.
This conversion simplifies the network topology, which should provides more inference efficiency. For example, https://github.com/ChengpengChen/RepGhost/issues/6 shows 13.3% speedup of an U-Net using our module in snapdragon 8 gen 1.
In order to analyze the problem, you can provide more details of the models before and after re-param and inference settings.
Hi, I trained the model on my dataset, and then convert it for inference using fille convert.py with the command " python convert.py load TRAINEDMODEL/best_repghost.pkl -m repghost.repghostnet". However, during conversion got the following message and the model converted as when I look on the two models the size (in MB) are different between the original model and the converted one.
When I use the original model for inference, there is no any error message, but when I use the converted model I got the following error message. Can you help me to solve the issue?