runtime error trying to resize storage that is not resizable

I am working on a script with data augmentation techniques centercropping,cornercropping and horizontalflip and I want to keep only the centercropping an horizontalflip this is the functions the first one is for the training data

 def get_train_utils(opt, model_parameters): assert opt.train_crop in ['random', 'corner', 'center'] spatial_transform = [] #if opt.train_crop == 'random': # spatial_transform.append( # RandomResizedCrop( # opt.sample_size, (opt.train_crop_min_scale, 1.0), #(opt.train_crop_min_ratio, 1.0 / opt.train_crop_min_ratio))) #elif opt.train_crop == 'corner': # scales = [1.0] # scale_step = 1 / (2**(1 / 4)) #for _ in range(1, 5): # scales.append(scales[-1] * scale_step) #spatial_transform.append(MultiScaleCornerCrop(opt.sample_size, scales)) if opt.train_crop == 'center': spatial_transform.append(Resize(opt.sample_size)) spatial_transform.append(CenterCrop(opt.sample_size)) normalize = get_normalize_method(opt.mean, opt.std, opt.no_mean_norm, opt.no_std_norm) if not opt.no_hflip: spatial_transform.append(RandomHorizontalFlip()) if opt.colorjitter: spatial_transform.append(ColorJitter()) spatial_transform.append(ToTensor()) if opt.input_type == 'flow': spatial_transform.append(PickFirstChannels(n=2)) spatial_transform.append(ScaleValue(opt.value_scale)) spatial_transform.append(normalize) spatial_transform = Compose(spatial_transform) assert opt.train_t_crop in ['random', 'center'] temporal_transform = [] if opt.sample_t_stride > 1: temporal_transform.append(TemporalSubsampling(opt.sample_t_stride)) # if opt.train_t_crop == 'random': # temporal_transform.append(TemporalRandomCrop(opt.sample_duration)) if opt.train_t_crop == 'center': temporal_transform.append(TemporalCenterCrop(opt.sample_duration)) temporal_transform = TemporalCompose(temporal_transform) train_data = get_training_data(opt.video_path, opt.annotation_path, opt.dataset, opt.input_type, opt.file_type, spatial_transform, temporal_transform) if opt.distributed: train_sampler = torch.utils.data.distributed.DistributedSampler( train_data) else: train_sampler = None train_loader = torch.utils.data.DataLoader(train_data, batch_size=opt.batch_size, shuffle=(train_sampler is None), num_workers=opt.n_threads, pin_memory=True, sampler=train_sampler, worker_init_fn=worker_init_fn)

the second one is for validation data

 def get_val_utils(opt): normalize = get_normalize_method(opt.mean, opt.std, opt.no_mean_norm, opt.no_std_norm) spatial_transform = [ Resize(opt.sample_size), CenterCrop(opt.sample_size), ToTensor() ] if opt.input_type == 'flow': spatial_transform.append(PickFirstChannels(n=2)) spatial_transform.extend([ScaleValue(opt.value_scale), normalize]) spatial_transform = Compose(spatial_transform) temporal_transform = [] if opt.sample_t_stride > 1: temporal_transform.append(TemporalSubsampling(opt.sample_t_stride)) temporal_transform.append( TemporalEvenCrop(opt.sample_duration, opt.n_val_samples)) temporal_transform = TemporalCompose(temporal_transform) val_data, collate_fn = get_validation_data(opt.video_path, opt.annotation_path, opt.dataset, opt.input_type, opt.file_type, spatial_transform, temporal_transform) if opt.distributed: val_sampler = torch.utils.data.distributed.DistributedSampler( val_data, shuffle=False) else: val_sampler = None val_loader = torch.utils.data.DataLoader(val_data, batch_size=(opt.batch_size // opt.n_val_samples), shuffle=False, num_workers=opt.n_threads, pin_memory=True, sampler=val_sampler, worker_init_fn=worker_init_fn, collate_fn=collate_fn)

and the last one is for inference data

 def get_inference_utils(opt): assert opt.inference_crop in ['center', 'nocrop'] normalize = get_normalize_method(opt.mean, opt.std, opt.no_mean_norm, opt.no_std_norm) spatial_transform = [Resize(opt.sample_size)] if opt.inference_crop == 'center': spatial_transform.append(CenterCrop(opt.sample_size)) spatial_transform.append(ToTensor()) if opt.input_type == 'flow': spatial_transform.append(PickFirstChannels(n=2)) spatial_transform.extend([ScaleValue(opt.value_scale), normalize]) spatial_transform = Compose(spatial_transform) temporal_transform = [] if opt.sample_t_stride > 1: temporal_transform.append(TemporalSubsampling(opt.sample_t_stride)) temporal_transform.append( SlidingWindow(opt.sample_duration, opt.inference_stride)) temporal_transform = TemporalCompose(temporal_transform) inference_data, collate_fn = get_inference_data( opt.video_path, opt.annotation_path, opt.dataset, opt.input_type, opt.file_type, opt.inference_subset, spatial_transform, temporal_transform) inference_loader = torch.utils.data.DataLoader( inference_data, batch_size=opt.inference_batch_size, shuffle=False, num_workers=opt.n_threads, pin_memory=True, worker_init_fn=worker_init_fn, collate_fn=collate_fn) return inference_loader, inference_data.class_names

the functions used are imported from :

 from spatial_transforms import (Compose, Normalize, Resize, CenterCrop, CornerCrop, MultiScaleCornerCrop, RandomResizedCrop, RandomHorizontalFlip, ToTensor, ScaleValue, ColorJitter, PickFirstChannels) from temporal_transforms import (LoopPadding, TemporalRandomCrop, TemporalCenterCrop, TemporalEvenCrop, SlidingWindow, TemporalSubsampling) from temporal_transforms import Compose as TemporalCompose

I just removed th random an corner cropping from the get_train_util function the line with the # symbole and kept only the center cropping but got this error

runtime error trying to resize storage that is not resizable

the tracebacktraceback_screenshotthe complete code is in this github repository link_to_completecodeI think it's related to the dataloader , it'not able to load the data after I tried to modified it any suggestions what should I do?

2 Related questions 1106 How do I remove/delete a folder that is not empty? 0 What does it mean to assert an object in python? 2 What could be raising this "RuntimeError: Trying to resize storage that is not resizable"? Related questions 1106 How do I remove/delete a folder that is not empty? 0 What does it mean to assert an object in python? 2 What could be raising this "RuntimeError: Trying to resize storage that is not resizable"? 774 Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 90 CUDA runtime error (59) : device-side assert triggered 1 Center widgets in Kivy 454 Error "filename.whl is not a supported wheel on this platform" Load 4 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like