> 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`   | このステップの一意の識別子を入力してください。                                                           | ❌  |
| `バージョン`    | `str`   | 使用するモデル。hiera\_large、hiera\_small、hiera\_tiny、hiera\_b\_plus のいずれか。               | ✅  |
| `しきい値`     | `float` | 予測マスクのスコアの閾値。                                                                     | ✅  |
| `マルチマスク出力` | `bool`  | sam2 の内部マルチマスクモードを使用するか、シングルマスクモードを使用するかを決定するフラグ。あいまいなプロンプトでは True に設定することを推奨します。 | ✅  |

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

### ランタイム互換性

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

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

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

<details>

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

* 入力
  * `画像` ([*`画像`*](/workflows/ja/gaido/developer-guide/kinds/image.md)）：推論対象の画像です。
  * `ボックス` (*Union\[*[*`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)*,* [*`object_detection_prediction`*](/workflows/ja/gaido/developer-guide/kinds/object-detection-prediction.md)*]*): ポリゴンに変換するバウンディングボックス（別のモデルからのもの）。
  * `バージョン` ([*`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)): 予測マスクのスコアの閾値。
  * `マルチマスク出力` ([*`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>
