> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/workflows/ja/burokku/blocks/run-a-model/segment-anything2-model.md).

# Segment Anything 2モデル

ゼロショットのインスタンスセグメンテーションモデルである Segment Anything 2 を画像に対して実行します。

\*\* 専用の推論サーバーが必要です（GPU 推奨） \*\*

他のモデルからのボックス/予測を Segment Anything 2 に渡して、モデルへのプロンプトとして使用できます。他のモデルからボックス検出を渡すと、ボックスのクラス名が予測マスクに引き継がれます。プロンプトなしでモデルを使用する場合、モデルは整数をクラス名 / ID として割り当てます。

### 型識別子

ステップで次の識別子を使用してください `"type"` フィールド： `roboflow_core/segment_anything@v1` ワークフローにこのブロックをステップとして追加するには。

### プロパティ

| **名前**             | **型**   | **説明**                                                                          | 参照 |
| ------------------ | ------- | ------------------------------------------------------------------------------- | -- |
| `name`             | `str`   | このステップの一意の識別子を入力してください。                                                         | ❌  |
| `version`          | `str`   | 使用するモデル。hiera\_large、hiera\_small、hiera\_tiny、hiera\_b\_plus のいずれか。             | ✅  |
| `のしきい値と比較します`      | `float` | 予測マスクのスコアのしきい値。                                                                 | ✅  |
| `multimask_output` | `bool`  | sam2 の内部マルチマスクモードを使用するか、シングルマスクモードを使用するかを決定するフラグ。曖昧なプロンプトでは True に設定することを推奨します。 | ✅  |

この **参照** 列は、で利用可能な動的値を使ってプロパティをパラメータ化できる可能性を示します `ワークフロー` 実行時。参照 *バインディング* 詳細は。

### ランタイム互換性

`ハード` - ランタイム `self_hosted_cpu`；実行 `ローカル` : GPU が必要です。run\_locally() は CUDA を必要とするモデルを読み込みます。

### 入力と出力のバインディング

利用可能な接続は、そのバインディング種別によって異なります。どのバインディング種別が `Segment Anything 2モデル` のバージョン `v1` あるか確認してください。

<details>

<summary>入力と出力のバインディング</summary>

* 入力
  * `images` ([*`image`*](/workflows/ja/gaido/developer-guide/kinds/image.md)): 推論対象の画像です..
  * `ボックス` (*Union\[*[*`object_detection_prediction`*](/workflows/ja/gaido/developer-guide/kinds/object-detection-prediction.md)*,* [*`instance_segmentation_prediction`*](/workflows/ja/gaido/developer-guide/kinds/instance-segmentation-prediction.md)*,* [*`keypoint_detection_prediction`*](/workflows/ja/gaido/developer-guide/kinds/keypoint-detection-prediction.md)*]*）：ポリゴンに変換するバウンディングボックス（別のモデルから）。
  * `version` ([*`string`*](/workflows/ja/gaido/developer-guide/kinds/string.md)）：使用するモデル。hiera\_large、hiera\_small、hiera\_tiny、hiera\_b\_plus のいずれか。
  * `のしきい値と比較します` ([*`float`*](/workflows/ja/gaido/developer-guide/kinds/float.md)）：予測マスクのスコアのしきい値。
  * `multimask_output` ([*`boolean`*](/workflows/ja/gaido/developer-guide/kinds/boolean.md)）：sam2 の内部マルチマスクモードを使用するか、シングルマスクモードを使用するかを決定するフラグ。曖昧なプロンプトでは True に設定することを推奨します。
* 出力
  * `predictions` ([`instance_segmentation_prediction`](/workflows/ja/gaido/developer-guide/kinds/instance-segmentation-prediction.md)): 検出されたバウンディングボックスとセグメンテーションマスクを sv.Detections(...) オブジェクトの形式で持つ予測。

</details>

<details>

<summary>JSON 定義の例</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/segment_anything@v1",
	    "images": "$inputs.image",
	    "boxes": "$steps.object_detection_model.predictions",
	    "version": "hiera_large",
	    "threshold": 0.3,
	    "multimask_output": true
	}
```

</details>
