> 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/roboflow/roboflow-jp/workflows/build-a-workflow.md).

# Workflow を構築

Workflow は block で構成され、それぞれがモデル推論の実行、ロジックの処理、外部サービスとの連携などの特定のタスクを実行します。

利用可能な block の一覧をさらに詳しく知るには、こちらの [block documentation](https://inference.roboflow.com/workflows/blocks/).

### 概要

このガイドでは、object detection model を実行し、予測をカウントし、モデル結果を可視化する 4 block の workflow の作成方法を説明します。以下が [最終 workflow テンプレート](https://app.roboflow.com/workflows/embed/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3b3JrZmxvd0lkIjoiMmdqakJxMDV3Q01ac1hHM3hkeFAiLCJ3b3Jrc3BhY2VJZCI6ImtyT1RBYm5jRmhvUU1DZExPbGU0IiwidXNlcklkIjoiSW1GTElaU2tHYk55OXpiNFV1cWxNelBScHBRMiIsImlhdCI6MTczODE4ODk5MH0.f72WI5bdjtnwC8iqXF_XiUVarfOktIAH1egpsI0Oh4Q) です。これに沿って進めてください。

{% embed url="<https://app.roboflow.com/workflows/embed/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3b3JrZmxvd0lkIjoiMmdqakJxMDV3Q01ac1hHM3hkeFAiLCJ3b3Jrc3BhY2VJZCI6ImtyT1RBYm5jRmhvUU1DZExPbGU0IiwidXNlcklkIjoiSW1GTElaU2tHYk55OXpiNFV1cWxNelBScHBRMiIsImlhdCI6MTczODE4ODk5MH0.f72WI5bdjtnwC8iqXF_XiUVarfOktIAH1egpsI0Oh4Q>" fullWidth="false" %}

<figure><img src="/files/35eea4fcd1c513f9324d86f1c1a5f03975149405" alt="" width="563"><figcaption><p>Detect, Count, and Visualize Workflow</p></figcaption></figure>

### Block Connections

構築を始める前に、block connection の仕組みを理解しておくことが重要です。

ある場所に block を追加するには、前の block を input として使用する必要があります。例えば、上に示した workflow では、 *Property Definition* block は *Object Detection* block の後に配置されます。なぜなら、その block は model block を input として使用するからです。次の *Bounding Box Visualization* block は右側にあります。これは、 *Property Definition* block の output は使わず、model output は参照するためです。

<figure><img src="/files/748d251b11c4c481b195ce2c0fa23e98f3e332e5" alt=""><figcaption><p>Model Comparison Workflow</p></figcaption></figure>

上の example workflow には 4 つの distinct な path があります。各 branch は runtime で並列に実行され、他の branch の block を input として必要としないためです。

### Builder Assist

Builder Assist は、workflow editor で block を接続・挿入する際にどれだけ支援するかを制御します。右上の navbar にある toggle でモードを切り替えられます。

モードは 3 つあります:

* **Auto** (default): block を接続または挿入すると、互換性のある input と output の field を自動で配線します。builder は、block を削除または切断したときに downstream の参照も修復します。
* **Quick**: 推奨される connection と block の recommendation を表示しますが、明示的に承認した場合にのみ適用されます。builder に変更を任せずにガイダンスだけ欲しい場合に便利です。
* **Manual**: 提案も自動配線もありません。すべての connection を自分で管理します。

選択した mode はローカルに保存されるため、セッションをまたいで保持されます。

### Workflow の作成

#### Object Detection Model

最初に、1 つの *Object Detection Model* block を追加します。公開 pre-trained model の例として、 [COCO](https://universe.roboflow.com/microsoft/coco)で学習された YOLOv8n のような *yolov8n* model と、workspace 内の fine-tuned model のどちらかを選べます。ここでは pre-trained

<figure><img src="/files/174343d9d284c6b6eeb6d17e61d3b7a4ca7129ab" alt="" width="344"><figcaption></figcaption></figure>

object detection block には、モデルが何を対象に inference するかを決める必須の image parameter があります。ほかにもいくつかの optional parameter がありますが、主要なものを以下で詳しく説明します:

* Class Filter: モデルが返す class の一覧です。注: モデルが返せるのは、学習済みの class のみです。これにより、不要な class を除外できます。
* Confidence: その confidence 未満の object は返されません。
* IoU threshold: threshold を高くすると、重なり合う prediction がより多く返されます。0.9 は 90% 以下の overlap の object が返されることを意味し、0.1 は 10% を超える overlap の object は含まれないことを意味します。
* Max Detections: モデルが返す object の最大数
* Class Agnostic NMS: overlap filtering で、同じ class の object のみを比較して除外するか、すべての class を対象にするかを指定します

#### Property Definition

Property Definition block を使うと、image size、predicted class、検出された object 数など、data から関連情報を抽出できます。この例では、object detection model が見つけた object の数をカウントします。

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc507UbRnkEH6XMdrfmwVZbHcK6x6K5THwnt1RmEk8iXSojwvmiA_q6KwRXV9bJudYnW7NMTQKKb9GqGxm_P0VjbuOoGWcDsM5NoQckl9jV4YcjYQFIvYoCgvd_YnQTNJLlwdbZwA?key=yGJPQzp1abf4J7pT0mnBw8w4" alt="" width="375"><figcaption></figcaption></figure>

次の *Data* property では model prediction を参照します。次の *Operations*では、Count Items を選択します。この設定により、object detection model が行った prediction の数が返されます。

#### Bounding Box Visualization

モデル結果を可視化するために、bounding box visualization block を追加します。次の *image* parameter では input image を選択します。predictions では model results を選択します。必要に応じて、optional configuration property を使って bounding box の色やサイズを変更できます。

<figure><img src="/files/cc57ad62cb2fa829a7abf622f8a5ca5138e50473" alt="" width="342"><figcaption></figcaption></figure>

#### Label Visualization

bounding box を描画するだけでなく、prediction の class 名も表示したいはずです。これを行うには、1 つの *Label Visualization* block を bounding box visualization の後ろに追加します。bounding box と label を同じ image 上に描画するには、参照する input image を次のように設定します。 *bounding\_box\_visualization* image にします。input image を参照するのではなく、こちらを参照します。これにより、label が bounding box の上に描画されます。

<figure><img src="/files/e7cb5c6eea7ab71ad5708a07e4494ef2cd307191" alt="" width="343"><figcaption></figcaption></figure>

optional の *Text* parameter を変更すると、表示テキストを class name、confidence、class name と confidence のいずれかに変えられます。

### 変更の保存

Workflow editor は変更を draft として自動保存します。編集時に手動で保存する必要はありません。

変更を公開するには、Workflow を publish します。Workflow を deployed している場合、公開版は Workflow が deployed されているすべての device で実行され始めます。

workflow が完成したので、テストする時間です。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-jp/workflows/build-a-workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
