[GH-ISSUE #208] Batch prediction with model.encode() ? #183

Closed
opened 2026-10-31 21:12:07 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @shashi-netra on GitHub (Jan 14, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/208

        image_inputs=[]
        for img in images_list:
            image_input = preprocess(img).unsqueeze(0).to(device)
            image_inputs.append(image_input)

            # Calculate features
        with torch.no_grad():
            all_image_features = model.encode_image(image_inputs)

I get a segmentation fault, not sure if it's something with my code or this feature is not supported.

Originally created by @shashi-netra on GitHub (Jan 14, 2022). Original GitHub issue: https://github.com/openai/CLIP/issues/208 ``` image_inputs=[] for img in images_list: image_input = preprocess(img).unsqueeze(0).to(device) image_inputs.append(image_input) # Calculate features with torch.no_grad(): all_image_features = model.encode_image(image_inputs) ``` I get a `segmentation fault`, not sure if it's something with my code or this feature is not supported.
Author
Owner

@subhamkhemka commented on GitHub (Jan 20, 2022):

Stack the images and pass it to model.encode_image - model.encode_image(torch.stack(image_inputs))

<!-- gh-comment-id:1017421223 --> @subhamkhemka commented on GitHub (Jan 20, 2022): Stack the images and pass it to model.encode_image - `model.encode_image(torch.stack(image_inputs))`
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#183
No description provided.