<h3 dir="auto">System Info</h3>
<ul dir="auto">
<li><code class="notranslate">transformers</code> version: 4.29.0.dev0</li>
<li>Platform: Linux-3.10.0-957.12.2.el7.x86_64-x86_64-with-glibc2.10</li>
<li>Python version: 3.8.3</li>
<li>Huggingface_hub version: 0.13.4</li>
<li>Safetensors version: not installed</li>
<li>PyTorch version (GPU?): 1.5.0 (True)</li>
<li>Tensorflow version (GPU?): not installed (NA)</li>
<li>Flax version (CPU?/GPU?/TPU?): not installed (NA)</li>
<li>Jax version: not installed</li>
<li>JaxLib version: not installed</li>
<li>Using GPU in script?: </li>
<li>Using distributed or parallel set-up in script?: </li>
</ul>
<h3 dir="auto">Who can help?</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Information</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> The official example scripts</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> My own modified scripts</li>
</ul>
<h3 dir="auto">Tasks</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> An officially supported task in the <code class="notranslate">examples</code> folder (such as GLUE/SQuAD, ...)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> My own task or dataset (give details below)</li>
</ul>
<h3 dir="auto">Reproduction</h3>
<p dir="auto">img_url = "<a href="https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png" rel="nofollow">https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png</a>"<br>
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB")<br>
input_points = [[[450, 600]]]  # 2D location of a window in the image</p>
<p dir="auto">inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to(device)<br>
outputs = model(**inputs)</p>
<p dir="auto">masks = processor.image_processor.post_process_masks(<br>
outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu()<br>
)<br>
scores = outputs.iou_scores</p>
<h3 dir="auto">Expected behavior</h3>
<hr>
<p dir="auto">RuntimeError                              Traceback (most recent call last)<br>
 in <br>
4<br>
5 inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to(device)<br>
----&gt; 6 outputs = model(**inputs)<br>
7<br>
8 masks = processor.image_processor.post_process_masks(</p>
<p dir="auto">~/miniconda3/envs/pytorch/lib/python3.8/site-packages/torch/nn/modules/module.py in <strong>call</strong>(self, *input, **kwargs)<br>
548             result = self._slow_forward(*input, **kwargs)<br>
549         else:<br>
--&gt; 550             result = self.forward(*input, **kwargs)<br>
551         for hook in self._forward_hooks.values():<br>
552             hook_result = hook(self, input, result)</p>
<p dir="auto">~/miniconda3/envs/pytorch/lib/python3.8/site-packages/transformers/models/sam/modeling_sam.py in forward(self, pixel_values, input_points, input_labels, input_boxes, input_masks, image_embeddings, multimask_output, output_attentions, output_hidden_states, return_dict, **kwargs)<br>
1331             )<br>
1332<br>
-&gt; 1333         sparse_embeddings, dense_embeddings = self.prompt_encoder(<br>
1334             input_points=input_points,<br>
1335             input_labels=input_labels,</p>
<p dir="auto">~/miniconda3/envs/pytorch/lib/python3.8/site-packages/torch/nn/modules/module.py in <strong>call</strong>(self, *input, **kwargs)<br>
548             result = self._slow_forward(*input, **kwargs)<br>
549         else:<br>
--&gt; 550             result = self.forward(*input, **kwargs)<br>
551         for hook in self._forward_hooks.values():<br>
552             hook_result = hook(self, input, result)</p>
<p dir="auto">~/miniconda3/envs/pytorch/lib/python3.8/site-packages/transformers/models/sam/modeling_sam.py in forward(self, input_points, input_labels, input_boxes, input_masks)<br>
669             if input_labels is None:<br>
670                 raise ValueError("If points are provided, labels must also be provided.")<br>
--&gt; 671             point_embeddings = self._embed_points(input_points, input_labels, pad=(input_boxes is None))<br>
672             sparse_embeddings = torch.empty((batch_size, point_batch_size, 0, self.hidden_size), device=target_device)<br>
673             sparse_embeddings = torch.cat([sparse_embeddings, point_embeddings], dim=2)</p>
<p dir="auto">~/miniconda3/envs/pytorch/lib/python3.8/site-packages/transformers/models/sam/modeling_sam.py in _embed_points(self, points, labels, pad)<br>
619             padding_point = torch.zeros(target_point_shape, device=points.device)<br>
620             padding_label = -torch.ones(target_labels_shape, device=labels.device)<br>
--&gt; 621             points = torch.cat([points, padding_point], dim=2)<br>
622             labels = torch.cat([labels, padding_label], dim=2)<br>
623         input_shape = (self.input_image_size, self.input_image_size)</p>
<p dir="auto">RuntimeError: Expected object of scalar type double but got scalar type float for sequence element 1.</p>
<h3 dir="auto">System Info</h3>
<ul dir="auto">
<li><code class="notranslate">transformers</code> version: 4.29.0.dev0</li>
<li>Platform: macOS-13.2-arm64-arm-64bit</li>
<li>Python version: 3.10.6</li>
<li>Huggingface_hub version: 0.13.4</li>
<li>Safetensors version: 0.3.0</li>
<li>PyTorch version (GPU?): 1.13.0 (False)</li>
<li>Tensorflow version (GPU?): not installed (NA)</li>
<li>Flax version (CPU?/GPU?/TPU?): 0.6.9 (cpu)</li>
<li>Jax version: 0.4.8</li>
<li>JaxLib version: 0.4.7</li>
<li>Using GPU in script?: NO</li>
<li>Using distributed or parallel set-up in script?: NO</li>
</ul>
<p dir="auto">Dependencies</p>
<ul dir="auto">
<li>torch = 1.13.0</li>
<li>numpy = 1.23.4</li>
</ul>
<h3 dir="auto">Who can help?</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Information</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> The official example scripts</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> My own modified scripts</li>
</ul>
<h3 dir="auto">Tasks</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> An officially supported task in the <code class="notranslate">examples</code> folder (such as GLUE/SQuAD, ...)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> My own task or dataset (give details below)</li>
</ul>
<h3 dir="auto">Reproduction</h3>
<ol dir="auto">
<li>Pull <a href="https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb">SAM Notebook example</a></li>
<li>Run notebook up until</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="masks = processor.image_processor.post_process_masks(outputs.pred_masks.cpu(), inputs[&quot;original_sizes&quot;].cpu(), inputs[&quot;reshaped_input_sizes&quot;].cpu())"><pre class="notranslate"><code class="notranslate">masks = processor.image_processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu())
</code></pre></div>
<ol start="3" dir="auto">
<li>Get error</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: upsample_bilinear2d() received an invalid combination of arguments - got (Tensor, list, bool, NoneType), but expected one of:
 * (Tensor input, tuple of SymInts output_size, bool align_corners, tuple of floats scale_factors)
      didn't match because some of the arguments have invalid types: (Tensor, !list!, bool, !NoneType!)
 * (Tensor input, tuple of SymInts output_size, bool align_corners, float scales_h, float scales_w, *, Tensor out)"><pre class="notranslate"><code class="notranslate">TypeError: upsample_bilinear2d() received an invalid combination of arguments - got (Tensor, list, bool, NoneType), but expected one of:
 * (Tensor input, tuple of SymInts output_size, bool align_corners, tuple of floats scale_factors)
      didn't match because some of the arguments have invalid types: (Tensor, !list!, bool, !NoneType!)
 * (Tensor input, tuple of SymInts output_size, bool align_corners, float scales_h, float scales_w, *, Tensor out)
</code></pre></div>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">original_sizes/output_sizes to be of the expected type, is this a dependency issue?</p>