-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'DeepLabV3Plus' object has no attribute 'save_pretrained' #880
Comments
import torch
import segmentation_models_pytorch as smp
model = smp.DeepLabV3Plus(
encoder_name="efficientnet-b5", # Выбранный энкодер
encoder_weights=None, # Использование предобученных весов на ImageNet
in_channels=1, # Количество входных каналов (например, 1 для черно-белых изображений)
classes=1, # Количество классов для выходной маски
activation='sigmoid' # Функция активации
)
model = torch.nn.DataParallel(model)
model = model.cpu()
# Путь к сохраненной модели
PATH = 'best_model_epoch_8.pt'
model.load_state_dict(torch.load(PATH, map_location=torch.device('cpu')))
if isinstance(model, torch.nn.DataParallel):
model = model.module
# Перевод модели в режим оценки
model.eval()
# After training your model, save it to a directory
model.save_pretrained('./model') AttributeError: 'DeepLabV3Plus' object has no attribute 'save_pretrained' |
Hi @Marcus2331, thanks for the issue! But you could try it out if you reinstall the library from the source with pip install -U git+https://github.com/qubvel/segmentation_models.pytorch I will release it to PyPI in a few days or so! |
Thanks for the quick feedback |
Прошу прощения возможно за глупый вопрос. Но есть ли возможность экспорта модели обученной на библиотеке smp в формат tf_saved_model Для tensorflow_serving? |
I tried an approach that Chat-GPT recommended, it seems to work fine, check this out in Colab: https://colab.research.google.com/drive/1J5dAmPfMcoJkDv9Bh_IbDxKjafhCFCmM?usp=sharing And, please, let me know if you have any questions or this solves your issue 🙂 I will include this example to examples folder then and in docs |
Слезно прошу вас помочь мне с конвертацией модели которую я сохранил с помощью model.save_pretrained('./model') сконвертировать в формат tf_saved_model для дальнейшего использования в tensorflow_serving:(( |
Did you try to do it with provided colab example? |
Consider also looking at |
Thank you so much!!! this solved my problem) |
Почему тут есть возможность сохранения модели https://smp.readthedocs.io/en/latest/save_load.html как в документации. А я не могу сохранить модель DeepLabV3Plus?
The text was updated successfully, but these errors were encountered: