pytorch_datafiles/loading_data.py
def collate(batch):
    # @GJY 
    r"""Puts each data field into a tensor with outer dimension batch size"""

    transposed = list(zip(*batch)) # imgs and dens
    imgs, dens = [transposed[0],transposed[1]]


    error_msg = "batch must contain tensors; found {}"
    if isinstance(imgs[0], torch.Tensor) and isinstance(dens[0], torch.Tensor):
        
        min_ht, min_wd = get_min_size(imgs)
        
        cropped_imgs = []
        cropped_dens = []
        for i_sample in range(len(batch)):
            _img, _den = random_crop(imgs[i_sample],dens[i_sample],[min_ht,min_wd])
            cropped_imgs.append(_img)
            cropped_dens.append(_den)

        cropped_imgs = torch.stack(cropped_imgs, 0, out=share_memory(cropped_imgs))
        cropped_dens = torch.stack(cropped_dens, 0, out=share_memory(cropped_dens))

        return [cropped_imgs,cropped_dens]

    raise TypeError((error_msg.format(type(batch[0]))))
r"""Puts each data field into a tensor with outer dimension batch size
r"""Puts each data field into a tensor with outer dimension batch size
r " " " Puts each data field into a tensor with outer dimension batch size
def collate(batch):
    transposed = list(zip(*batch)) 
    imgs, dens = [transposed[0],transposed[1]]
    error_msg = "batch must contain tensors; found {}"
    if isinstance(imgs[0], torch.Tensor) and isinstance(dens[0], torch.Tensor):
        min_ht, min_wd = get_min_size(imgs)
        cropped_imgs = []
        cropped_dens = []
        for i_sample in range(len(batch)):
            _img, _den = random_crop(imgs[i_sample],dens[i_sample],[min_ht,min_wd])
            cropped_imgs.append(_img)
            cropped_dens.append(_den)
        cropped_imgs = torch.stack(cropped_imgs, 0, out=share_memory(cropped_imgs))
        cropped_dens = torch.stack(cropped_dens, 0, out=share_memory(cropped_dens))
        return [cropped_imgs,cropped_dens]
    raise TypeError((error_msg.format(type(batch[0]))))
def collate ( batch ) : transposed = list ( zip ( * batch ) ) imgs , dens = [ transposed [ 0 ] , transposed [ 1 ] ] error_msg = "batch must contain tensors; found {}" if isinstance ( imgs [ 0 ] , torch . Tensor ) and isinstance ( dens [ 0 ] , torch . Tensor ) : min_ht , min_wd = get_min_size ( imgs ) cropped_imgs = [ ] cropped_dens = [ ] for i_sample in range ( len ( batch ) ) : _img , _den = random_crop ( imgs [ i_sample ] , dens [ i_sample ] , [ min_ht , min_wd ] ) cropped_imgs . append ( _img ) cropped_dens . append ( _den ) cropped_imgs = torch . stack ( cropped_imgs , 0 , out = share_memory ( cropped_imgs ) ) cropped_dens = torch . stack ( cropped_dens , 0 , out = share_memory ( cropped_dens ) ) return [ cropped_imgs , cropped_dens ] raise TypeError ( ( error_msg . format ( type ( batch [ 0 ] ) ) ) )
r"""Puts each data field into a tensor with outer dimension batch size
r " " " Puts each data field into a tensor with outer dimension batch size
# @GJY  r"""Puts each data field into a tensor with outer dimension batch size""" # imgs and dens
batch