[Python] How to pre-load numpy data into a buffer like io.BytesIO to make it seekable?

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    Following function basically returns numpy.ndarray

    def getimage(id):
    img = self.coco.loadImgs(id)
    I = io.imread(img['coco_url'])
    return I #returns 'numpy.ndarray'


    The getimage function being called from main:

    x = load.getimage(id).
    x = torch.load(x)


    Error thrown:

    'numpy.ndarray' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.

    Continue reading...

Compartilhe esta Página