如何使用“匹配图像”内容主持人的API? [英] How to use "Match Image" API of Content Moderator?

查看:59
本文介绍了如何使用“匹配图像”内容主持人的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"匹配图片"如何? Microsoft Content Moderator的API工作吗?

How does the "Match Image" API of Microsoft Content Moderator work?

让我们通过我们的添加表单一个接一个地添加我们的用户添加的以下3个图像




1)https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg



2)https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Olympiastadion_Berlin_Innenansicht.jpg/800px-Olympiastadion_Berlin_Innenansicht.jpg



3)https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/320px-Leuchtturm_in_Westerheversand.jpg





我们想检查每个新发布的图像是否与任何早期发布的图像重复。因此,使用您的"匹配图像"服务时,应该注意到图像3是先前提交的图像1的副本。
$


如何进行此操作?首先,我们必须执行"添加图像",然后执行"刷新索引"。 &安培;然后"匹配图像"?那么什么是"缓存图像"呢? &安培; "匹配缓存图像"?
$


问题:



a)我已经发送了这些图像一个裸体检查。如果在那个时候,我只给出cache = true,那么图像是否可能会被添加到缓存中,并且可以用于"匹配图像"。没有任何索引刷新的API?
$


b)将图像添加到列表中,然后检查它是否与任何其他先前图像匹配,这些将花费2个计数或仅1个计数?因此,对于"添加图像"计数1次,对"高速缓存图像"计数1次,然后刷新索引,然后为
"匹配图像"计数1次。因此,仅仅匹配一个图像就需要花费3分吗?b


c)是否有可能在单个请求中获得裸露检查和图像匹配的响应?因此,我节省了时间。这将花费我们2分吧?b
$
d)在"刷新索引"页面上,它表示可能需要大约5分钟才能更新索引。但在我的网站上,用户将持续提交图像。因此,如果相隔几秒钟提交2张图像,我们希望重复检查
即使对于这样的图像也是如此。这可能吗?
b
$


$
以下是我们尝试制作的内容"匹配图片"工作,但我们迷路了。请帮忙!
$


$
*试用A)



我尝试添加通过"自定义图像列表管理>图像到高速缓存;添加图片"链接。它给出错误



$
- HTTP请求



POST https:/ /api.microsoftmoderator.com/Image/Validate/Image/Add HTTP / 1.1

主持人:api.microsoftmoderator.com

Ocp-Apim-Subscription-Key:•• ••••••••••••••••••••••••························································· b

{

  "DataRepresentation":"URL","
  "值":"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg"

}



$
- 回复正文



日期:2016年5月24日星期二15:35: 43 GMT

X-Powered-By:ASP.NET

内容长度:152

内容类型:application / json; charset = utf-8

$
{

  "状态":{
$
    "代码":3004,

    "描述":"处理请求时发生错误",

    "例外":null

  },b $ b  "TrackingId":null,

  "AdditionalInfo":[],

  " ContentId":null

}



$
$
*试用B )b
$
我尝试通过"图像缓存>"将图像添加到缓存中缓存图像"链接,然后检查内容是否正在缓存,但在使用缓存的图像时,它给出"内容已在服务器上过期"。




$
- HTTP请求



POST https: //api.microsoftmoderator.com/Image/Cache/ HTTP / 1.1

内容类型:application / json

主持人:api.microsoftmoderator.com

内容长度:106

Ocp-Apim-Subscription-Key:••••••••••••••••••••••••• ••••••¥b $ b $
{

  "DataRepresentation":"URL","
  "值":"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg"

}





$
- 回应内容



日期:星期二,2016年5月24日15:41:03 GMT

X-Powered-By:ASP.NET

内容长度:141

内容 - 类型:application / json; charset = utf-8

$
{

  " CacheID":" 72a6cd4d2ffe492980d321d0f34f84be",&b $ b  " TrackingId":" WUS_90939_560b14832703740d8c47b89d_72a6cd4d2ffe492980d321d0f34f84be"

}



$
现在我尽快使用此缓存图像通过"图像服务>评估"缓存图像",它会显示"内容已过期"的错误。




- 响应状态



410内容已在服务器上过期。

响应延迟

608 ms

回复内容



日期:2016年5月24日星期二15:42:31 GMT

X-Powered-By:ASP.NET

内容长度:272

内容类型:application / json; charset = utf-8

$
{

  " TrackingId":" WUS_90939_560b14832703740d8c47b89d_547f59be13f8437f940c823286aff1c8",&
  "AdvancedInfo":[],

  "结果":false,

  "AdultClassificationScore":0,

  "IsImageAdultClassified":false,

  "IsImageRacyClassified":false,

  "RacyClassificationScore":0

}





$ b *试用C )b
$
我甚至尝试了各种"图像服务"组合。匹配图像"和"图像服务>匹配缓存图像,但绝对没有任何东西对我有用。

Let's take the following 3 images added by our users one after the other via our Add Form

1) https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg

2) https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Olympiastadion_Berlin_Innenansicht.jpg/800px-Olympiastadion_Berlin_Innenansicht.jpg

3) https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/320px-Leuchtturm_in_Westerheversand.jpg


We want to check whether each new posted image is a duplicate of any of the earlier posted images. Thus using your "Match Image" service, it should catch that Image 3 is a duplicate of previously submitted Image 1.

How do I go about it? First we have to do "Add Image", then "Refresh Index" & then "Match Image"? Then what is "Cache Image" & "Match Cached Image"?

Questions :

a) I am already sending these images one by one for Nudity Checking. If at that time, I just give cache=true, then is it possible that the image will get added to your cache, and would be ready to use for the "Match Image" API without any Index Refreshing?

b) Adding an image to your list and then checking if it matches with any other previous image, these would cost be 2 counts or just 1 count? Thus 1 count for "Add Image", 1 count for "Cache Image", then Refresh Index, and then 1 Count for "Match Image". Thus it would cost us 3 points for matching just a single image?

c) Is it possible to get a response of nudity checking and image matching in a single request? Thus, I save time. This would cost us 2 points right?

d) On the page of "Refresh Index", it says it can take around 5 minutes to do get the index updated. But on my site, users would be submitting images continuously. Thus if 2 images are submitted just seconds apart, we would like duplicate checking to happen even for such images. Would this be possible?



Below are the things we tried to make "Match Image" work, but we are lost. Please help!


* Trial A)

I tried adding images to the Cache via "Custom Image List Management > Add Image" link. It gives Error


- HTTP request

POST https://api.microsoftmoderator.com/Image/Validate/Image/Add HTTP/1.1
Host: api.microsoftmoderator.com
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••
Content-Length: 102

{
  "DataRepresentation":"URL",
  "Value":"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg"
}


- Response Body

Date: Tue, 24 May 2016 15:35:43 GMT
X-Powered-By: ASP.NET
Content-Length: 152
Content-Type: application/json; charset=utf-8

{
  "Status": {
    "Code": 3004,
    "Description": "Error occurred while processing request",
    "Exception": null
  },
  "TrackingId": null,
  "AdditionalInfo": [],
  "ContentId": null
}



* Trial B)

I tried adding images to the Cache via "Image Caching > Cache Image" link and then checking if content is getting cached, but on using a cached image it gives "Content has expired on the server".


- HTTP Request

POST https://api.microsoftmoderator.com/Image/Cache/ HTTP/1.1
Content-Type: application/json
Host: api.microsoftmoderator.com
Content-Length: 106
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••

{
  "DataRepresentation":"URL",
  "Value":"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Leuchtturm_in_Westerheversand.jpg/800px-Leuchtturm_in_Westerheversand.jpg"
}



- Response Content

