Skip to content
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

run using-model-example.ipynb occur errors #6

Open
fuujiro opened this issue May 16, 2022 · 0 comments
Open

run using-model-example.ipynb occur errors #6

fuujiro opened this issue May 16, 2022 · 0 comments

Comments

@fuujiro
Copy link

fuujiro commented May 16, 2022

seg_interactive = segmentation(PATH,LABELS)
Which backbone model do you want to use?
-'mobilenet' or 'mobilenetv2': efficient and light for real-word application
-'inceptionv3': Deep Convolutional Neural Network with sparsely connected architecture developped by Google (using different types of convolutional blocks at each layer)
-'resnet18','resnet34','resnet50','resnet101' or'resnet152': core idea of this model is 'identity shortcut connection' that skips one or more layers
We encourage you to try mobilenet first to see if it is sufficient for your segmentation task
mobilenet

Which loss function do you want to use ?
-'cross_entropy': fastest to compute,
-'dice_loss': Overlap measure that performs better at class imbalanced problems
-'focal_loss' : To down-weight the contribution of easy examples so that the CNN focuses more on hard examples
Could also be a mix of those loss functions
Examples :

  • cross_entropy + dice_loss
  • dice_loss + focal_loss
    cross_entropy
    Do you want Data Augmentation ? Yes or No
    yes
    Do you want to use pre-trained weights trained on Imagenet for the encoder ?
    Yes or No
    yes

What is your batch_size ?
6

What is your steps_per_epoch ?
For guidance, you have 12 training images and a chosen batch_size of 6
Normally (with many images), the steps_per_epoch is equal to Nbr_training_images//batch_size==2
However, if you have a few images, you could increase that number because you'll have data augmentation
10

How many epochs do you want to run ?
20

Do you want to freeze the encoder layer ? Yes or No
No
Found 12 images belonging to 1 classes.
Found 12 images belonging to 1 classes.
Found 1 images belonging to 1 classes.
Found 1 images belonging to 1 classes.


OSError Traceback (most recent call last)
in
----> 1 seg_interactive = segmentation(PATH,LABELS)

/mnt/code/AC295-final-project-JWI/lib/Segmentation.py in init(self, PATH, CLASSES, target_size, params)
78 self.create_datagenerator(PATH)
79 #Model
---> 80 self.model = sm.Unet(self.backbone, encoder_weights=self.weights_pretrained,classes=self.n_classes, activation=self.activation, encoder_freeze=self.encoder_freeze)
81
82 try:

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/segmentation_models/init.py in wrapper(*args, **kwargs)
32 kwargs['models'] = _KERAS_MODELS
33 kwargs['utils'] = _KERAS_UTILS
---> 34 return func(*args, **kwargs)
35
36 return wrapper

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/segmentation_models/models/unet.py in Unet(backbone_name, input_shape, classes, activation, weights, encoder_weights, encoder_freeze, encoder_features, decoder_block_type, decoder_filters, decoder_use_batchnorm, **kwargs)
219 'Got: {}'.format(decoder_block_type))
220
--> 221 backbone = Backbones.get_backbone(
222 backbone_name,
223 input_shape=input_shape,

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/segmentation_models/backbones/backbones_factory.py in get_backbone(self, name, *args, **kwargs)
101 def get_backbone(self, name, *args, **kwargs):
102 model_fn, _ = self.get(name)
--> 103 model = model_fn(*args, **kwargs)
104 return model
105

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/classification_models/models_factory.py in wrapper(*args, **kwargs)
76 modules_kwargs = self.get_kwargs()
77 new_kwargs = dict(list(kwargs.items()) + list(modules_kwargs.items()))
---> 78 return func(*args, **new_kwargs)
79
80 return wrapper

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/keras_applications/mobilenet.py in MobileNet(input_shape, alpha, depth_multiplier, dropout, include_top, weights, input_tensor, pooling, classes, **kwargs)
294 weight_path,
295 cache_subdir='models')
--> 296 model.load_weights(weights_path)
297 elif weights is not None:
298 model.load_weights(weights)

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in load_weights(self, filepath, by_name, skip_mismatch)
248 raise ValueError('Load weights is not yet supported with TPUStrategy '
249 'with steps_per_run greater than 1.')
--> 250 return super(Model, self).load_weights(filepath, by_name, skip_mismatch)
251
252 def compile(self,

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch)
1257 'first, then load the weights.')
1258 self._assert_weights_created()
-> 1259 with h5py.File(filepath, 'r') as f:
1260 if 'layer_names' not in f.attrs and 'model_weights' in f:
1261 f = f['model_weights']

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/h5py/_hl/files.py in init(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)
404 with phil:
405 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, **kwds)
--> 406 fid = make_fid(name, mode, userblock_size,
407 fapl, fcpl=make_fcpl(track_order=track_order),
408 swmr=swmr)

~/miniconda3/envs/segmentation/lib/python3.8/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
171 if swmr and swmr_support:
172 flags |= h5f.ACC_SWMR_READ
--> 173 fid = h5f.open(name, flags, fapl=fapl)
174 elif mode == 'r+':
175 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (truncated file: eof = 57344, sblock->base_addr = 0, stored_eof = 17225924)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant