> 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/models/ja/supported-models/easyocr.md).

# EasyOCR

[EasyOCR](https://github.com/JaidedAI/EasyOCR) は、多言語の光学文字認識モデルで、当社の [Serverless Cloud API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api)を通じてデプロイ可能です。対応言語には、英語、日本語、カンナダ語、韓国語、ラテン文字（スペイン語、フランス語、イタリア語、ポルトガル語、ドイツ語、ポーランド語、オランダ語を含む）、テルグ語、簡体字中国語が含まれます。

## EasyOCR API

EasyOCR を HTTP エンドポイント経由で直接実行するには、 `curl`、または [`inference-sdk`](https://docs.roboflow.com/reference/inference/inference-sdk) ラッパーを使用します。

{% tabs %}
{% tab title="HTTP（curl）" icon="webhook" %}
{% stepper %}
{% step %}

### APIキーを取得する

Roboflow アカウントを作成し、 [Roboflow API 設定ページ](https://app.roboflow.com/settings/api) でキーを見つけ、シェルで利用できるようにします。

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### モデルを実行する

次を呼び出します `/easy_ocr/ocr` エンドポイントを `curl`:

```bash
curl --location 'https://serverless.roboflow.com/easy_ocr/ocr' \
  --header 'Content-Type: application/json' \\
  --header "Authorization: Bearer $ROBOFLOW_API_KEY" \\
  --data '{
    "image": {"type": "url", "value": "https://media.roboflow.com/swift.png"},
    "language_codes": ["en"]
  }'
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK（Python）" icon="python" %}
{% stepper %}
{% step %}

### APIキーを取得する

Roboflow アカウントを作成し、 [Roboflow API 設定ページ](https://app.roboflow.com/settings/api) でキーを見つけ、シェルで利用できるようにします。

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### 依存関係をインストールする

このパッケージは次のモデルを呼び出します:

```bash
pip install -U inference-sdk supervision
```

{% endstep %}

{% step %}

### モデルを実行する

画像に対して EasyOCR を実行:

```python
import os
import supervision as sv
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

image = sv.load_image_from_url("https://media.roboflow.com/swift.png")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))

result = client.ocr_image(
    inference_input=image,
    model="easy_ocr",
    language_codes=["en"],
)

print(result["result"]) # 抽出されたテキスト
```

上記のコードは推論結果をターミナルに出力します:

```
今日はふと、いわゆる各『Eras』を通ってきたのだなと思っていた。まさにメタだ。Midnights アルバムを聴いた後に、スウィフトさんの音楽を聴き始めた。アルバムを初めて聴いてから数週間後、さまざまな曲を繰り返し再生している自分に気づいた。アルバムを順番に何度も聴いた:
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## EasyOCR の推論速度

次で測定したレイテンシー [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 1台のNVIDIA L4、バッチサイズ1、ウォームアップ後の平均で測定。

<table data-search="false"><thead><tr><th>モデル</th><th>レイテンシー（ms）</th></tr></thead><tbody><tr><td><code>easy_ocr</code></td><td>19.7</td></tr></tbody></table>

完全なドキュメント画像で測定（テキスト検出と認識を含む）。

{% hint style="info" %}
設定する `api_url` をデプロイ先に合わせます:

* `https://serverless.roboflow.com` サーバーレスクラウドAPI用。
* `http://localhost:9001` ローカルの [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) サーバー用。
* あなたの [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) プライベートエンドポイント用のURL。
  {% endhint %}