Date: Tue, 24 May 2016 15:41:03 GMT
X-Powered-By: ASP.NET
Content-Length: 141
Content-Type: application/json; charset=utf-8

{
  "CacheID": "72a6cd4d2ffe492980d321d0f34f84be",
  "TrackingId": "WUS_90939_560b14832703740d8c47b89d_72a6cd4d2ffe492980d321d0f34f84be"
}


Now as soon as I try to use this Cached image via "Image Services > Evaluate Cached Image", it gives error saying "Content has expired"


- Response status

410 Content has expired on the server.
Response latency
608 ms
Response content

Date: Tue, 24 May 2016 15:42:31 GMT
X-Powered-By: ASP.NET
Content-Length: 272
Content-Type: application/json; charset=utf-8

{
  "TrackingId": "WUS_90939_560b14832703740d8c47b89d_547f59be13f8437f940c823286aff1c8",
  "AdvancedInfo": [],
  "Result": false,
  "AdultClassificationScore": 0,
  "IsImageAdultClassified": false,
  "IsImageRacyClassified": false,
  "RacyClassificationScore": 0
}



* Trial C)

I even tried various combinations of "Image Services > Match Image" and "Image Services > Match Cached Image", but absolutely nothing seems to be working for me.

推荐答案

< span style ="font-size:11.0pt; font-family:'Calibri',sans-serif">我将首先详细介绍Cache Image和Match Image API的工作原理:

 

< span style ="text-decoration:underline"> 缓存图像

此API的目的是减轻在不同API之间发送相同图像的出口成本。因此,当您使用cacheimage = true调用EvaluateImage API时,我们会缓存
发送的图像,持续时间 50秒。

 

 

图像缓存时,你可以调用任何其他API"在缓存图像中检测面","匹配缓存图像"和"从缓存图像中提取文本",并指定在第一次调用中返回的
的CacheId。这节省了自己的出口成本,因为我们不会再次下载图像。

 

 

 

匹配图片:

此API的目的是使您能够将新图像与现有图像列表进行匹配。此API使用模糊匹配,因此可以匹配稍微修改过
的图像。

 

添加图像API用于将新图像添加到自定义列表。添加图像会在添加图像之前检查列表中是否有完全相同的图像。

 

完成向图像列表添加图像后,需要调用刷新索引API。刷新索引API开始重建您的自定义图像
列表的数据结构,以启用模糊匹配。

 

 

 

 

在您的电子邮件中解决问题:

Addressing questions in your email:


  1.       我已经将这些图片逐个发送给Nudity Checking。如果在那个时候,我只是给出cache = true,那么图像是否可能被添加到你的缓存中,并且可以用
    准备用于"匹配图像"。没有任何索引刷新的API?
  1.       I am already sending these images one by one for Nudity Checking. If at that time, I just give cache=true, then is it possible that the image will get added to your cache, and would be ready to use for the "Match Image" API without any Index Refreshing?


 

 

高速缓存图像仅暂时保留图像,以便在调用其他图像功能时节省出口成本。缓存图像不会将其添加到自定义列表中。因此,Match Image API无法将
与缓存图片相匹配。

 

  ;

 


  1.     ;&NBSP;&NBSP; 将图像添加到列表中,然后检查它是否与之前的任何其他图像匹配,这些图像需要2个计数还是1个计数?因此,1为"添加图像"计数,1为"高速缓存图像"计数
    ,然后刷新索引,然后为"匹配图像"计数1计数。因此,仅匹配一张图片就需要3分吗?
  1.       Adding an image to your list and then checking if it matches with any other previous image, these would cost be 2 counts or just 1 count? Thus 1 count for "Add Image", 1 count for "Cache Image", then Refresh Index, and then 1 Count for "Match Image". Thus it would cost us 3 points for matching just a single image?


 

 

