qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.73k stars 1.03k forks source link

Loading weights in local #531

Open Le0Dev opened 2 years ago

Le0Dev commented 2 years ago

Hello everyone,

I'm currently using the segmentation_models lib for semantic segmentation on medical images. More precisely, I use U-net with a Resnet34 backbone. When I run my code on my personal computer, everything works fine. However, I tried to use the same code on a server with GPU but I have issues when downloading the resnet34_imagenet_no_top.h5 file.

The issue happen when I run this cell:

BACKBONE = 'resnet34'
model = sm.Unet(BACKBONE, encoder_weights='imagenet',
            input_shape=(IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS),
            classes=n_classes, activation='softmax')
model.compile('Adam', loss=sm.categorical_focal_dice_loss, metrics=[sm.metrics.iou_score])

I obtainTimeOutError, URLError and this at the end of the error message:

Exception: URL fetch failure on 
https://github.com/qubvel/classification_models/releases/download/0.0.1/resnet34_imagenet_1000_no_top.h5: None -- [WinError 
10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established 
connection failed because connected host has failed to respond

I guess it comes from the proxy of my company. I would like to know if there is a way to load the resnet34_imagenet_no_top.h5 in local, without having sm.Unet() to download the file.

Thanks by advance