重要
Azure Content Moderator は 2024 年 2 月の時点で非推奨となり、2027 年 3 月 15 日に廃止されます。 これは、高度な AI 機能と強化されたパフォーマンスを提供する Azure AI Content Safety に置き換えられます。
Azure AI Content Safetyは、アプリケーションやサービスで有害なユーザー生成コンテンツと AI 生成コンテンツを検出するように設計された包括的なソリューションです。 Azure AI Content Safetyは、オンライン マーケットプレース、ゲーム会社、ソーシャル メッセージング プラットフォーム、エンタープライズ メディア企業、K-12 教育ソリューション プロバイダーなどの多くのシナリオに適しています。 その機能の概要を次に示します。
- テキストおよび画像検出 API: テキストと画像をスキャンして、複数の重大度レベルで性的なコンテンツ、暴力、ヘイト、自傷行為を検出します。
- Content Safety Studio: 最新のコンテンツ モデレーション ML モデルを使用して、攻撃的、危険、または望ましくない可能性のあるコンテンツを処理するように設計されたオンライン ツール。 ユーザーが独自のコンテンツ モデレーション システムを構築できるようにするテンプレートとカスタマイズされたワークフローが提供されます。
- Language のサポート: Azure AI Content Safetyは 100 を超える言語をサポートしており、英語、ドイツ語、日本語、スペイン語、フランス語、イタリア語、ポルトガル語、中国語で特別にトレーニングされています。
Azure AI Content Safetyは、コンテンツ モデレーションのニーズに合わせて堅牢で柔軟なソリューションを提供します。 Content Moderator から Azure AI Content Safety に切り替えることで、最新のツールとテクノロジを利用して、コンテンツが正確な仕様に常にモデレートされるようにすることができます。
Azure AI Content Safety の詳細を確認し、コンテンツ モデレーション戦略を向上させる方法を探ってみましょう。
.NET用の Azure Content Moderator クライアント ライブラリの使用を開始します。 NuGet パッケージをインストールし、基本的なタスクのコード例を試すには、次の手順に従います。
Content Moderator は、不快、危険、または望ましくない可能性のあるコンテンツを処理できる AI サービスです。 AI を利用したコンテンツ モデレーション サービスを使用して、テキスト、画像、ビデオをスキャンし、コンテンツ フラグを自動的に適用します。 規制に準拠したり、ユーザーの目的の環境を維持したりするために、コンテンツ フィルタリング ソフトウェアをアプリに組み込みます。
.NET用の Content Moderator クライアント ライブラリを使用して、次の目的で使用します。
- テキストをモデレートする
- 画像をモデレートする
リファレンスのドキュメント | ライブラリのソース コード | パッケージ (NuGet) | サンプル
前提 条件
- Azure サブスクリプション - 無料で作成します
- Visual Studio IDE または現在のバージョンの .NET Core。
- Azure サブスクリプションを取得したら、Azure ポータルで Content Moderator リソース を作成して、キーとエンドポイントを取得します。 デプロイされるまで待ってから、[ リソースに移動 ] ボタンをクリックします。
- アプリケーションを Content Moderator に接続するには、作成したリソースのキーとエンドポイントが必要です。 キーとエンドポイントは、クイックスタートの後半のコードに貼り付けます。
- Free 価格レベル (
F0) を使用してサービスを試し、後で運用環境用の有料レベルにアップグレードできます。
セットアップ
新しい C# アプリケーションを作成する
Visual Studioを使用して、新しい .NET Core アプリケーションを作成します。
クライアント ライブラリをインストールする
新しいプロジェクトを作成したら、Microsoft.Azure.CognitiveServices.ContentModerator を検索します。 バージョン 2.0.0を選択し、[ インストール] を選択します。
ヒント
クイック スタート コード ファイル全体を一度に表示しますか? このクイック スタートのコード例を含む GitHub で確認できます。
プロジェクト ディレクトリから、任意のエディターまたは IDE で Program.cs ファイルを開きます。 次の using ステートメントを追加します。
using Microsoft.Azure.CognitiveServices.ContentModerator;
using Microsoft.Azure.CognitiveServices.ContentModerator.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
Program クラスで、リソースのキーとエンドポイントの変数を作成します。
重要
Azure ポータルに移動します。 [前提条件] セクションで作成した Content Moderator リソースが正常にデプロイされた場合は、[次の手順] の [リソースに移動] ボタンをクリックします。 キーとエンドポイントは、リソースの [キーとエンドポイント ] ページの [ リソース管理] で確認できます。
// Your Content Moderator subscription key is found in your Azure portal resource on the 'Keys' page.
private static readonly string SubscriptionKey = "PASTE_YOUR_CONTENT_MODERATOR_SUBSCRIPTION_KEY_HERE";
// Base endpoint URL. Found on 'Overview' page in Azure resource. For example: https://westus.api.cognitive.microsoft.com
private static readonly string Endpoint = "PASTE_YOUR_CONTENT_MODERATOR_ENDPOINT_HERE";
重要
完了したら、コードからキーを削除し、公開しないでください。 運用環境では、
アプリケーションの main() メソッドで、このクイック スタートで使用するメソッドの呼び出しを追加します。 これらは後で作成します。
// Create an image review client
ContentModeratorClient clientImage = Authenticate(SubscriptionKey, Endpoint);
// Create a text review client
ContentModeratorClient clientText = Authenticate(SubscriptionKey, Endpoint);
// Create a human reviews client
ContentModeratorClient clientReviews = Authenticate(SubscriptionKey, Endpoint);
// Moderate text from text in a file
ModerateText(clientText, TextFile, TextOutputFile);
// Moderate images from list of image URLs
ModerateImages(clientImage, ImageUrlFile, ImageOutputFile);
オブジェクト モデル
次のクラスは、Content Moderator .NET クライアント ライブラリの主要な機能の一部を処理します。
| 名前 | 説明 |
|---|---|
| ContentModeratorClient | このクラスは、Content Moderator のすべての機能に必要です。 サブスクリプション情報を使用してインスタンス化し、それを使用して他のクラスのインスタンスを生成します。 |
| ImageModeration | このクラスは、成人向けコンテンツ、個人情報、または人間の顔の画像を分析するための機能を提供します。 |
| TextModeration | このクラスは、言語、不適切な表現、エラー、個人情報のテキストを分析するための機能を提供します。 |
コード例
これらのコード スニペットは、.NET用の Content Moderator クライアント ライブラリで次のタスクを実行する方法を示しています。
クライアントを認証する
新しいメソッドで、エンドポイントとキーを使用してクライアント オブジェクトをインスタンス化します。
public static ContentModeratorClient Authenticate(string key, string endpoint)
{
ContentModeratorClient client = new ContentModeratorClient(new ApiKeyServiceClientCredentials(key));
client.Endpoint = endpoint;
return client;
}
テキストをモデレートする
次のコードでは、Content Moderator クライアントを使用してテキストの本文を分析し、結果をコンソールに出力します。 Program クラスのルートで、入力ファイルと出力ファイルを定義します。
// TEXT MODERATION
// Name of the file that contains text
private static readonly string TextFile = "TextFile.txt";
// The name of the file to contain the output from the evaluation.
private static string TextOutputFile = "TextModerationOutput.txt";
次に、プロジェクトのルートに 、TextFile.txt ファイルを追加します。 このファイルに独自のテキストを追加するか、次のサンプル テキストを使用します。
Is this a grabage email abcdef@abcd.com, phone: 4255550111, IP: 255.255.255.255, 1234 Main Boulevard, Panapolis WA 96555.
<offensive word> is the profanity here. Is this information PII? phone 4255550111
次に、 Program クラスのどこかにテキスト モデレーション メソッドを定義します。
/*
* TEXT MODERATION
* This example moderates text from file.
*/
public static void ModerateText(ContentModeratorClient client, string inputFile, string outputFile)
{
Console.WriteLine("--------------------------------------------------------------");
Console.WriteLine();
Console.WriteLine("TEXT MODERATION");
Console.WriteLine();
// Load the input text.
string text = File.ReadAllText(inputFile);
// Remove carriage returns
text = text.Replace(Environment.NewLine, " ");
// Convert string to a byte[], then into a stream (for parameter in ScreenText()).
byte[] textBytes = Encoding.UTF8.GetBytes(text);
MemoryStream stream = new MemoryStream(textBytes);
Console.WriteLine("Screening {0}...", inputFile);
// Format text
// Save the moderation results to a file.
using (StreamWriter outputWriter = new StreamWriter(outputFile, false))
{
using (client)
{
// Screen the input text: check for profanity, classify the text into three categories,
// do autocorrect text, and check for personally identifying information (PII)
outputWriter.WriteLine("Autocorrect typos, check for matching terms, PII, and classify.");
// Moderate the text
var screenResult = client.TextModeration.ScreenText("text/plain", stream, "eng", true, true, null, true);
outputWriter.WriteLine(JsonConvert.SerializeObject(screenResult, Formatting.Indented));
}
outputWriter.Flush();
outputWriter.Close();
}
Console.WriteLine("Results written to {0}", outputFile);
Console.WriteLine();
}
画像をモデレートする
次のコードでは、Content Moderator クライアントと ImageModeration オブジェクトを使用して、成人向けおよびわいせつなコンテンツのリモート 画像を分析します。
メモ
また、ローカル画像の内容を分析することもできます。 ローカル イメージで動作するメソッドと操作については、 リファレンス ドキュメント を参照してください。
サンプル 画像を取得する
Program クラスのルートで入力ファイルと出力ファイルを定義します。
// IMAGE MODERATION
//The name of the file that contains the image URLs to evaluate.
private static readonly string ImageUrlFile = "ImageFiles.txt";
// The name of the file to contain the output from the evaluation.
private static string ImageOutputFile = "ImageModerationOutput.json";
次に、プロジェクトのルートに入力ファイル ImageFiles.txtを作成します。 このファイルでは、分析する画像の URL (各行に 1 つの URL) を追加します。 次のサンプル イメージを使用できます。
https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpg
https://moderatorsampleimages.blob.core.windows.net/samples/sample5.png
ヘルパー クラスを定義する
Program クラス内に次のクラス定義を追加します。 この内部クラスは、画像のモデレーション結果を処理します。
// Contains the image moderation results for an image,
// including text and face detection results.
public class EvaluationData
{
// The URL of the evaluated image.
public string ImageUrl;
// The image moderation results.
public Evaluate ImageModeration;
// The text detection results.
public OCR TextDetection;
// The face detection results;
public FoundFaces FaceDetection;
}
イメージ モデレーション メソッドを定義する
次のメソッドは、テキスト ファイル内の画像 URL を反復処理し、 EvaluationData インスタンスを作成し、成人向け/わいせつなコンテンツ、テキスト、人間の顔の画像を分析します。 次に、最終的な EvaluationData インスタンスをリストに追加し、返されたデータの完全なリストをコンソールに書き込みます。
画像を反復処理する
/*
* IMAGE MODERATION
* This example moderates images from URLs.
*/
public static void ModerateImages(ContentModeratorClient client, string urlFile, string outputFile)
{
Console.WriteLine("--------------------------------------------------------------");
Console.WriteLine();
Console.WriteLine("IMAGE MODERATION");
Console.WriteLine();
// Create an object to store the image moderation results.
List<EvaluationData> evaluationData = new List<EvaluationData>();
using (client)
{
// Read image URLs from the input file and evaluate each one.
using (StreamReader inputReader = new StreamReader(urlFile))
{
while (!inputReader.EndOfStream)
{
string line = inputReader.ReadLine().Trim();
if (line != String.Empty)
{
Console.WriteLine("Evaluating {0}...", Path.GetFileName(line));
var imageUrl = new BodyModel("URL", line.Trim());
コンテンツの分析
Content Moderator で表示されるイメージ属性の詳細については、 イメージ モデレーションの概念ガイドを 参照してください。
var imageData = new EvaluationData
{
ImageUrl = imageUrl.Value,
// Evaluate for adult and racy content.
ImageModeration =
client.ImageModeration.EvaluateUrlInput("application/json", imageUrl, true)
};
Thread.Sleep(1000);
// Detect and extract text.
imageData.TextDetection =
client.ImageModeration.OCRUrlInput("eng", "application/json", imageUrl, true);
Thread.Sleep(1000);
// Detect faces.
imageData.FaceDetection =
client.ImageModeration.FindFacesUrlInput("application/json", imageUrl, true);
Thread.Sleep(1000);
// Add results to Evaluation object
evaluationData.Add(imageData);
}
}
}
モデレーション結果をファイルに書き込む
// Save the moderation results to a file.
using (StreamWriter outputWriter = new StreamWriter(outputFile, false))
{
outputWriter.WriteLine(JsonConvert.SerializeObject(
evaluationData, Formatting.Indented));
outputWriter.Flush();
outputWriter.Close();
}
Console.WriteLine();
Console.WriteLine("Image moderation results written to output file: " + outputFile);
Console.WriteLine();
}
}
アプリケーションを実行する
IDE ウィンドウの上部にある [デバッグ ] ボタンをクリックして、アプリケーションを実行します。
リソースのクリーンアップ
Azure AI サービス サブスクリプションをクリーンアップして削除する場合は、リソースまたはリソース グループを削除できます。 リソース グループを削除すると、それに関連付けられている他のリソースも削除されます。
次の手順
このクイックスタートでは、Content Moderator .NET ライブラリを使用してモデレーション タスクを実行する方法について説明しました。 次に、概念ガイドを読んで、画像やその他のメディアのモデレートについて詳しく学習します。
Java用の Azure Content Moderator クライアント ライブラリの使用を開始します。 Maven パッケージをインストールし、基本的なタスクのコード例を試すには、次の手順に従います。
Content Moderator は、不快、危険、または望ましくない可能性のあるコンテンツを処理できる AI サービスです。 AI を利用したコンテンツ モデレーション サービスを使用して、テキスト、画像、ビデオをスキャンし、コンテンツ フラグを自動的に適用します。 規制に準拠したり、ユーザーの目的の環境を維持したりするために、コンテンツ フィルタリング ソフトウェアをアプリに組み込みます。
Java用の Content Moderator クライアント ライブラリを使用して、次の目的で使用します。
- テキストをモデレートする
- 画像をモデレートする
リファレンス ドキュメント | ライブラリのソース コード |Artifact (Maven) | サンプル
前提 条件
- Azure サブスクリプション - 無料で作成します
Java Development Kit (JDK) - Gradle ビルド ツール、または別の依存関係マネージャー。
- Azure サブスクリプションを取得したら、Azure ポータルで Content Moderator リソース を作成して、キーとエンドポイントを取得します。 デプロイされるまで待ってから、[ リソースに移動 ] ボタンをクリックします。
- アプリケーションを Content Moderator に接続するには、作成したリソースのキーとエンドポイントが必要です。 キーとエンドポイントは、クイックスタートの後半のコードに貼り付けます。
- Free 価格レベル (
F0) を使用してサービスを試し、後で運用環境用の有料レベルにアップグレードできます。
セットアップ
新しい Gradle プロジェクトを作成する
コンソール ウィンドウ (cmd、PowerShell、Bash など) で、アプリ用の新しいディレクトリを作成し、そこに移動します。
mkdir myapp && cd myapp
作業ディレクトリから gradle init コマンドを実行します。 このコマンドは、実行時にアプリケーションの作成と構成に使用される build.gradle.kts など、Gradle の重要なビルド ファイルを作成します。
gradle init --type basic
DSL の選択を求められたら、[Kotlin] を選択します。
クライアント ライブラリをインストールする
build.gradle.kts を見つけて、任意の IDE またはテキスト エディターで開きます。 次に、次のビルド構成をコピーします。 この構成では、エントリ ポイントがクラス ContentModeratorQuickstart を持つJava アプリケーションとしてプロジェクトを定義します。 JSON シリアル化用の Content Moderator クライアント ライブラリと GSON sdk をインポートします。
plugins {
java
application
}
application{
mainClassName = "ContentModeratorQuickstart"
}
repositories{
mavenCentral()
}
dependencies{
compile(group = "com.microsoft.azure.cognitiveservices", name = "azure-cognitiveservices-contentmoderator", version = "1.0.2-beta")
compile(group = "com.google.code.gson", name = "gson", version = "2.8.5")
}
Java ファイルを作成する
作業ディレクトリから、次のコマンドを実行してプロジェクト ソース フォルダーを作成します。
mkdir -p src/main/java
新しいフォルダーに移動し、 ContentModeratorQuickstart.javaという名前のファイルを作成します。 任意のエディターまたは IDE で開き、次の import ステートメントを追加します。
import com.google.gson.*;
import com.microsoft.azure.cognitiveservices.vision.contentmoderator.*;
import com.microsoft.azure.cognitiveservices.vision.contentmoderator.models.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
ヒント
クイック スタート コード ファイル全体を一度に表示しますか? このクイック スタートのコード例を含む GitHub で確認できます。
アプリケーションの ContentModeratorQuickstart クラスで、リソースのキーとエンドポイントの変数を作成します。
重要
Azure ポータルに移動します。 [前提条件] セクションで作成した Content Moderator リソースが正常にデプロイされた場合は、[次の手順] の [リソースに移動] ボタンをクリックします。 キーとエンドポイントは、リソースの [キーとエンドポイント ] ページの [ リソース管理] で確認できます。
private static final String subscriptionKey = "<your-subscription-key>";
private static final String endpoint = "<your-api-endpoint>";
重要
完了したら、コードからキーを削除し、公開しないでください。 運用環境では、
アプリケーションの メイン メソッドで、このクイック スタートで使用するメソッドの呼び出しを追加します。 これらのメソッドは後で定義します。
// Create a List in which to store the image moderation results.
List<EvaluationData> evaluationData = new ArrayList<EvaluationData>();
// Moderate URL images
moderateImages(client, evaluationData);
// Moderate text from file
moderateText(client);
// Create a human review
humanReviews(client);
オブジェクト モデル
次のクラスは、Content Moderator Java クライアント ライブラリの主要な機能の一部を処理します。
| 名前 | 説明 |
|---|---|
| ContentModeratorClient | このクラスは、Content Moderator のすべての機能に必要です。 サブスクリプション情報を使用してインスタンス化し、それを使用して他のクラスのインスタンスを生成します。 |
| ImageModeration | このクラスは、成人向けコンテンツ、個人情報、または人間の顔の画像を分析するための機能を提供します。 |
| TextModerations | このクラスは、言語、不適切な表現、エラー、個人情報のテキストを分析するための機能を提供します。 |
コード例
これらのコード スニペットは、Java用の Content Moderator クライアント ライブラリで次のタスクを実行する方法を示しています。
クライアントを認証する
アプリケーションの main メソッドで、サブスクリプション エンドポイント値とサブスクリプション キーを使用して ContentModeratorClient オブジェクトを作成します。
// Set CONTENT_MODERATOR_SUBSCRIPTION_KEY in your environment settings, with
// your key as its value.
// Set COMPUTER_MODERATOR_ENDPOINT in your environment variables with your Azure
// endpoint.
ContentModeratorClient client = ContentModeratorManager.authenticate(AzureRegionBaseUrl.fromString(endpoint),
"CONTENT_MODERATOR_SUBSCRIPTION_KEY");
テキストをモデレートする
サンプル テキストを設定する
ContentModeratorQuickstart クラスの先頭で、ローカル テキスト ファイルへの参照を定義します。 .txt ファイルをプロジェクト ディレクトリに追加し、分析するテキストを入力します。
// TEXT MODERATION variable
private static File textFile = new File("src\\main\\resources\\TextModeration.txt");
テキストの分析
.txt ファイルを読み取り、各行で screenText メソッドを呼び出す新しいメソッドを作成します。
public static void moderateText(ContentModeratorClient client) {
System.out.println("---------------------------------------");
System.out.println("MODERATE TEXT");
System.out.println();
try (BufferedReader inputStream = new BufferedReader(new FileReader(textFile))) {
String line;
Screen textResults = null;
// For formatting the printed results
Gson gson = new GsonBuilder().setPrettyPrinting().create();
while ((line = inputStream.readLine()) != null) {
if (line.length() > 0) {
textResults = client.textModerations().screenText("text/plain", line.getBytes(), null);
// Uncomment below line to print in console
// System.out.println(gson.toJson(textResults).toString());
}
}
テキスト モデレーションの結果を印刷する
次のコードを追加して、モデレーションの結果をプロジェクト ディレクトリ内の .json ファイルに出力します。
System.out.println("Text moderation status: " + textResults.status().description());
System.out.println();
// Create output results file to TextModerationOutput.json
BufferedWriter writer = new BufferedWriter(
new FileWriter(new File("src\\main\\resources\\TextModerationOutput.json")));
writer.write(gson.toJson(textResults).toString());
System.out.println("Check TextModerationOutput.json to see printed results.");
System.out.println();
writer.close();
tryステートメントと catch ステートメントを閉じて、メソッドを完了します。
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
画像をモデレートする
サンプル イメージを設定する
新しいメソッドで、画像を指す特定の URL 文字列を使用して BodyModelModel オブジェクトを構築します。
public static void moderateImages(ContentModeratorClient client, List<EvaluationData> resultsList) {
System.out.println();
System.out.println("---------------------------------------");
System.out.println("MODERATE IMAGES");
System.out.println();
try {
String urlString = "https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpg";
// Evaluate each line of text
BodyModelModel url = new BodyModelModel();
url.withDataRepresentation("URL");
url.withValue(urlString);
// Save to EvaluationData class for later
EvaluationData imageData = new EvaluationData();
imageData.ImageUrl = url.value();
ヘルパー クラスを定義する
次に、 ContentModeratorQuickstart.java ファイルで、 ContentModeratorQuickstart クラス内に次のクラス定義を追加します。 この内部クラスは、イメージ モデレーション プロセスで使用されます。
// Contains the image moderation results for an image, including text and face
// detection from the image.
public static class EvaluationData {
// The URL of the evaluated image.
public String ImageUrl;
// The image moderation results.
public Evaluate ImageModeration;
// The text detection results.
public OCR TextDetection;
// The face detection results;
public FoundFaces FaceDetection;
}
コンテンツの分析
このコード行は、指定された URL の画像で成人向けまたはわいせつなコンテンツをチェックします。 これらの用語の詳細については、イメージ モデレーションの概念ガイドを参照してください。
// Evaluate for adult and racy content.
imageData.ImageModeration = client.imageModerations().evaluateUrlInput("application/json", url,
new EvaluateUrlInputOptionalParameter().withCacheImage(true));
Thread.sleep(1000);
テキストを確認する
このコード行は、画像に表示されるテキストをチェックします。
// Detect and extract text from image.
imageData.TextDetection = client.imageModerations().oCRUrlInput("eng", "application/json", url,
new OCRUrlInputOptionalParameter().withCacheImage(true));
Thread.sleep(1000);
顔を確認する
このコード行は、人間の顔の画像をチェックします。
// Detect faces.
imageData.FaceDetection = client.imageModerations().findFacesUrlInput("application/json", url,
new FindFacesUrlInputOptionalParameter().withCacheImage(true));
Thread.sleep(1000);
最後に、返された情報を EvaluationData リストに格納します。
resultsList.add(imageData);
結果を印刷する
while ループの後に、次のコードを追加します。コンソールと出力ファイル src/main/resources/ModerationOutput.jsonに結果が出力されます。
// Save the moderation results to a file.
// ModerationOutput.json contains the output from the evaluation.
// Relative paths are relative to the execution directory (where pom.xml is
// located).
BufferedWriter writer = new BufferedWriter(
new FileWriter(new File("src\\main\\resources\\ImageModerationOutput.json")));
// For formatting the printed results
Gson gson = new GsonBuilder().setPrettyPrinting().create();
writer.write(gson.toJson(resultsList).toString());
System.out.println("Check ImageModerationOutput.json to see printed results.");
writer.close();
try ステートメントを閉じ、catch ステートメントを追加してメソッドを完了します。
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
アプリケーションを実行する
次の方法でアプリをビルドできます。
gradle build
gradle run コマンドを使用してアプリケーションを実行します。
gradle run
次に 、src/main/resources/ModerationOutput.json ファイルに移動し、コンテンツ モデレーションの結果を表示します。
リソースのクリーンアップ
Azure AI サービス サブスクリプションをクリーンアップして削除する場合は、リソースまたはリソース グループを削除できます。 リソース グループを削除すると、それに関連付けられている他のリソースも削除されます。
次の手順
このクイック スタートでは、Content Moderator Java ライブラリを使用してモデレーション タスクを実行する方法について説明しました。 次に、概念ガイドを読んで、画像やその他のメディアのモデレートについて詳しく学習します。
Python用の Azure Content Moderator クライアント ライブラリの使用を開始します。 PiPy パッケージをインストールし、基本的なタスクのコード例を試すには、次の手順に従います。
Content Moderator は、不快、危険、または望ましくない可能性のあるコンテンツを処理できる AI サービスです。 AI を利用したコンテンツ モデレーション サービスを使用して、テキスト、画像、ビデオをスキャンし、コンテンツ フラグを自動的に適用します。 規制に準拠したり、ユーザーの目的の環境を維持したりするために、コンテンツ フィルタリング ソフトウェアをアプリに組み込みます。
Python用の Content Moderator クライアント ライブラリを使用して、次の目的で使用します。
- テキストをモデレートする
- カスタム用語リストを使用する
- 画像をモデレートする
- カスタム イメージ リストを使用する
リファレンス ドキュメント | ライブラリのソース コード | パッケージ (PiPy) | サンプル
前提 条件
- Azure サブスクリプション - 無料で作成します
-
Python 3.x
- Pythonインストールには、pipが含まれている必要があります。 コマンド ラインで
pip --versionを実行することで、pip がインストールされているかどうかを確認できます。 最新バージョンのPythonをインストールして pip を取得します。
- Pythonインストールには、pipが含まれている必要があります。 コマンド ラインで
- Azure サブスクリプションを取得したら、Azure ポータルで Content Moderator リソースを作成して、キーとエンドポイントを取得します。 デプロイされるまで待ってから、[ リソースに移動 ] ボタンをクリックします。
- アプリケーションを Content Moderator に接続するには、作成したリソースのキーとエンドポイントが必要です。 キーとエンドポイントは、クイックスタートの後半のコードに貼り付けます。
- Free 価格レベル (
F0) を使用してサービスを試し、後で運用環境用の有料レベルにアップグレードできます。
セットアップ
クライアント ライブラリをインストールする
Pythonをインストールしたら、次のコマンドを使用して Content Moderator クライアント ライブラリをインストールできます。
pip install --upgrade azure-cognitiveservices-vision-contentmoderator
新しいPython アプリケーションを作成する
新しいPython スクリプトを作成し、任意のエディターまたは IDE で開きます。 次に、次の import ステートメントをファイルの先頭に追加します。
import os.path
from pprint import pprint
import time
from io import BytesIO
from random import random
import uuid
from azure.cognitiveservices.vision.contentmoderator import ContentModeratorClient
import azure.cognitiveservices.vision.contentmoderator.models
from msrest.authentication import CognitiveServicesCredentials
ヒント
クイック スタート コード ファイル全体を一度に表示しますか? このクイック スタートのコード例を含む GitHub で確認できます。
次に、リソースのエンドポイントの場所とキーの変数を作成します。
重要
Azure ポータルに移動します。 [前提条件] セクションで作成した Content Moderator リソースが正常にデプロイされた場合は、[次の手順] の [リソースに移動] ボタンをクリックします。 キーとエンドポイントは、リソースの [キーとエンドポイント ] ページの [ リソース管理] で確認できます。
CONTENT_MODERATOR_ENDPOINT = "PASTE_YOUR_CONTENT_MODERATOR_ENDPOINT_HERE"
subscription_key = "PASTE_YOUR_CONTENT_MODERATOR_SUBSCRIPTION_KEY_HERE"
重要
完了したら、コードからキーを削除し、公開しないでください。 運用環境では、
オブジェクト モデル
次のクラスは、Content Moderator Python クライアント ライブラリの主要な機能の一部を処理します。
| 名前 | 説明 |
|---|---|
| ContentModeratorClient | このクラスは、Content Moderator のすべての機能に必要です。 サブスクリプション情報を使用してインスタンス化し、それを使用して他のクラスのインスタンスを生成します。 |
| ImageModerationOperations | このクラスは、成人向けコンテンツ、個人情報、または人間の顔の画像を分析するための機能を提供します。 |
| TextModerationOperations | このクラスは、言語、不適切な表現、エラー、個人情報のテキストを分析するための機能を提供します。 |
コード例
これらのコード スニペットは、Python用の Content Moderator クライアント ライブラリで次のタスクを実行する方法を示しています。
クライアントを認証する
エンドポイントとキーを使用してクライアントをインスタンス化します。 CognitiveServicesCredentials](/python/api/msrest/msrest.authentication.cognitiveservicescredentials オブジェクトをキーで作成し、エンドポイントで使用して ContentModeratorClient オブジェクトを作成します。
client = ContentModeratorClient(
endpoint=CONTENT_MODERATOR_ENDPOINT,
credentials=CognitiveServicesCredentials(subscription_key)
)
テキストをモデレートする
次のコードでは、Content Moderator クライアントを使用してテキストの本文を分析し、結果をコンソールに出力します。 まず、プロジェクトのルートに text_files/ フォルダーを作成し、 content_moderator_text_moderation.txt ファイルを追加します。 このファイルに独自のテキストを追加するか、次のサンプル テキストを使用します。
Is this a grabage email abcdef@abcd.com, phone: 4255550111, IP: 255.255.255.255, 1234 Main Boulevard, Panapolis WA 96555.
<offensive word> is the profanity here. Is this information PII? phone 2065550111
新しいフォルダーへの参照を追加します。
TEXT_FOLDER = os.path.join(os.path.dirname(
os.path.realpath(__file__)), "text_files")
次に、Python スクリプトに次のコードを追加します。
# Screen the input text: check for profanity,
# do autocorrect text, and check for personally identifying
# information (PII)
with open(os.path.join(TEXT_FOLDER, 'content_moderator_text_moderation.txt'), "rb") as text_fd:
screen = client.text_moderation.screen_text(
text_content_type="text/plain",
text_content=text_fd,
language="eng",
autocorrect=True,
pii=True
)
assert isinstance(screen, Screen)
pprint(screen.as_dict())
カスタム用語リストを使用する
次のコードは、テキスト モデレーションのカスタム用語の一覧を管理する方法を示しています。 ListManagementTermListsOperations クラスを使用すると、用語リストの作成、個々の用語の管理、およびそれに対するテキストの他の本文のスクリーニングを行うことができます。
サンプル テキストを取得する
このサンプルを使用するには、プロジェクトのルートに text_files/ フォルダーを作成し、 content_moderator_term_list.txt ファイルを追加する必要があります。 このファイルには、用語の一覧に対してチェックされる有機テキストが含まれている必要があります。 次のサンプル テキストを使用できます。
This text contains the terms "term1" and "term2".
まだ定義していない場合は、フォルダーへの参照を追加します。
TEXT_FOLDER = os.path.join(os.path.dirname(
os.path.realpath(__file__)), "text_files")
リストを作成する
次のコードをPython スクリプトに追加して、カスタム用語リストを作成し、その ID 値を保存します。
#
# Create list
#
print("\nCreating list")
custom_list = client.list_management_term_lists.create(
content_type="application/json",
body={
"name": "Term list name",
"description": "Term list description",
}
)
print("List created:")
assert isinstance(custom_list, TermList)
pprint(custom_list.as_dict())
list_id = custom_list.id
リストの詳細を定義する
リストの ID を使用して、その名前と説明を編集できます。
#
# Update list details
#
print("\nUpdating details for list {}".format(list_id))
updated_list = client.list_management_term_lists.update(
list_id=list_id,
content_type="application/json",
body={
"name": "New name",
"description": "New description"
}
)
assert isinstance(updated_list, TermList)
pprint(updated_list.as_dict())
リストに用語を追加する
次のコードは、用語 "term1" と "term2" を一覧に追加します。
#
# Add terms
#
print("\nAdding terms to list {}".format(list_id))
client.list_management_term.add_term(
list_id=list_id,
term="term1",
language="eng"
)
client.list_management_term.add_term(
list_id=list_id,
term="term2",
language="eng"
)
リスト内のすべての用語を取得する
リスト ID を使用して、リスト内のすべての用語を返すことができます。
#
# Get all terms ids
#
print("\nGetting all term IDs for list {}".format(list_id))
terms = client.list_management_term.get_all_terms(
list_id=list_id, language="eng")
assert isinstance(terms, Terms)
terms_data = terms.data
assert isinstance(terms_data, TermsData)
pprint(terms_data.as_dict())
リスト インデックスを更新する
リストに用語を追加または削除するたびに、更新されたリストを使用する前にインデックスを更新する必要があります。
#
# Refresh the index
#
print("\nRefreshing the search index for list {}".format(list_id))
refresh_index = client.list_management_term_lists.refresh_index_method(
list_id=list_id, language="eng")
assert isinstance(refresh_index, RefreshIndex)
pprint(refresh_index.as_dict())
print("\nWaiting {} minutes to allow the server time to propagate the index changes.".format(
LATENCY_DELAY))
time.sleep(LATENCY_DELAY * 60)
画面テキストをリストと照合する
カスタム用語リストの主な機能は、テキストの本文をリストと比較し、一致する用語があるかどうかを見つけることです。
#
# Screen text
#
with open(os.path.join(TEXT_FOLDER, 'content_moderator_term_list.txt'), "rb") as text_fd:
screen = client.text_moderation.screen_text(
text_content_type="text/plain",
text_content=text_fd,
language="eng",
autocorrect=False,
pii=False,
list_id=list_id
)
assert isinstance(screen, Screen)
pprint(screen.as_dict())
リストから用語を削除する
次のコードは、 "term1" という用語を一覧から削除します。
#
# Remove terms
#
term_to_remove = "term1"
print("\nRemove term {} from list {}".format(term_to_remove, list_id))
client.list_management_term.delete_term(
list_id=list_id,
term=term_to_remove,
language="eng"
)
リストからすべての用語を削除する
次のコードを使用して、すべての用語の一覧をクリアします。
#
# Delete all terms
#
print("\nDelete all terms in the image list {}".format(list_id))
client.list_management_term.delete_all_terms(
list_id=list_id, language="eng")
リストを削除する
カスタム用語リストを削除するには、次のコードを使用します。
#
# Delete list
#
print("\nDelete the term list {}".format(list_id))
client.list_management_term_lists.delete(list_id=list_id)
画像をモデレートする
次のコードでは、Content Moderator クライアントと ImageModerationOperations オブジェクトを使用して、成人向けコンテンツとわいせつなコンテンツの画像を分析します。
サンプル 画像を取得する
分析する画像への参照を定義します。
IMAGE_LIST = [
"https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpg",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample5.png"
]
次に、次のコードを追加して、イメージを反復処理します。 このセクションの残りのコードは、このループ内に入ります。
for image_url in IMAGE_LIST:
print("\nEvaluate image {}".format(image_url))
成人向け/わいせつなコンテンツを確認する
次のコードは、指定された URL の画像で成人向けまたはわいせつなコンテンツをチェックし、結果をコンソールに出力します。 これらの用語の意味については、 イメージ モデレーションの概念 ガイドを参照してください。
print("\nEvaluate for adult and racy content.")
evaluation = client.image_moderation.evaluate_url_input(
content_type="application/json",
cache_image=True,
data_representation="URL",
value=image_url
)
assert isinstance(evaluation, Evaluate)
pprint(evaluation.as_dict())
表示されるテキストを確認する
次のコードは、画像に表示されるテキスト コンテンツをチェックし、結果をコンソールに出力します。
print("\nDetect and extract text.")
evaluation = client.image_moderation.ocr_url_input(
language="eng",
content_type="application/json",
data_representation="URL",
value=image_url,
cache_image=True,
)
assert isinstance(evaluation, OCR)
pprint(evaluation.as_dict())
顔を確認する
次のコードは、人間の顔の画像をチェックし、結果をコンソールに出力します。
print("\nDetect faces.")
evaluation = client.image_moderation.find_faces_url_input(
content_type="application/json",
cache_image=True,
data_representation="URL",
value=image_url
)
assert isinstance(evaluation, FoundFaces)
pprint(evaluation.as_dict())
カスタム イメージ リストを使用する
次のコードは、イメージ モデレーション用のイメージのカスタム リストを管理する方法を示しています。 この機能は、画面を表示するのと同じイメージ セットのインスタンスをプラットフォームが頻繁に受信する場合に便利です。これらの特定のイメージの一覧を維持することで、パフォーマンスを向上させることができます。 ListManagementImageListsOperations クラスを使用すると、イメージ リストの作成、リスト上の個々のイメージの管理、および他のイメージの比較を行います。
次のテキスト変数を作成して、このシナリオで使用するイメージ URL を格納します。
IMAGE_LIST = {
"Sports": [
"https://moderatorsampleimages.blob.core.windows.net/samples/sample4.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample6.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample9.png"
],
"Swimsuit": [
"https://moderatorsampleimages.blob.core.windows.net/samples/sample1.jpg",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample3.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample4.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample16.png"
]
}
IMAGES_TO_MATCH = [
"https://moderatorsampleimages.blob.core.windows.net/samples/sample1.jpg",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample4.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample5.png",
"https://moderatorsampleimages.blob.core.windows.net/samples/sample16.png"
]
メモ
これは適切なリスト自体ではなく、コードの add images セクションに追加されるイメージの非公式なリストです。
イメージ リストを作成する
次のコードを追加して、イメージ リストを作成し、その ID への参照を保存します。
#
# Create list
#
print("Creating list MyList\n")
custom_list = client.list_management_image_lists.create(
content_type="application/json",
body={
"name": "MyList",
"description": "A sample list",
"metadata": {
"key_one": "Acceptable",
"key_two": "Potentially racy"
}
}
)
print("List created:")
assert isinstance(custom_list, ImageList)
pprint(custom_list.as_dict())
list_id = custom_list.id
リストに画像を追加する
次のコードは、すべてのイメージを一覧に追加します。
print("\nAdding images to list {}".format(list_id))
index = {} # Keep an index url to id for later removal
for label, urls in IMAGE_LIST.items():
for url in urls:
image = add_images(list_id, url, label)
if image:
index[url] = image.content_id
スクリプト内の別の場所で add_images ヘルパー関数を定義します。
#
# Add images
#
def add_images(list_id, image_url, label):
"""Generic add_images from url and label."""
print("\nAdding image {} to list {} with label {}.".format(
image_url, list_id, label))
try:
added_image = client.list_management_image.add_image_url_input(
list_id=list_id,
content_type="application/json",
data_representation="URL",
value=image_url,
label=label
)
except APIErrorException as err:
# sample4 will fail
print("Unable to add image to list: {}".format(err))
else:
assert isinstance(added_image, Image)
pprint(added_image.as_dict())
return added_image
リスト内の画像を取得する
次のコードは、リスト内のすべてのイメージの名前を出力します。
#
# Get all images ids
#
print("\nGetting all image IDs for list {}".format(list_id))
image_ids = client.list_management_image.get_all_image_ids(list_id=list_id)
assert isinstance(image_ids, ImageIds)
pprint(image_ids.as_dict())
リストの詳細を更新する
リスト ID を使用して、リストの名前と説明を更新できます。
#
# Update list details
#
print("\nUpdating details for list {}".format(list_id))
updated_list = client.list_management_image_lists.update(
list_id=list_id,
content_type="application/json",
body={
"name": "Swimsuits and sports"
}
)
assert isinstance(updated_list, ImageList)
pprint(updated_list.as_dict())
リストの詳細を取得する
次のコードを使用して、リストの現在の詳細を出力します。
#
# Get list details
#
print("\nGetting details for list {}".format(list_id))
list_details = client.list_management_image_lists.get_details(
list_id=list_id)
assert isinstance(list_details, ImageList)
pprint(list_details.as_dict())
リスト インデックスを更新する
イメージを追加または削除した後は、リスト インデックスを更新してから、それを使用して他のイメージをスクリーニングする必要があります。
#
# Refresh the index
#
print("\nRefreshing the search index for list {}".format(list_id))
refresh_index = client.list_management_image_lists.refresh_index_method(
list_id=list_id)
assert isinstance(refresh_index, RefreshIndex)
pprint(refresh_index.as_dict())
print("\nWaiting {} minutes to allow the server time to propagate the index changes.".format(
LATENCY_DELAY))
time.sleep(LATENCY_DELAY * 60)
一覧に対して画像を照合する
画像リストの主な機能は、新しい画像を比較し、一致があるかどうかを確認することです。
#
# Match images against the image list.
#
for image_url in IMAGES_TO_MATCH:
print("\nMatching image {} against list {}".format(image_url, list_id))
match_result = client.image_moderation.match_url_input(
content_type="application/json",
list_id=list_id,
data_representation="URL",
value=image_url,
)
assert isinstance(match_result, MatchResponse)
print("Is match? {}".format(match_result.is_match))
print("Complete match details:")
pprint(match_result.as_dict())
一覧から画像を削除する
次のコードは、リストから項目を削除します。 この場合、リスト カテゴリと一致しないイメージです。
#
# Remove images
#
correction = "https://moderatorsampleimages.blob.core.windows.net/samples/sample16.png"
print("\nRemove image {} from list {}".format(correction, list_id))
client.list_management_image.delete_image(
list_id=list_id,
image_id=index[correction]
)
リストからすべての画像を削除する
次のコードを使用して、イメージの一覧をクリアします。
#
# Delete all images
#
print("\nDelete all images in the image list {}".format(list_id))
client.list_management_image.delete_all_images(list_id=list_id)
イメージ リストを削除する
特定のイメージ リストを削除するには、次のコードを使用します。
#
# Delete list
#
print("\nDelete the image list {}".format(list_id))
client.list_management_image_lists.delete(list_id=list_id)
アプリケーションを実行する
クイック スタート ファイルで python コマンドを使用してアプリケーションを実行します。
python quickstart-file.py
リソースのクリーンアップ
Azure AI サービス サブスクリプションをクリーンアップして削除する場合は、リソースまたはリソース グループを削除できます。 リソース グループを削除すると、それに関連付けられている他のリソースも削除されます。
次の手順
このクイック スタートでは、Content Moderator Python ライブラリを使用してモデレーション タスクを実行する方法について説明しました。 次に、概念ガイドを読んで、画像やその他のメディアのモデレートについて詳しく学習します。
Azure Content Moderator REST API の使用を開始します。
Content Moderator は、不快、危険、または望ましくない可能性のあるコンテンツを処理できる AI サービスです。 AI を利用したコンテンツ モデレーション サービスを使用して、テキスト、画像、ビデオをスキャンし、コンテンツ フラグを自動的に適用します。 規制に準拠したり、ユーザーの目的の環境を維持したりするために、コンテンツ フィルタリング ソフトウェアをアプリに組み込みます。
Content Moderator REST API を使用して、次の手順を実行します。
- テキストをモデレートする
- 画像をモデレートする
前提 条件
- Azure サブスクリプション - 無料で作成します
- Azure サブスクリプションを取得したら、Azure ポータルで Content Moderator リソース を作成して、キーとエンドポイントを取得します。 デプロイされるまで待ってから、[ リソースに移動 ] ボタンをクリックします。
- アプリケーションを Content Moderator に接続するには、作成したリソースのキーとエンドポイントが必要です。 キーとエンドポイントは、クイックスタートの後半のコードに貼り付けます。
- Free 価格レベル (
F0) を使用してサービスを試し、後で運用環境用の有料レベルにアップグレードできます。
- PowerShell バージョン 6.0 以降、または同様のコマンド ライン アプリケーション。
テキストをモデレートする
次のようなコマンドを使用して、Content Moderator API を呼び出してテキストの本文を分析し、結果をコンソールに出力します。
curl -v -X POST "https://westus.api.cognitive.microsoft.com/contentmoderator/moderate/v1.0/ProcessText/Screen?autocorrect=True&PII=True&classify=True&language={string}"
-H "Content-Type: text/plain"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "Is this a crap email abcdef@abcd.com, phone: 6657789887, IP: 255.255.255.255, 1 Microsoft Way, Redmond, WA 98052"
コマンドをテキスト エディターにコピーし、次の変更を行います。
- 有効な Face サブスクリプション キーに
Ocp-Apim-Subscription-Keyを割り当てます。重要
完了したら、コードからキーを削除し、公開しないでください。 運用環境では、
Azure Key Vault 。 詳細については、Azure AI サービス security に関する記事を参照してください。 - クエリ URL の最初の部分を、サブスクリプション キーに対応するエンドポイントと一致するように変更します。
メモ
2019 年 7 月 1 日以降に作成された新しいリソースでは、カスタム サブドメイン名が使用されます。 リージョン エンドポイントの詳細と完全な一覧については、「 Foundry Tools のカスタム サブドメイン名」を参照してください。
- 必要に応じて、分析したい任意のテキストを要求の本文に変更してください。
変更が完了したら、コマンド プロンプトを開き、新しいコマンドを入力します。
結果を確認する
テキスト モデレーションの結果がコンソール ウィンドウに JSON データとして表示されます。 例えば:
{
"OriginalText": "Is this a <offensive word> email abcdef@abcd.com, phone: 6657789887, IP: 255.255.255.255,\n1 Microsoft Way, Redmond, WA 98052\n",
"NormalizedText": "Is this a <offensive word> email abide@ abed. com, phone: 6657789887, IP: 255. 255. 255. 255, \n1 Microsoft Way, Redmond, WA 98052",
"AutoCorrectedText": "Is this a <offensive word> email abide@ abed. com, phone: 6657789887, IP: 255. 255. 255. 255, \n1 Microsoft Way, Redmond, WA 98052",
"Misrepresentation": null,
"PII": {
"Email": [
{
"Detected": "abcdef@abcd.com",
"SubType": "Regular",
"Text": "abcdef@abcd.com",
"Index": 21
}
],
"IPA": [
{
"SubType": "IPV4",
"Text": "255.255.255.255",
"Index": 61
}
],
"Phone": [
{
"CountryCode": "US",
"Text": "6657789887",
"Index": 45
}
],
"Address": [
{
"Text": "1 Microsoft Way, Redmond, WA 98052",
"Index": 78
}
]
},
"Classification": {
"Category1":
{
"Score": 0.5
},
"Category2":
{
"Score": 0.6
},
"Category3":
{
"Score": 0.5
},
"ReviewRecommended": true
},
"Language": "eng",
"Terms": [
{
"Index": 10,
"OriginalIndex": 10,
"ListId": 0,
"Term": "<offensive word>"
}
],
"Status": {
"Code": 3000,
"Description": "OK",
"Exception": null
},
"TrackingId": "1717c837-cfb5-4fc0-9adc-24859bfd7fac"
}
Content Moderator で表示されるテキスト属性の詳細については、 テキスト モデレーションの概念ガイドを 参照してください。
画像をモデレートする
次のようなコマンドを使用して、Content Moderator API を呼び出してリモート イメージをモデレートし、結果をコンソールに出力します。
curl -v -X POST "https://westus.api.cognitive.microsoft.com/contentmoderator/moderate/v1.0/ProcessImage/Evaluate?CacheImage={boolean}"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{\"DataRepresentation\":\"URL\", \"Value\":\"https://moderatorsampleimages.blob.core.windows.net/samples/sample.jpg\"}"
コマンドをテキスト エディターにコピーし、次の変更を行います。
- 有効な Face サブスクリプション キーに
Ocp-Apim-Subscription-Keyを割り当てます。 - クエリ URL の最初の部分を、サブスクリプション キーに対応するエンドポイントと一致するように変更します。
- 必要であれば、リクエスト本文の
"Value"URL を、お好みのリモート画像に変更してモデレートしてください。
ヒント
また、要求本文にバイト データを渡すことで、ローカル イメージをモデレートすることもできます。 これを行う方法については、 リファレンス ドキュメント を参照してください。
変更が完了したら、コマンド プロンプトを開き、新しいコマンドを入力します。
結果を確認する
画像のモデレーションの結果がコンソール ウィンドウに JSON データとして表示されます。
{
"AdultClassificationScore": x.xxx,
"IsImageAdultClassified": <Bool>,
"RacyClassificationScore": x.xxx,
"IsImageRacyClassified": <Bool>,
"AdvancedInfo": [],
"Result": false,
"Status": {
"Code": 3000,
"Description": "OK",
"Exception": null
},
"TrackingId": "<Request Tracking Id>"
}
Content Moderator で表示されるイメージ属性の詳細については、 イメージ モデレーションの概念ガイドを 参照してください。
リソースのクリーンアップ
Azure AI サービス サブスクリプションをクリーンアップして削除する場合は、リソースまたはリソース グループを削除できます。 リソース グループを削除すると、それに関連付けられている他のリソースも削除されます。
次の手順
このクイックスタートでは、Content Moderator REST API を使用してモデレーション タスクを実行する方法について説明しました。 次に、概念ガイドを読んで、画像やその他のメディアのモデレートについて詳しく学習します。