使用 API 主控台中的自訂影像清單進行仲裁Moderate with custom image lists in the API console

您可使用 Azure Content Moderator 中的清單管理 API 來建立自訂影像清單。You use the List Management API in Azure Content Moderator to create custom lists of images. 請搭配「影像仲裁 API」使用自訂影像清單。Use the custom lists of images with the Image Moderation API. 影像仲裁作業會評估您的影像。The image moderation operation evaluates your image. 如果您建立自訂清單,此作業也會將它與您自訂清單中的影像做比較。If you create custom lists, the operation also compares it to the images in your custom lists. 您可以使用自訂清單來封鎖或允許影像。You can use custom lists to block or allow the image.

注意

上限是 5 個影像清單,其中每個清單不可超過 10,000 個影像There is a maximum limit of 5 image lists with each list to not exceed 10,000 images.

您可以使用「清單管理 API」來執行下列工作:You use the List Management API to do the following tasks:

  • 建立清單。Create a list.
  • 將影像新增至清單。Add images to a list.
  • 依據清單中的影像過濾影像。Screen images against the images in a list.
  • 從清單中刪除影像。Delete images from a list.
  • 刪除清單。Delete a list.
  • 編輯清單資訊。Edit list information.
  • 重新整理索引,以便將清單變更包含在新的掃描中。Refresh the index so that changes to the list are included in a new scan.

使用 API 主控台Use the API console

您需要有訂用帳戶金鑰,才能在線上主控台中試用 API。Before you can test-drive the API in the online console, you need your subscription key. 這位於 [設定]**** 索引標籤的 [Ocp-Apim-Subscription-Key]**** 方塊中。This is located on the Settings tab, in the Ocp-Apim-Subscription-Key box. 如需詳細資訊,請參閱概觀For more information, see Overview.

重新整理搜尋索引Refresh search index

在您對影像清單進行變更之後,必須重新整理其索引,變更才會包含在未來的掃描中。After you make changes to an image list, you must refresh its index for changes to be included in future scans. 此步驟就像桌面搜尋引擎 (如果已啟用) 或 Web 搜尋引擎持續重新整理其索引以包含新檔案或頁面一樣。This step is similar to how a search engine on your desktop (if enabled) or a web search engine continually refreshes its index to include new files or pages.

  1. 影像清單管理 API 參考中,從左側功能表中選取 [Image Lists] (影像清單)****,然後選取 [Refresh Search Index] (重新整理搜尋索引)****。In the Image List Management API reference, in the left menu, select Image Lists, and then select Refresh Search Index.

    [Image Lists - Refresh Search Index] (影像清單 - 重新整理搜尋索引)**** 頁面隨即開啟。The Image Lists - Refresh Search Index page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Image Lists - Refresh Search Index] (影像清單 - 重新整理搜尋索引) 頁面區域選取項目

    [Image Lists - Refresh Search Index] (影像清單 - 重新整理搜尋索引)**** API 主控台隨即開啟。The Image Lists - Refresh Search Index API console opens.

  3. 在 [listId]**** 方塊中,輸入清單識別碼。In the listId box, enter the list ID. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。Enter your subscription key, and then select Send.

    [Image Lists - Refresh Search Index] (影像清單 - 重新整理搜尋索引) 主控台的 [Response content] (回應內容) 方塊

建立影像清單Create an image list

  1. 移至影像清單管理 API 參考Go to the Image List Management API reference.

    [Image Lists - Create] (影像清單 - 建立)**** 頁面隨即開啟。The Image Lists - Create page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Image Lists - Create] (影像清單 - 建立) 頁面區域選取項目

    [Image Lists - Create] (影像清單 - 建立)**** API 主控台隨即開啟。The Image Lists - Create API console opens.

  3. 在 [Ocp-Apim-Subscription-Key]**** 中,輸入您的訂用帳戶金鑰。In the Ocp-Apim-Subscription-Key box, enter your subscription key.

  4. 在 [Request body] (要求本文)**** 方塊中,輸入 [Name] (名稱)**** (例如 MyList) 和 [Description] (描述)**** 的值。In the Request body box, enter values for Name (for example, MyList) and Description.

    [Image Lists - Create] (影像清單 - 建立) 主控台的要求本文名稱和描述

  5. 使用機碼值組預留位置來為清單指派更多描述性中繼資料。Use key-value pair placeholders to assign more descriptive metadata to your list.

    {
        "Name": "MyExclusionList",
        "Description": "MyListDescription",
        "Metadata": 
        {
            "Category": "Competitors",
            "Type": "Exclude"
        }
    }
    

    請以索引鍵/值組形式新增清單中繼資料,而不要新增實際的影像。Add list metadata as key-value pairs, and not the actual images.

  6. 選取 [傳送]。Select Send. 您的清單隨即建立。Your list is created. 請注意與新清單關聯的 [ID] (識別碼)**** 值。Note the ID value that is associated with the new list. 您需要有此識別碼,才能進行其他影像清單管理功能。You need this ID for other image list management functions.

    [Image Lists - Create] (影像清單 - 建立) 主控台的 [Response content] (回應內容) 方塊顯示清單識別碼

  7. 接著,將影像新增至 MyList。Next, add images to MyList. 從左側功能表中,選取 [Image] (影像)****,然後選取 [Add Image] (新增影像)****。In the left menu, select Image, and then select Add Image.

    [Image - Add Image] (影像 - 新增影像)**** 頁面隨即開啟。The Image - Add Image page opens.

  8. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Image - Add Image] (影像 - 新增影像) 頁面區域選取項目

    [Image - Add Image] (影像 - 新增影像)**** API 主控台隨即開啟。The Image - Add Image API console opens.

  9. 在 [listId]**** 方塊中,輸入您產生的清單識別碼,然後輸入想要新增影像的 URL。In the listId box, enter the list ID that you generated, and then enter the URL of the image that you want to add. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。Enter your subscription key, and then select Send.

  10. 若要確認是否已將該影像新增至清單,請從左側功能表中,選取 [Image] (影像)****,然後選取 [Get All Image Ids] (取得所有影像識別碼)****。To verify that the image has been added to the list, in the left menu, select Image, and then select Get All Image Ids.

    [Image - Get All Image Ids] (影像 - 取得所有影像識別碼)**** API 主控台隨即開啟。The Image - Get All Image Ids API console opens.

  11. 在 [listId]**** 方塊中,輸入清單識別碼,然後輸入您的訂用帳戶金鑰。In the listId box, enter the list ID, and then enter your subscription key. 選取 [傳送]。Select Send.

    [Image - Get All Image Ids] (影像 - 取得所有影像識別碼) 主控台的 [Response content] (回應內容) 方塊列出您輸入的影像

  12. 再多新增幾個影像。Add a few more images. 既然您已建立自訂影像清單,現在即可嘗試使用自訂影像清單來評估影像Now that you have created a custom list of images, try evaluating images by using the custom image list.