调用自定义图像列表管理API(即添加图像,删除图像,刷新索引)不计入每月配额,这些API有
速率限制为10 /秒 。因此,总体而言,这种情况将被视为1次通话(即匹配图像)。

 


  1.       是否可以在单个请求中获得裸露检查和图像匹配的响应?因此,我节省了时间。这会花费我们2分吗?
  1.       Is it possible to get a response of nudity checking and image matching in a single request? Thus, I save time. This would cost us 2 points right?

 

是的,你是对的,截至今天这些电话将被计为2.虽然,我们现在正在开发一个更具包容性的"审核API",它允许你将大部分这些电话放在一起。我们会随时向您发布。

 


  1.       在"刷新索引"页面上,它表示可能需要大约5分钟才能更新索引。但在我的网站上,用户将持续提交图像。因此,如果相隔几秒钟提交2张图片
    ,我们希望即使对于这样的图像也会发生重复检查。这会是可能的吗?
  1.       On the page of "Refresh Index", it says it can take around 5 minutes to do get the index updated. But on my site, users would be submitting images continuously. Thus if 2 images are submitted just seconds apart, we would like duplicate checking to happen even for such images. Would this be possible?

 

匹配Image API处理数据结构(启用模糊匹配),需要重新构建才能开始匹配新添加的图像。但是,在这种情况下,如果您只使用相同的图像两次调用添加图像API
,它会返回一个回复,说明图片已经存在于您的列表中。

The Match Image API works off data structures (that enable fuzzy matching) which need to be rebuilt before it can start matching newly added images. In this scenario though, if you just call the Add Image API with the same image twice, it would return you a response saying that the Image already exists in your list.

 

注意:虽然添加图像API会告诉您如果图像中已存在图像,它会在图像上完全匹配,并且不会启用模糊匹配。

 

 

 

 

解决电子邮件中提到的每个试用场景:

Addressing each Trial scenario mentioned in your email:

 

 

试用A:

Trial A:

你说的是正确的Add Image API在使用Content-Type:application / json调用时抛出异常。我们已经将此作为一个问题记录下来并积极地解决了这个问题。

 

同时,如果您在指定Content-Type时将原始图像作为正文传递,则Add Image API有效:< Image Mime Type>。 如下所示:

https://developer.microsoftmoderator.com/ docs / services / 54f79439e3a97812880825ce / operations / 54f79439e3a9780af42ee9ca

 

 

 

 

试用版B:

Trial B:

我们在最后验证了这个场景,它正在按预期工作。图像缓存时间为50秒。我们将更新门户网站上的文档以反映相同的情况。

 

如果您在50秒后在缓存中进行评估图像,那么您将收到http 410,其中包含"内容已在服务器上过期"。

在下面的示例中,图像缓存在
星期二,2016年5月24日15:41: 03 GMT
消费在
日期:星期二,2016年5月24日15:42:31 GMT
时间戳之间的差异大于50秒。

 

请重试此方案,如果您仍然遇到问题,请告诉我们。

 

 

试用C:

Trial C:

请使用以下呼叫顺序:


  1.        调用添加图像(请在将内容类型指定为图像的Mime类型时将图像传递到正文中)
  2.        呼叫刷新索引
  3.         调用匹配图像以匹配步骤1中添加的图像
  1.        Call Add Image(s) (please pass the image in body while specifying the Content-Type as the Mime type of the image)
  2.        Call Refresh Index
  3.        Call Match Image to match against the images that were added in step 1

< span style ="font-size:11.0pt; font-family:'Calibri',sans-serif"> 

 

 

 

另外,我们在Github上发布了我们的SDK

https://github.com/MicrosoftContentModerator/ContentModeratorSDK/tree/master/ContentModeratorSDK.NET

你可以参考当您与服务集成时,单元在套件中进行测试。

Also, we have our SDK published on Github: https://github.com/MicrosoftContentModerator/ContentModeratorSDK/tree/master/ContentModeratorSDK.NET. You can refer the Unit Tests in the suite as you integrate with the service.


这篇关于如何使用“匹配图像”内容主持人的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