Open
Description
I'm implementing the API on a website. I made a code that loads the model I trained and predicts on some images, but every time I load the model, the model start downloading the encoder weights. This slows down my tests. I downloaded the encoder so I was wondering if there was any way to load these weights by passing the path to the encoder?
modle_path = os.path.join(os.path.dirname(__file__), 'modelos_seg/model_dpl_efficientnet-b7')
model = smp.from_pretrained(modle_path) # Load the pre-trained model
Downloading: "https://github.com/lukemelas/EfficientNet-PyTorch/releases/download/1.0/efficientnet-b7-dcc49843.pth" to /root/.cache/torch/hub/checkpoints/efficientnet-b7-dcc49843.pth
100%|██████████| 254M/254M [00:57<00:00, 4.67MB/s]
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
qubvel commentedon Oct 21, 2024
Hi @Rafaelca70x , thanks for the question! The reason is that in config "encoder_weights" is set to "imagenet". That is why the model first loads "encoder" weights, and then loads weights for the whole trained model. You can modify your saved config.json to store "encoder_weights: null", it should help.
This behavior should be avoided, I would appreciate the fix if you have the bandwidth! Thanks for reporting anyway!
Rafaelca70x commentedon Oct 23, 2024
Thanks for the reply, @qubvel ! I'm asking because I'm planning to put your model in a docker to send to a computer in a region that doesn't have internet, so I want to put all the files in the docker, including the encoder.
CvBokchoy commentedon Oct 26, 2024
请问如何将examples/camvid_segmentation_multiclass.ipynb 中训练好的模型保存到本地 并且转为onnx模型呢?谢谢(How do I save the trained models in examples/camvid_segmentation_multiclass.ipynb locally and convert them to onnx models? thank you)