刪除影像和清單Delete images and lists

刪除影像或清單相當簡單。Deleting an image or a list is straightforward. 您可以使用 API 來執行下列工作:You can use the API to do the following tasks:

  • 删除映像。Delete an image. ([Image - Delete] (影像 - 刪除)****)(Image - Delete)
  • 刪除清單中的所有影像,但不刪除清單。Delete all the images in a list without deleting the list. ([Image - Delete All Images] (影像 - 刪除所有影像)****)(Image - Delete All Images)
  • 刪除清單及其所有內容。Delete a list and all of its contents. ([Image Lists - Delete] (影像清單 - 刪除)****)(Image Lists - Delete)

此範例會刪除單一影像:This example deletes a single image:

  1. 影像清單管理 API 參考中,從左側功能表中選取 [Image] (影像)****,然後選取 [Delete] (刪除)****。In the Image List Management API reference, in the left menu, select Image, and then select Delete.

    [Image - Delete] (影像 - 刪除)**** 頁面隨即開啟。The Image - Delete page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Image - Delete] (影像 - 刪除) 頁面區域選取項目

    [Image - Delete] (影像 - 刪除)**** API 主控台隨即開啟。The Image - Delete API console opens.

  3. 在 [listId]**** 方塊中,輸入要作為影像刪除來源的清單識別碼。In the listId box, enter the ID of the list to delete an image from. 這是 [Image - Get All Image Ids] (影像 - 取得所有影像識別碼)**** 主控台中針對 MyList 傳回的數字。This is the number returned in the Image - Get All Image Ids console for MyList. 接著,輸入要刪除之影像的 [ImageId]****。Then, enter the ImageId of the image to delete.

在我們的範例中,清單識別碼是 58953(ContentSource 的值)。In our example, the list ID is 58953, the value for ContentSource. 影像識別碼是 59021 (ContentIds的值)。The image ID is 59021, the value for ContentIds.

  1. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。Enter your subscription key, and then select Send.

  2. 若要確認是否已將該影像刪除,請使用 [Image - Get All Image Ids] (影像 - 取得所有影像識別碼)**** 主控台。To verify that the image has been deleted, use the Image - Get All Image Ids console.

變更清單資訊Change list information

您可以編輯清單的名稱和描述,以及新增中繼資料項目。You can edit a list’s name and description, and add metadata items.

  1. 影像清單管理 API 參考中,從左側功能表中選取 [Image Lists] (影像清單)****,然後選取 [Update Details] (更新詳細資料)****。In the Image List Management API reference, in the left menu, select Image Lists, and then select Update Details.

    [Image Lists - Update Details] (影像清單 - 更新詳細資料)**** 頁面隨即開啟。The Image Lists - Update Details page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Image Lists - Update Details] (影像清單 - 更新詳細資料) 頁面區域選取項目

    [Image Lists - Update Details] (影像清單 - 更新詳細資料)**** API 主控台隨即開啟。The Image Lists - Update Details API console opens.

  3. 在 [listId]**** 方塊中,輸入清單識別碼,然後輸入您的訂用帳戶金鑰。In the listId box, enter the list ID, and then enter your subscription key.

  4. 在 [Request body] (要求本文)**** 方塊中,進行編輯,然後選取頁面上的 [Send] (傳送)**** 按鈕。In the Request body box, make your edits, and then select the Send button on the page.

    [Image Lists - Update Details] (影像清單 - 更新詳細資料) 主控台 [Request body] (要求本文) 編輯

後續步驟Next steps

在您的程式碼中使用 REST API,或從影像清單 .NET 快速入門開始著手,以便與您的應用程式進行整合。Use the REST API in your code or start with the Image lists .NET quickstart to integrate with your application.