Skip to content

Errors when uploading certain pictures from my cell phone #3416

Closed
@liusida

Description

When I try to use ComfyUI on my cell phone (Android), sometimes, when I try to upload an image, it will give error like this:

!!! Exception during processing!!! Sizes of tensors must match except in dimension 0. Expected size 2688 but got size 1018 for tensor number 1 in the list.
Traceback (most recent call last):
  File "/mnt/data/ComfyUI-BS/ComfyUI/execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data/ComfyUI-BS/ComfyUI/execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data/ComfyUI-BS/ComfyUI/execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data/ComfyUI-BS/ComfyUI/nodes.py", line 1480, in load_image
    output_image = torch.cat(output_images, dim=0)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 2688 but got size 1018 for tensor number 1 in the list.

And when I paused the process right before the error happens, and I inspect the variable img, I saw this (with n_frames=2), but it's a JPG! I don't know why, and ChatGPT says that it's a MPO file.

image

Extracted with ChatGPT:

img: <PIL.MpoImagePlugin.MpoImageFile image mode=L size=572x1018 at 0x7F1E153924D0>

special variables
function variables

app: {'APP1': b'http://ns.adobe.com/xmp/extension/\x01\x00\x08\xAC0B6D96AB3A7066059E016278C9C8...\x00\x00\x92\x00\x00\x10\x01\x02\x00\x08\x00\x00\x00'}
applist: [('APP0', b'JFIF\x00\x01\x02\x00\x48\x00\x48\x00\x00'), ('APP1', b'http://ns.adobe.com/xap/1.0/\x00...\x00\x00\x92\x00\x00\x12\x01\x03...\x00')]
bits: 8
custom_mimetype: None
decoderconfig: {}
decodermaxblock: 65536
filename: '/mnt/data/ComfyUI-BS/ComfyUI/input/PXL_20240507_013340406 (5).jpg'
format: 'MPO'
format_description: 'MPO (CIPA DC-007)'
fp: None
has_transparency_data: False
height: 2688
huffman_ac: {}
huffman_dc: {}
icclist: []
im: <ImagingCore object at 0x7f1e1422d5e0>
info: {'dpi': (72.0, 72.0), 'jfif': 258, 'jfif_version': (1, 2)}
is_animated: True
layer: [(1, 2, 2, 0), (2, 1, 1, 1), (3, 1, 1, 1)]
layers: 3
map: None
mode: 'RGB'
mpinfo: {45056: b'0100', 45057: 2, 45058: [{...}, {...}]}
n_frames: 2
offset: 0
palette: None
pyaccess: None
quantization: {0: [3, 3, 2, 3, 5, 8, 10, 12, 2, 4, 4, ...], 1: [3, 3, 5, 7, 11, 11, 12, 3, 4, 6, 8, 10, 2, 4, 4, ...]}
readonly: 0
size: (1512, 2688)
tile: []

I never encounter this kind of JPGs on my Desktop, ether Ubuntu or Windows. I'm not sure why cell phones store some JPGs like that (no all JPGs have two frames, only some of them do). But this causes errors in ComfyUI's LoadImage node.

I'll try to upload one of the JPG files here in the comment. To reproduce the error, save the tomato photo and try to upload with ComfyUI's Load Image node.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions