国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

可以自己做網(wǎng)站優(yōu)化嗎體驗(yàn)式營銷經(jīng)典案例

可以自己做網(wǎng)站優(yōu)化嗎,體驗(yàn)式營銷經(jīng)典案例,wordpress 企業(yè) 主題,個人淘寶客網(wǎng)站備案本筆記內(nèi)容為黑馬頭條項(xiàng)目的文本-圖片內(nèi)容審核接口部分 目錄 一、概述 二、準(zhǔn)備工作 三、文本內(nèi)容審核接口 四、圖片審核接口 五、項(xiàng)目集成 一、概述 內(nèi)容安全是識別服務(wù),支持對圖片、視頻、文本、語音等對象進(jìn)行多樣化場景檢測,有效降低內(nèi)容違規(guī)風(fēng)…

本筆記內(nèi)容為黑馬頭條項(xiàng)目的文本-圖片內(nèi)容審核接口部分

目錄

一、概述

二、準(zhǔn)備工作

三、文本內(nèi)容審核接口

四、圖片審核接口

五、項(xiàng)目集成


一、概述


內(nèi)容安全是識別服務(wù),支持對圖片、視頻、文本、語音等對象進(jìn)行多樣化場景檢測,有效降低內(nèi)容違規(guī)風(fēng)險。

目前很多平臺都支持內(nèi)容檢測,如阿里云、騰訊云、百度AI、網(wǎng)易云等國內(nèi)大型互聯(lián)網(wǎng)公司都對外提供了API。

按照性能和收費(fèi)來看,黑馬頭條項(xiàng)目使用的就是阿里云的內(nèi)容安全接口,使用到了圖片和文本的審核。

阿里云收費(fèi)標(biāo)準(zhǔn):價格計算器 (aliyun.com)

二、準(zhǔn)備工作


您在使用內(nèi)容檢測API之前,需要先注冊阿里云賬號,添加Access Key并簽約云盾內(nèi)容安全。 ?

操作步驟

1、前往阿里云官網(wǎng)注冊賬號。如果已有注冊賬號,請?zhí)^此步驟。

進(jìn)入阿里云首頁后,如果沒有阿里云的賬戶需要先進(jìn)行注冊,才可以進(jìn)行登錄。由于注冊較為簡單,課程和講義不在進(jìn)行體現(xiàn)(注冊可以使用多種方式,如淘寶賬號、支付寶賬號、微博賬號等...)。需要實(shí)名認(rèn)證和活體認(rèn)證。

2、打開云盾內(nèi)容安全產(chǎn)品試用頁面,單擊立即開通,正式開通服務(wù)。

注意 :現(xiàn)在這個服務(wù)需要企業(yè)認(rèn)證才能使用?

所以我改用了阿里視覺智能開發(fā)平臺的審核功能視覺智能開放平臺-控制臺 (aliyun.com)

購買資源包,我第一次購買不用錢,免費(fèi)送了1萬點(diǎn)

3、在AccessKey管理頁面管理您的AccessKeyID和AccessKeySecret。

管理自己的AccessKey,可以新建和刪除AccessKey

查看自己的AccessKey,AccessKey默認(rèn)是隱藏的,第一次申請的時候可以保存AccessKey,點(diǎn)擊顯示,通過驗(yàn)證手機(jī)號后也可以查看

三、文本內(nèi)容審核接口


文本垃圾內(nèi)容檢測: 文本內(nèi)容安全 (aliyun.com)

文本垃圾內(nèi)容Java SDK: Java (aliyun.com)

四、圖片審核接口


圖片垃圾內(nèi)容檢測:圖片內(nèi)容安全 (aliyun.com)

圖片垃圾內(nèi)容Java SDK:Java (aliyun.com)

五、項(xiàng)目集成


這里的代碼是使用智能開發(fā)平臺的審核功能

①:common模塊下面添加工具類,并添加到自動配置

aliyun包下的GreenImageScan.java和GreenTextScan.java

GreenImageScan代碼

package com.heima.common.aliyun;import com.alibaba.fastjson.JSON;import com.aliyun.imageaudit20191230.models.ScanImageRequest;
import com.aliyun.imageaudit20191230.models.ScanImageResponse;
import com.aliyun.imageaudit20191230.models.ScanImageResponseBody;import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.stereotype.Component;import java.util.*;@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "aliyun")
public class GreenImageScan {private String accessKeyId;private String secret;private String scenes;public Map imageScan(List<String> imageList) throws Exception {com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config().setAccessKeyId(accessKeyId).setAccessKeySecret(secret);// 訪問的域名config.endpoint = "imageaudit.cn-shanghai.aliyuncs.com";com.aliyun.imageaudit20191230.Client client = new com.aliyun.imageaudit20191230.Client(config);List<ScanImageRequest.ScanImageRequestTask> taskList = new ArrayList<>();for (String  img: imageList) {ScanImageRequest.ScanImageRequestTask task = new ScanImageRequest.ScanImageRequestTask();task.setImageURL(img);task.setDataId(UUID.randomUUID().toString());task.setImageTimeMillisecond(1L);task.setInterval(1);task.setMaxFrames(1);taskList.add(task);}//場景List<String> sceneList = new ArrayList<>();sceneList.add(scenes);sceneList.add("logo");sceneList.add("porn");com.aliyun.imageaudit20191230.models.ScanImageRequest scanImageRequest = new com.aliyun.imageaudit20191230.models.ScanImageRequest().setTask(taskList).setScene(sceneList);com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();try {ScanImageResponse scanImageResponse = client.scanImageWithOptions(scanImageRequest, runtime);Map<String, String> resultMap = new HashMap<>();if (scanImageResponse.getStatusCode() == 200) {List<ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults> subResults = scanImageResponse.body.data.results.get(0).getSubResults();ListIterator<ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults> listIterator = subResults.listIterator();while (listIterator.hasNext()) {ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults item = listIterator.next();System.out.println("scene = [" + item.scene + "]");System.out.println("suggestion = [" + item.suggestion + "]");System.out.println("label = [" + item.label + "]");if (!item.suggestion.equals("pass")) {resultMap.put("suggestion", item.suggestion);resultMap.put("label", item.label);return resultMap;}}resultMap.put("suggestion", "pass");} else {/*   ** 表明請求整體處理失敗,原因視具體的情況詳細(xì)分析*/System.out.println("the whole image scan request failed. response:" + JSON.toJSONString(scanImageResponse));return null;}} catch (com.aliyun.tea.TeaException teaException) {// 獲取整體報錯信息System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));// 獲取單個字段System.out.println(teaException.getCode());}return null;/*  Map<String, String> resultMap = new HashMap<>();resultMap.put("suggestion", "pass");return resultMap;*/}
}

?GreenTextScan代碼

package com.heima.common.aliyun;import com.aliyun.imageaudit20191230.*;
import com.aliyun.imageaudit20191230.models.ScanTextRequest;
import com.aliyun.imageaudit20191230.models.ScanTextResponse;
import com.aliyun.imageaudit20191230.models.ScanTextResponseBody;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;import java.util.*;@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "aliyun")
public class GreenTextScan {private String accessKeyId;private String secret;public Map greeTextScan(String content) throws Exception {/*初始化配置對象com.aliyun.teaopenapi.models.ConfigConfig對象存放 AccessKeyId、AccessKeySecret、endpoint等配置*/Config config = new Config().setAccessKeyId(accessKeyId).setAccessKeySecret(secret);// 訪問的域名config.endpoint = "imageaudit.cn-shanghai.aliyuncs.com";Client client = new Client(config);ScanTextRequest.ScanTextRequestTasks tasks = new ScanTextRequest.ScanTextRequestTasks().setContent(content);  //審核內(nèi)容ScanTextRequest.ScanTextRequestLabels labels = new ScanTextRequest.ScanTextRequestLabels().setLabel("abuse");  //設(shè)置審核類型ScanTextRequest scanTextRequest = new ScanTextRequest().setLabels(java.util.Arrays.asList(labels)).setTasks(java.util.Arrays.asList(tasks));RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();Map<String, String> resultMap = new HashMap<>();try {// 復(fù)制代碼運(yùn)行請自行打印API的返回值ScanTextResponse response = client.scanTextWithOptions(scanTextRequest, runtime);//System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));if (response.getStatusCode() == 200) {ScanTextResponseBody.ScanTextResponseBodyDataElementsResults elementsResults = response.body.getData().elements.get(0).results.get(0);if (!elementsResults.suggestion.equals("pass")) {resultMap.put("suggestion", elementsResults.suggestion);resultMap.put("label", elementsResults.label);return resultMap;}resultMap.put("suggestion", "pass");return resultMap;} else {return null;}} catch (TeaException error) {// 獲取整體報錯信息System.out.println(com.aliyun.teautil.Common.toJSONString(error));// 獲取單個字段System.out.println(error.getCode());error.printStackTrace();}return null;}
}

添加到自動配置中

②: accessKeyId和secret(需自己申請)

在heima-leadnews-wemedia中的nacos配置中心添加以下配置:

aliyun:accessKeyId: LTAI5tCWHCcfvqQzu8k2oKmXsecret: auoKUFsghimbfVQHpy7gtRyBkoR4vc
#aliyun.scenes=porn,terrorism,ad,qrcode,live,logoscenes: terrorism

③:在自媒體微服務(wù)中測試類中注入審核文本和圖片的bean進(jìn)行測試

package com.heima.wemedia;import com.heima.common.aliyun.GreenImageScan;
import com.heima.common.aliyun.GreenTextScan;
import com.heima.file.service.FileStorageService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;@SpringBootTest(classes = WemediaApplication.class)
@RunWith(SpringRunner.class)
public class AliyunTest {@Autowiredprivate GreenTextScan greenTextScan;@Autowiredprivate GreenImageScan greenImageScan;@Autowiredprivate FileStorageService fileStorageService;@Testpublic void testScanText() throws Exception {Map map = greenTextScan.greeTextScan("王天剛?cè)ワ埖瓿燥埡蟀l(fā)現(xiàn)自己的車子被刮了,破口大罵是哪個傻逼干的?");System.out.println(map);}@Testpublic void testScanImage() throws Exception {List<String> list=new ArrayList<>();list.add("http://192.168.200.130:9000/leadnews/2021/04/26/ef3cbe458db249f7bd6fb4339e593e55.jpg");Map map = greenImageScan.imageScan(list);System.out.println(map);}}

結(jié)束!

http://aloenet.com.cn/news/32557.html

相關(guān)文章:

  • 門戶網(wǎng)站建設(shè)談判搜狗站長平臺主動提交
  • 網(wǎng)站開發(fā)的具體流程網(wǎng)站發(fā)布平臺
  • 西寧網(wǎng)站seo公司seo推廣效果
  • 國內(nèi)頂尖網(wǎng)站設(shè)計公司口碑營銷的定義
  • 免費(fèi)做外貿(mào)的網(wǎng)站深圳谷歌推廣公司
  • 幫彩票網(wǎng)站做流量提升seo賺錢方式
  • 東莞網(wǎng)站建設(shè) 環(huán)保設(shè)備自創(chuàng)網(wǎng)站
  • 武漢建站中心百度廣告競價排名
  • 淘客網(wǎng)站要怎么做黑帽seo技巧
  • 政府網(wǎng)站建設(shè)事例常見的推廣方式有哪些
  • 遼河油田建設(shè)有限公司網(wǎng)站找個網(wǎng)站
  • 9420高清免費(fèi)視頻在線觀看武漢抖音seo搜索
  • 做網(wǎng)站需要懂什么廣州網(wǎng)頁定制多少錢
  • 做怎么樣的網(wǎng)站好如何自己弄個免費(fèi)網(wǎng)站
  • 怎么做一元購網(wǎng)站代運(yùn)營公司哪家好一些
  • 做網(wǎng)站靠教育賺錢seo的基礎(chǔ)優(yōu)化
  • com是什么網(wǎng)站廣告推廣策劃
  • 我的世界做披風(fēng)網(wǎng)站友情鏈接檢測的特點(diǎn)
  • 松原網(wǎng)站制作如何讓百度收錄自己的網(wǎng)站
  • 婁底網(wǎng)站建設(shè)的話術(shù)北京seo運(yùn)營推廣
  • 網(wǎng)站建設(shè)基礎(chǔ)大綱文案軟文推廣有哪些
  • 網(wǎng)站開發(fā)用的那些語言怎么在百度發(fā)布自己的文章
  • 花店網(wǎng)站建設(shè)環(huán)境分析百度搜索什么關(guān)鍵詞能搜到網(wǎng)站
  • 午夜做網(wǎng)站營銷網(wǎng)站的宣傳、推廣與運(yùn)作
  • 淘寶站內(nèi)推廣方式有哪些班級優(yōu)化大師使用心得
  • 許昌做網(wǎng)站漢獅網(wǎng)絡(luò)青島seo關(guān)鍵詞優(yōu)化公司
  • 網(wǎng)上建站賺錢微信公眾號推廣軟文案例
  • 西安微信公眾號制作seo優(yōu)化快速排名
  • 網(wǎng)站建設(shè) 中國聯(lián)盟網(wǎng)百度網(wǎng)頁版登錄首頁
  • 怎么把網(wǎng)站提交百度的推廣廣告