阿里视觉AI训练营-day04-作业日-车辆保险应用

本文涉及的产品
对象存储 OSS,20GB 3个月
对象存储 OSS,内容安全 1000次 1年
对象存储 OSS,恶意文件检测 1000次 1年
简介: 车辆保险应用

阿里AI训练营【车辆保险应用】


# 前言 转载于:[【阿里云高校计划】车辆保险应用 day4 【拨云见日】](https://blog.csdn.net/weixin_42234067/article/details/106764710)
# 实施前准备工作 ## 一、本地图片上传为OSS #### 1.开通oss ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173041857.png#pic_center) #### 2.创建Bucket ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173108804.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center)![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173122550.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173134702.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) ## 二、开通目标检测服务 [阿里云视觉智能开放平台--目标检测](https://vision.aliyun.com/objectdet?spm=a211p3.14020179.J_7524944390.10.2c984b58Kfamiz) ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173234550.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center)![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173431528.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) ## 三、查看所需API 这里我们用到阿里云视觉智能开放平台提供的三个功能: - 车辆部件识别 - 车辆损伤识别 - 车险图片分类 ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102173511537.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) 1.车辆部件识别 > 检测图片中车辆部件的位置以及名称。 2.车辆损伤识别 > 针对常见小汽车车型,识别车辆外观受损部件及损伤类型,可识别数十种车辆部件、五大类外观损伤。(刮擦、凹陷、开裂、褶皱、穿孔) 3.车险图片分类 > 对输入的车险图片进行分类。 # 具体实施 ## 一、本地图片上传至OSS的uploadPic类 #### 车辆部件识别 ###### 1.在maven中导入所需依赖 ```java com.aliyun.ossaliyun-sdk-oss3.8.0 ``` ###### 2.编写UploadPic类 ```java package com.example.demo; import com.aliyun.oss.OSS; import com.aliyun.oss.OSSClientBuilder; import java.io.File; import java.net.URL; import java.security.SecureRandom; import java.util.Date; import java.lang.*; import java.util.Scanner; public class UploadPic { public static String UploadPic(){ // Endpoint以杭州为例,其它Region请按实际情况填写。 String endpoint = "oss-cn-shanghai.aliyuncs.com"; // 阿里云主账号AccessKey。 String accessKeyId = "*************"; String accessKeySecret = "*************"; //本地文件名 System.out.println("请输入本地图片path:"); Scanner scanner = new Scanner(System.in); String fileName = scanner.nextLine(); String bucketName = "auto-insurance-pic"; // 获取文件的后缀名 String suffixName = fileName.substring(fileName.lastIndexOf(".")); // 生成上传文件名 String objectName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + suffixName; // 创建OSSClient实例。 OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); // 如果需要上传时设置存储类型与访问权限,请参考以下示例代码。 // ObjectMetadata metadata = new ObjectMetadata(); // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); // metadata.setObjectAcl(CannedAccessControlList.Private); // putObjectRequest.setMetadata(metadata); // 上传文件。 ossClient.putObject(bucketName, objectName, new File(fileName)); // 设置URL过期时间为1小时。 Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000); // 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。 URL url = ossClient.generatePresignedUrl(bucketName, objectName, expiration); // 关闭OSSClient。 ossClient.shutdown(); return url.toString(); } } ``` ###### 3.运行结果 ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102174302405.png#pic_center)![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102174306965.png#pic_center) ## 二、车辆部件识别RecognizeVehicleParts类 #### 1.在maven中导入所需依赖 [阿里maven私有仓库服务](https://maven.aliyun.com/mvn/search) ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102175052583.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) ```java com.aliyunaliyun-java-sdk-core4.4.8com.alibabafastjson1.2.52com.aliyunaliyun-java-sdk-objectdet1.0.7 ``` #### 2.编写RecognizeVehicleParts类 ```java package com.example.demo; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.profile.DefaultProfile; import com.example.demo.UploadPic; import com.google.gson.Gson; import java.util.*; import com.aliyuncs.objectdet.model.v20191230.*; public class RecognizeVehicleParts { public static void main(String[] args) { DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "accessKeyId", "accessKeySecret"); IAcsClient client = new DefaultAcsClient(profile); RecognizeVehiclePartsRequest request = new RecognizeVehiclePartsRequest(); request.setRegionId("cn-shanghai"); request.setImageURL(UploadPic.UploadPic()); try { RecognizeVehiclePartsResponse response = client.getAcsResponse(request); System.out.println(new Gson().toJson(response)); } catch (ServerException e) { e.printStackTrace(); } catch (ClientException e) { System.out.println("ErrCode:" + e.getErrCode()); System.out.println("ErrMsg:" + e.getErrMsg()); System.out.println("RequestId:" + e.getRequestId()); } } } ``` #### 3.运行结果 ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102175250466.png#pic_center)返回值为: > {"requestId":"BBFB102D-5EAC-483F-9A94-9DA79A06E1F6","data":{"elements":[{"score":0.98788995,"type":"left_tail_light","boxes":[132,274,862,607]},{"score":0.952229,"type":"left_rear_wing","boxes":[4,162,365,750]},{"score":0.74785864,"type":"rear_bumper","boxes":[60,456,987,760]}],"originShapes":[768,1024]}} ## 三.车辆损伤识别 #### 1.在maven中导入所需依赖 见本文二-1 #### 2.编写RecognizeVehicleDamage类 ```java package com.example.demo; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.profile.DefaultProfile; import com.google.gson.Gson; import java.util.*; import com.aliyuncs.objectdet.model.v20191230.*; public class RecognizeVehicleDamage { public static void main(String[] args) { DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "accessKeyId", "accessKeySecret"); IAcsClient client = new DefaultAcsClient(profile); RecognizeVehicleDamageRequest request = new RecognizeVehicleDamageRequest(); request.setRegionId("cn-shanghai"); request.setImageURL(UploadPic.UploadPic()); try { RecognizeVehicleDamageResponse response = client.getAcsResponse(request); System.out.println(new Gson().toJson(response)); } catch (ServerException e) { e.printStackTrace(); } catch (ClientException e) { System.out.println("ErrCode:" + e.getErrCode()); System.out.println("ErrMsg:" + e.getErrMsg()); System.out.println("RequestId:" + e.getRequestId()); } } } ``` #### 3.识别结果 返回值为: > {"requestId":"7FFBD390-7019-4B85-9FFA-779C912A9CEB","data":{"elements":[{"score":0.414995,"type":"1","scores":[0.414995,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[343,390,473,542]},{"score":0.408405,"type":"1","scores":[0.408405,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[541,442,659,545]},{"score":0.348472,"type":"1","scores":[0.348472,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[273,293,423,400]},{"score":0.378637,"type":"2","scores":[0.0,0.378637,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[261,26,496,142]},{"score":0.873101,"type":"5","scores":[0.0,0.0,0.0,0.0,0.873101,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[91,4,555,267]},{"score":0.815785,"type":"6","scores":[0.0,0.0,0.0,0.0,0.0,0.815785,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[564,270,869,441]},{"score":0.845525,"type":"8","scores":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.845525,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"boxes":[230,234,529,313]},{"score":0.411336,"type":"11","scores":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.411336,0.0,0.0,0.0,0.0],"boxes":[632,425,922,563]},{"score":0.334054,"type":"11","scores":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.334054,0.0,0.0,0.0,0.0],"boxes":[538,91,733,194]},{"score":0.333818,"type":"11","scores":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.333818,0.0,0.0,0.0,0.0],"boxes":[694,157,899,286]},{"score":0.32519,"type":"11","scores":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.32519,0.0,0.0,0.0,0.0],"boxes":[523,87,902,278]}]}} ## 四.车险图片分类 #### 1.在maven中导入所需依赖 见本文二-1 #### 2.编写ClassifyVehicleInsurance类 ```java package com.example.demo; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.profile.DefaultProfile; import com.google.gson.Gson; import java.util.*; import com.aliyuncs.objectdet.model.v20191230.*; public class ClassifyVehicleInsurance { public static void main(String[] args) { DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "accessKeyId", "accessKeySecret"); IAcsClient client = new DefaultAcsClient(profile); ClassifyVehicleInsuranceRequest request = new ClassifyVehicleInsuranceRequest(); request.setRegionId("cn-shanghai"); request.setImageURL(UploadPic.UploadPic()); try { ClassifyVehicleInsuranceResponse response = client.getAcsResponse(request); System.out.println(new Gson().toJson(response)); } catch (ServerException e) { e.printStackTrace(); } catch (ClientException e) { System.out.println("ErrCode:" + e.getErrCode()); System.out.println("ErrMsg:" + e.getErrMsg()); System.out.println("RequestId:" + e.getRequestId()); } } } ``` #### 3.识别结果 ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102175903416.png#pic_center)返回值为: > {"requestId":"87BEADED-F581-4C38-9F5F-E6F8DF0A1BA5","data":{"threshold":0.0,"labels":[{"score":0.0046,"name":"others"},{"score":0.0164,"name":"detail"},{"score":0.1934,"name":"component"},{"score":0.0,"name":"vin"},{"score":8.0E-4,"name":"people"},{"score":2.0E-4,"name":"motor"},{"score":0.1439,"name":"semi-car"},{"score":0.0027,"name":"panoramic"},{"score":3.0E-4,"name":"license"},{"score":0.0169,"name":"CT-scan"},{"score":5.0E-4,"name":"truck"},{"score":0.0144,"name":"disassembly"},{"score":0.6059,"name":"scene"}]}} ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201102175927853.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5NzA2MzY5,size_16,color_FFFFFF,t_70#pic_center) # 总结 转载于:[【阿里云高校计划】车辆保险应用 day4 【拨云见日】](https://blog.csdn.net/weixin_42234067/article/details/106764710)
相关实践学习
借助OSS搭建在线教育视频课程分享网站
本教程介绍如何基于云服务器ECS和对象存储OSS,搭建一个在线教育视频课程分享网站。
目录
相关文章
|
4天前
|
机器学习/深度学习 人工智能 自然语言处理
当前AI大模型在软件开发中的创新应用与挑战
2024年,AI大模型在软件开发领域的应用正重塑传统流程,从自动化编码、智能协作到代码审查和测试,显著提升了开发效率和代码质量。然而,技术挑战、伦理安全及模型可解释性等问题仍需解决。未来,AI将继续推动软件开发向更高效、智能化方向发展。
|
6天前
|
机器学习/深度学习 人工智能 算法
AI在医疗领域的应用与挑战
本文探讨了人工智能(AI)在医疗领域的应用,包括其在疾病诊断、治疗方案制定、患者管理等方面的优势和潜力。同时,也分析了AI在医疗领域面临的挑战,如数据隐私、伦理问题以及技术局限性等。通过对这些内容的深入分析,旨在为读者提供一个全面了解AI在医疗领域现状和未来发展的视角。
32 10
|
6天前
|
机器学习/深度学习 人工智能 监控
探索AI在医疗领域的应用与挑战
本文深入探讨了人工智能(AI)在医疗领域中的应用现状和面临的挑战。通过分析AI技术如何助力疾病诊断、治疗方案优化、患者管理等方面的创新实践,揭示了AI技术为医疗行业带来的变革潜力。同时,文章也指出了数据隐私、算法透明度、跨学科合作等关键问题,并对未来的发展趋势进行了展望。
|
5天前
|
存储 人工智能 固态存储
如何应对生成式AI和大模型应用带来的存储挑战
如何应对生成式AI和大模型应用带来的存储挑战
|
机器学习/深度学习 新零售 人工智能
阿里云高校计划视觉AI五天训练营 Day 1——视觉应用探索
在这个人工智能已经普及的时代,各行各业都充斥着AI的身影。大部分人认为人工智能起点高,入门难,想要使用AI服务又无法独立完成编写,开发者可以通过阿里云视觉平台提供的通用且标准化的接入方式,快速接入及使用阿里云视觉平台提供的包括人脸人体、文字识别、商品理解、内容安全、图像识别、图像生产、分割抠图、视觉搜索、目标检测、图像分析处理、视频理解、视频生产、视频分割13个类目多个API能力,为其提供高易用、普惠的视觉API服务,帮助企业快速建立视觉智能技术的应用能力的综合性视觉AI能力平台。
1293 0
阿里云高校计划视觉AI五天训练营 Day 1——视觉应用探索
|
JSON 人工智能 API
阿里云高校计划视觉AI五天训练营 Day5
关爱环境卫生,人人有责,怎么快速识别垃圾的种类扔进相应的垃圾桶中,那接下来看如何快速识别垃圾分类。
阿里云高校计划视觉AI五天训练营 Day5
|
人工智能 达摩院 文字识别
阿里云视觉智能开放平台2021首秀——趣味视觉AI训练营限时免费报名中!
趣味视觉AI训练营限时报名中!!!新功能,新算法,阿里云视觉智能开发平台产品专家带你体验视觉AI平台新能力,0代码体验AI能力,一键生成可视化AI结果。本次训练营带来更多的视觉AI应用场景,达摩院算法专家分享图像分割的算法基础知识,演示人物背景替换实现过程,体验热门算法-人物动漫化。调用视觉AI能力体验AI带来的趣味性。
阿里云视觉智能开放平台2021首秀——趣味视觉AI训练营限时免费报名中!
|
编解码 人工智能 文字识别
阿里云高校计划视觉AI五天训练营 Day 2——身份证识别系统
本文介绍了如何使用阿里云视觉智能开放平台相关服务的PHP SDK,具体包括SDK的获取和安装方法以及SDK代码示例。
463 0
阿里云高校计划视觉AI五天训练营 Day 2——身份证识别系统
|
人工智能
阿里云高校计划视觉AI五天训练营教程 Day 2 - 身份证识别系统搭建
实战讲述如何使用阿里云视觉平台API快速开发在线视觉AI平台,主要如何为如何搭建身份证识别系统,进而扩展到其他的识别系统。
阿里云高校计划视觉AI五天训练营教程 Day 2 - 身份证识别系统搭建
|
人工智能 文字识别 前端开发
阿里云高校计划视觉AI五天训练营教程 Day 2 - 身份证识别系统搭建
本篇文章是基于阿里云高校计划AI课程第二讲,身份证识别系统搭建。在阿里云视觉开放平台上已有调试功能。
299 0
阿里云高校计划视觉AI五天训练营教程 Day 2 - 身份证识别系统搭建