Problem with Huggingface Agent
Author: piust
Pull request: no

### System Info

2023-05-12 10:53:56.623476: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
WARNING:tensorflow:From /usr/local/lib/python3.10/dist-packages/transformers/commands/env.py:63: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-05-12 10:54:01.265612: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.29.0
- Platform: Linux-5.10.147+-x86_64-with-glibc2.31
- Python version: 3.10.11
- Huggingface_hub version: 0.14.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.0.0+cu118 (True)
- Tensorflow version (GPU?): 2.12.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.6.9 (gpu)
- Jax version: 0.4.8
- JaxLib version: 0.4.7
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>



### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I have a image in webp format and wanted to segment the character in foreground, but I get an error.
Let me know how I can send it to you ... this type of file is not supported

Here is the code:
`
from PIL import Image

def leggi_immagine(percorso):
    try:
        image = Image.open(percorso)
        return image
    except IOError:
        print("Impossibile aprire l'immagine. Controlla il percorso del file.")

image = leggi_immagine("dart.webp")
image2 = agent.run("Draw a red line all around dart vader body in `image`", image=image)
`



and here is the error:

in <cell line: 1>:1                                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py:323 in run                  │
│                                                                                                  │
│   320 │   │   if not return_code:                                                                │
│   321 │   │   │   print("\n\n==Result==")                                                        │
│   322 │   │   │   self.cached_tools = resolve_tools(code, self.toolbox, remote=remote, cached_   │
│ ❱ 323 │   │   │   return evaluate(code, self.cached_tools, state=kwargs.copy())                  │
│   324 │   │   else:                                                                              │
│   325 │   │   │   tool_code = get_tool_creation_code(code, self.toolbox, remote=remote)          │
│   326 │   │   │   return f"{tool_code}\n{code}"                                                  │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:61 in evaluate  │
│                                                                                                  │
│    58 │   result = None                                                                          │
│    59 │   for idx, node in enumerate(expression.body):                                           │
│    60 │   │   try:                                                                               │
│ ❱  61 │   │   │   line_result = evaluate_ast(node, state, tools)                                 │
│    62 │   │   except InterpretorError as e:                                                      │
│    63 │   │   │   msg = f"Evaluation of the code stopped at line {idx} before the end because    │
│    64 │   │   │   if chat_mode:                                                                  │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:98 in           │
│ evaluate_ast                                                                                     │
│                                                                                                  │
│    95 │   if isinstance(expression, ast.Assign):                                                 │
│    96 │   │   # Assignement -> we evaluate the assignement which should update the state         │
│    97 │   │   # We return the variable assigned as it may be used to determine the final resul   │
│ ❱  98 │   │   return evaluate_assign(expression, state, tools)                                   │
│    99 │   elif isinstance(expression, ast.Call):                                                 │
│   100 │   │   # Function call -> we return the value of the function call                        │
│   101 │   │   return evaluate_call(expression, state, tools)                                     │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:139 in          │
│ evaluate_assign                                                                                  │
│                                                                                                  │
│   136                                                                                            │
│   137 def evaluate_assign(assign, state, tools):                                                 │
│   138 │   var_names = assign.targets                                                             │
│ ❱ 139 │   result = evaluate_ast(assign.value, state, tools)                                      │
│   140 │                                                                                          │
│   141 │   if len(var_names) == 1:                                                                │
│   142 │   │   state[var_names[0].id] = result                                                    │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:101 in          │
│ evaluate_ast                                                                                     │
│                                                                                                  │
│    98 │   │   return evaluate_assign(expression, state, tools)                                   │
│    99 │   elif isinstance(expression, ast.Call):                                                 │
│   100 │   │   # Function call -> we return the value of the function call                        │
│ ❱ 101 │   │   return evaluate_call(expression, state, tools)                                     │
│   102 │   elif isinstance(expression, ast.Constant):                                             │
│   103 │   │   # Constant -> just return the value                                                │
│   104 │   │   return expression.value                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:167 in          │
│ evaluate_call                                                                                    │
│                                                                                                  │
│   164 │   # Todo deal with args                                                                  │
│   165 │   args = [evaluate_ast(arg, state, tools) for arg in call.args]                          │
│   166 │   kwargs = {keyword.arg: evaluate_ast(keyword.value, state, tools) for keyword in call   │
│ ❱ 167 │   return func(*args, **kwargs)                                                           │
│   168                                                                                            │
│   169                                                                                            │
│   170 def evaluate_subscript(subscript, state, tools):                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/base.py:536 in __call__               │
│                                                                                                  │
│   533 │   │                                                                                      │
│   534 │   │   encoded_inputs = self.encode(*args, **kwargs)                                      │
│   535 │   │   encoded_inputs = send_to_device(encoded_inputs, self.device)                       │
│ ❱ 536 │   │   outputs = self.forward(encoded_inputs)                                             │
│   537 │   │   outputs = send_to_device(outputs, "cpu")                                           │
│   538 │   │   return self.decode(outputs)                                                        │
│   539                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/image_segmentation.py:52 in forward   │
│                                                                                                  │
│   49 │                                                                                           │
│   50 │   def forward(self, inputs):                                                              │
│   51 │   │   with torch.no_grad():                                                               │
│ ❱ 52 │   │   │   logits = self.model(**inputs).logits                                            │
│   53 │   │   return logits                                                                       │
│   54 │                                                                                           │
│   55 │   def decode(self, outputs):                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:1426 in  │
│ forward                                                                                          │
│                                                                                                  │
│   1423 │   │                                                                                     │
│   1424 │   │   # step 1: forward the query images through the frozen CLIP vision encoder         │
│   1425 │   │   with torch.no_grad():                                                             │
│ ❱ 1426 │   │   │   vision_outputs = self.clip.vision_model(                                      │
│   1427 │   │   │   │   pixel_values=pixel_values,                                                │
│   1428 │   │   │   │   output_attentions=output_attentions,                                      │
│   1429 │   │   │   │   output_hidden_states=True,  # we need the intermediate hidden states      │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:867 in   │
│ forward                                                                                          │
│                                                                                                  │
│    864 │   │   if pixel_values is None:                                                          │
│    865 │   │   │   raise ValueError("You have to specify pixel_values")                          │
│    866 │   │                                                                                     │
│ ❱  867 │   │   hidden_states = self.embeddings(pixel_values)                                     │
│    868 │   │   hidden_states = self.pre_layrnorm(hidden_states)                                  │
│    869 │   │                                                                                     │
│    870 │   │   encoder_outputs = self.encoder(                                                   │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:215 in   │
│ forward                                                                                          │
│                                                                                                  │
│    212 │   │                                                                                     │
│    213 │   │   if embeddings.shape[1] != self.num_positions:                                     │
│    214 │   │   │   new_shape = int(math.sqrt(embeddings.shape[1] - 1))                           │
│ ❱  215 │   │   │   embeddings = embeddings + self.interpolate_position_embeddings((new_shape, n  │
│    216 │   │   │   embeddings = embeddings.to(embeddings.dtype)                                  │
│    217 │   │   else:                                                                             │
│    218 │   │   │   embeddings = embeddings + self.position_embedding(self.position_ids)          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: The size of tensor a (3151) must match the size of tensor b (3137) at non-singleton dimension 1



### Expected behavior

To draw a red line around Dart Vader figure.

Comments:
Hello @piust 

The error message you are seeing suggests that there is a size mismatch between two tensors, 'a' and 'b', at dimension 1. This typically occurs when the dimensions of the tensors involved in a calculation are not compatible.

But the error message doesn't seem to be specific enough to determine the exact cause of the error. It is possible that there is a problem with the code that was passed to the agent, or there could be a problem with the image that was passed to it. One possible solution would be to try running the code on a different image to see if the error persists.

Hi @piust, 

For the image, are you able to reproduce the error if you read in the PNG equivalent? i.e. is it possible to save out the image, read it back and run the agent script again e.g.:

```python
from PIL import Image

image_path = "dart.webp"
image = Image.open(image_path)

# Save out the image as a PNG
image.save("dart.png")

# Read in the image from PNG format
image = Image.open("dart.png")

# Then pass the image to the agent
from transformers import HfAgent
agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
image2 = agent.run(
    "Draw a red line all around dart vader body in `image`", 
    image=image
)
```

PNG images are sharable within issues, and so if it also triggers an error we could debug from that.

Yes, it triggers a error:

==Explanation from the agent==
I will use the following  tools: `image_segmenter` to create a segmentation mask of the dart vader body, then `image_transformer` to draw a red line around it.


==Code generated by the agent==
mask = image_segmenter(image=image, label="Dart Vader")
image = image_transformer(image=image, prompt="Red line around dart vader body")


==Result==
Downloading (…)ge_transformation.py: 100%
2.05k/2.05k [00:00<00:00, 155kB/s]
A new version of the following files was downloaded from https://huggingface.co/space/huggingface-tools/image-transformation:
- image_transformation.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
Downloading (…)rocessor_config.json: 100%
380/380 [00:00<00:00, 29.2kB/s]
Downloading (…)okenizer_config.json: 100%
974/974 [00:00<00:00, 73.6kB/s]
Downloading (…)olve/main/vocab.json: 100%
1.06M/1.06M [00:00<00:00, 3.26MB/s]
Downloading (…)olve/main/merges.txt: 100%
525k/525k [00:00<00:00, 6.42MB/s]
Downloading (…)cial_tokens_map.json: 100%
472/472 [00:00<00:00, 38.5kB/s]
Downloading (…)lve/main/config.json: 100%
4.73k/4.73k [00:00<00:00, 266kB/s]
Downloading pytorch_model.bin: 100%
603M/603M [00:01<00:00, 315MB/s]
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <cell line: 15>:15                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py:323 in run                  │
│                                                                                                  │
│   320 │   │   if not return_code:                                                                │
│   321 │   │   │   print("\n\n==Result==")                                                        │
│   322 │   │   │   self.cached_tools = resolve_tools(code, self.toolbox, remote=remote, cached_   │
│ ❱ 323 │   │   │   return evaluate(code, self.cached_tools, state=kwargs.copy())                  │
│   324 │   │   else:                                                                              │
│   325 │   │   │   tool_code = get_tool_creation_code(code, self.toolbox, remote=remote)          │
│   326 │   │   │   return f"{tool_code}\n{code}"                                                  │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:61 in evaluate  │
│                                                                                                  │
│    58 │   result = None                                                                          │
│    59 │   for idx, node in enumerate(expression.body):                                           │
│    60 │   │   try:                                                                               │
│ ❱  61 │   │   │   line_result = evaluate_ast(node, state, tools)                                 │
│    62 │   │   except InterpretorError as e:                                                      │
│    63 │   │   │   msg = f"Evaluation of the code stopped at line {idx} before the end because    │
│    64 │   │   │   if chat_mode:                                                                  │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:98 in           │
│ evaluate_ast                                                                                     │
│                                                                                                  │
│    95 │   if isinstance(expression, ast.Assign):                                                 │
│    96 │   │   # Assignement -> we evaluate the assignement which should update the state         │
│    97 │   │   # We return the variable assigned as it may be used to determine the final resul   │
│ ❱  98 │   │   return evaluate_assign(expression, state, tools)                                   │
│    99 │   elif isinstance(expression, ast.Call):                                                 │
│   100 │   │   # Function call -> we return the value of the function call                        │
│   101 │   │   return evaluate_call(expression, state, tools)                                     │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:139 in          │
│ evaluate_assign                                                                                  │
│                                                                                                  │
│   136                                                                                            │
│   137 def evaluate_assign(assign, state, tools):                                                 │
│   138 │   var_names = assign.targets                                                             │
│ ❱ 139 │   result = evaluate_ast(assign.value, state, tools)                                      │
│   140 │                                                                                          │
│   141 │   if len(var_names) == 1:                                                                │
│   142 │   │   state[var_names[0].id] = result                                                    │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:101 in          │
│ evaluate_ast                                                                                     │
│                                                                                                  │
│    98 │   │   return evaluate_assign(expression, state, tools)                                   │
│    99 │   elif isinstance(expression, ast.Call):                                                 │
│   100 │   │   # Function call -> we return the value of the function call                        │
│ ❱ 101 │   │   return evaluate_call(expression, state, tools)                                     │
│   102 │   elif isinstance(expression, ast.Constant):                                             │
│   103 │   │   # Constant -> just return the value                                                │
│   104 │   │   return expression.value                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/python_interpreter.py:167 in          │
│ evaluate_call                                                                                    │
│                                                                                                  │
│   164 │   # Todo deal with args                                                                  │
│   165 │   args = [evaluate_ast(arg, state, tools) for arg in call.args]                          │
│   166 │   kwargs = {keyword.arg: evaluate_ast(keyword.value, state, tools) for keyword in call   │
│ ❱ 167 │   return func(*args, **kwargs)                                                           │
│   168                                                                                            │
│   169                                                                                            │
│   170 def evaluate_subscript(subscript, state, tools):                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/base.py:536 in __call__               │
│                                                                                                  │
│   533 │   │                                                                                      │
│   534 │   │   encoded_inputs = self.encode(*args, **kwargs)                                      │
│   535 │   │   encoded_inputs = send_to_device(encoded_inputs, self.device)                       │
│ ❱ 536 │   │   outputs = self.forward(encoded_inputs)                                             │
│   537 │   │   outputs = send_to_device(outputs, "cpu")                                           │
│   538 │   │   return self.decode(outputs)                                                        │
│   539                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/tools/image_segmentation.py:52 in forward   │
│                                                                                                  │
│   49 │                                                                                           │
│   50 │   def forward(self, inputs):                                                              │
│   51 │   │   with torch.no_grad():                                                               │
│ ❱ 52 │   │   │   logits = self.model(**inputs).logits                                            │
│   53 │   │   return logits                                                                       │
│   54 │                                                                                           │
│   55 │   def decode(self, outputs):                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:1426 in  │
│ forward                                                                                          │
│                                                                                                  │
│   1423 │   │                                                                                     │
│   1424 │   │   # step 1: forward the query images through the frozen CLIP vision encoder         │
│   1425 │   │   with torch.no_grad():                                                             │
│ ❱ 1426 │   │   │   vision_outputs = self.clip.vision_model(                                      │
│   1427 │   │   │   │   pixel_values=pixel_values,                                                │
│   1428 │   │   │   │   output_attentions=output_attentions,                                      │
│   1429 │   │   │   │   output_hidden_states=True,  # we need the intermediate hidden states      │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:867 in   │
│ forward                                                                                          │
│                                                                                                  │
│    864 │   │   if pixel_values is None:                                                          │
│    865 │   │   │   raise ValueError("You have to specify pixel_values")                          │
│    866 │   │                                                                                     │
│ ❱  867 │   │   hidden_states = self.embeddings(pixel_values)                                     │
│    868 │   │   hidden_states = self.pre_layrnorm(hidden_states)                                  │
│    869 │   │                                                                                     │
│    870 │   │   encoder_outputs = self.encoder(                                                   │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1501 in _call_impl            │
│                                                                                                  │
│   1498 │   │   if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks   │
│   1499 │   │   │   │   or _global_backward_pre_hooks or _global_backward_hooks                   │
│   1500 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                   │
│ ❱ 1501 │   │   │   return forward_call(*args, **kwargs)                                          │
│   1502 │   │   # Do not call functions when jit is used                                          │
│   1503 │   │   full_backward_hooks, non_full_backward_hooks = [], []                             │
│   1504 │   │   backward_pre_hooks = []                                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/clipseg/modeling_clipseg.py:215 in   │
│ forward                                                                                          │
│                                                                                                  │
│    212 │   │                                                                                     │
│    213 │   │   if embeddings.shape[1] != self.num_positions:                                     │
│    214 │   │   │   new_shape = int(math.sqrt(embeddings.shape[1] - 1))                           │
│ ❱  215 │   │   │   embeddings = embeddings + self.interpolate_position_embeddings((new_shape, n  │
│    216 │   │   │   embeddings = embeddings.to(embeddings.dtype)                                  │
│    217 │   │   else:                                                                             │
│    218 │   │   │   embeddings = embeddings + self.position_embedding(self.position_ids)          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: The size of tensor a (3151) must match the size of tensor b (3137) at non-singleton dimension 1


@piust OK, thanks for trying. Could you share the PNG image and the agent being used so that we can reproduce to try and debug? 

Hi all,
I confirm that on my set of images, the image segmenter tool has the same behavior with the same issue of matrix dimensions conflicts. Images are PNG of different sizes. Same problem whatever the image dimensions.

[image sample](https://drive.google.com/file/d/1n95JCjltE1WYBjrktgrbyy4uBB1ckBQD/view?usp=share_link)

@jeromemassot Thanks for sharing the image. Using it I was able to track down the issue to [this line](https://github.com/huggingface/transformers/blob/00f6ba0e7ebd5d19bb7d834a709d74dbb8a5a3d9/src/transformers/tools/image_segmentation.py#L47) in the image segmentation tool, where the `size` parameter for the image processor is overridden with the input image dimensions. I've opened an PR to resolve, but will need to check that this isn't removing any assumptions elsewhere with the tools.