以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 文字、图片自动审核(鉴别色情|恶心|政治|等等),该怎么做? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=106768) |
||||||||||||||||||||
-- 作者:zhangjian222200 -- 发布时间:2017/9/15 11:49:00 -- 文字、图片自动审核(鉴别色情|恶心|政治|等等),该怎么做? 如题: |
||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/15 11:57:00 -- 要调用api
https://cloud.baidu.com/product/imagecensoring
[此贴子已经被作者于2017/9/15 16:07:40编辑过]
|
||||||||||||||||||||
-- 作者:zhangjian222200 -- 发布时间:2017/9/15 15:15:00 -- 百度的先用后付,很好,网址:https://cloud.baidu.com/product/imagecensoring 能帮指导下怎么用么? 文档网址:http://ai.baidu.com/docs#/ImageCensoring-Java-SDK/top 创建应用后,可以选择下图中的sdk, [此贴子已经被作者于2017/9/21 18:37:35编辑过]
|
||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/15 16:01:00 -- 获取token
得到token 24.864d8f6c5046ba8fa0bc3ee503583c10.2592000.1508053325.282335-10146214
执行代码,获取信息
Dim bmp As new Bitmap("d:\\test.jpg") Dim arr(ms.Length) As Byte Dim strbase64 As String = Convert.ToBase64String(arr) Dim body As String = "{""image"":""" & strbase64 & """,""scenes"":[""ocr"",""face"",""public"",""politician"",""antiporn"",""terror"",""webimage""],""sceneConf"":{""ocr"":{""recognize_granularity"":""big"",""language_type"":""CHN_ENG"",""detect_direction"":""true"",""detect_language"":""true""},""antiporn"":{}}}" Dim stm As System.IO.Stream = pos.GetResponseStream() Dim jo As JObject = Jobject.Parse(str) [此贴子已经被作者于2017/9/15 16:03:47编辑过]
|
||||||||||||||||||||
-- 作者:zhangjian222200 -- 发布时间:2017/9/15 16:17:00 -- 我把上传图片页面代码、处理图片页面代码和js贴出来了。楼上代码应该放哪?(现有的图片审核是在js里面处理的) 图片上传页代码: Dim e As RequestEventArgs = args(0) \'注册第7页,上传照片 Dim wb As New weui If e.PostValues.Count = 0 Then wb.AddTopTips("","toptip1","") \'用于显示动态错误提示 wb.AddForm("","form1","valid_images.htm") With wb.AddInputGroup("form1","ipg1","展示照(选择1张靓照即可)") \'文件上传(1个) With.AddUploader("up1","",False) .AllowDelete = True \'允许用户删除图片 .ScaleWidth = 400 \'自动压缩图片宽度为400个像素,高度等比例压缩 End With End With With wb.AddInputGroup("form1","ipg22","生活照(选择3张以上靓照)") \'带图片浏览的文件上传(最少4个) With.AddUploader("up4","",True) \'True表示允许一次上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 .ScaleWidth = 400 \'自动压缩图片宽度为400个像素,高度等比例压缩 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "提交", "button").Attri-bute= "on-click=\'validit_images()\'" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajax-form_images.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 End If 图片处理页面: Dim e As RequestEventArgs = args(0) \'验证页面(照片) Dim wb As New weui Dim NewName As String \'应该是照片的新名字 Dim drbianh As String = e.Cookies("drbianhao") \'为cookie传递数据 Dim dr As DataRow = DataTables("会员资料").sql-Find("会员编号 = \'" & drbianh & "\'") If dr IsNot Nothing Then \'测试代码:msgbox(e.PostValues("isr")) For Each key As String In e.Files.Keys If key = "up1" Then For Each fln As String In e.Files(key) \'msgbox(0) Dim ext As String = fln.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmss") & Rand.Next(10000,99999) & "." & ext e.SaveFile(key, fln, "e:\\web\\zsz\\d\\" & Format(Date.Today, "yyyyMM") & "\\" & NewName) dr("展示照") &= iif(dr.IsNull("展示照"), "", vbcrlf) & Format(Date.Today, "yyyyMM") & "\\" & NewName Next End If Next For Each key1 As String In e.Files.Keys If key1 = "up4" Then For Each fln1 As String In e.Files(key1) Dim ext1 As String = fln1.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmss") & Rand.Next(10000,99999) & "." & ext1 e.SaveFile(key1, fln1, "e:\\web\\shz\\d\\" & Format(Date.Today, "yyyyMM") & "\\" & NewName) dr("生活照") &= iif(dr.IsNull("生活照"), "", vbcrlf) & Format(Date.Today, "yyyyMM") & "\\" & NewName Next End If Next dr.save() \'保存 e.WriteString("OK") \'生成网页 Else e.WriteString("没有找到会员行!请重新登录,再试!") End If js代码: function validit_images(){ var v1 = docu-ment.get-ElementById("up1_thumbnails").get-ElementsByTagName("li").length; var v2 = docu-ment.get-ElementById("up4_thumbnails").get-ElementsByTagName("li").length; //alert(v1 + " " + v2); var frm = docu-ment.get-ElementById("form1"); var frmdata = new FormData(frm); if (frm.incremental) { var fluds = frm.get-ElementsByClassName("weui_uploader_input"); for (var idx = 0; idx < fluds.length; idx++) { var files = fluds[idx].Files; if (files) { for (var i = 0; i < files.length; i++) { alert(files[i].blobFile); var fln = files[i].blobFile if (typeof(fln) == "undefined") { //alert("照片格式不正确"); showTopTips("toptip1","照片格式不正确!",2000); return false; } fln = fln.substring(fln.lastIndexOf(".") + 1).toLowerCase(); switch (fln) { case "jpg": case "jpeg": case "png": case "gif": case "bmp": break; default: //alert("照片格式不正确"); showTopTips("toptip1","照片格式不正确!",2000); return false; } } } } } if(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传!",2000); return false; } if(v1 > 1){ showTopTips("toptip1","展示照只可以上传1张!",2000); return false; } if(v2 < 3){ showTopTips("toptip1","请选择3张以上生活照上传!",2000); return false; } if(v2 > 9){ showTopTips("toptip1","生活照最多可以上传9张!",2000); return false; } show("tst1",2000); var result = submitAjaxForm(\'form1\',\'afterSubmit\'); } function afterSubmit(result){ hide("tst1"); if (result==\'OK\') { show("tst2"); location="success.htm"; } else{ show("tst3",2000); } } [此贴子已经被作者于2017/9/15 16:25:44编辑过]
|
||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/15 17:30:00 -- 写在 e.SaveFile 的后面。
你保存图片以后,把图片发过去验证,如果验证是错误的,就把图片删除,同时返回信息告知用户。 |
||||||||||||||||||||
-- 作者:zhangjian222200 -- 发布时间:2017/9/16 19:07:00 -- 看了4楼代码,然后在百度创建了一个应用,截图如下:(创建网址:https://cloud.baidu.com/product/imagecensoring) 如何把里面的AppID、API Key、Secret Key,放在4楼给出的代码里? |
||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/17 16:23:00 -- 先获取token(一个月有效)具体看帮助文档,参考如何获取token。
红色代码就是你要替换的东西
得到token 24.864d8f6c5046ba8fa0bc3ee503583c10.2592000.1508053325.282335-10146214 |
||||||||||||||||||||
-- 作者:zhangjian222200 -- 发布时间:2017/9/21 12:10:00 -- 4楼代码 1.最后一句:jo.ToString,是返回的检测结果吗? 2.红色部分看不懂,是将文字识别、人脸识别、图像审核,都包含进来了吗? Dim body As String = "{""image"":""" & strbase64 & """,""scenes"":[""ocr"",""face"",""public"",""politician"",""antiporn"",""terror"",""webimage""],""sceneConf"":{""ocr"":{""recognize_granularity"":""big"",""language_type"":""CHN_ENG"",""detect_direction"":""true"",""detect_language"":""true""},""antiporn"":{}}}"
[此贴子已经被作者于2017/9/21 12:18:56编辑过]
|
||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/21 12:23:00 -- 你需要什么,你就合成什么,参考
请求参数
|