# API_final exam **Repository Path**: lin_shiying/api_final-exam ## Basic Information - **Project Name**: API_final exam - **Description**: No description available - **Primary Language**: Unknown - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-14 - **Last Updated**: 2021-06-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # API_final exam ## 产品需求文档——识图 | 产品需求文档 | | |---|---| | 产品名 | 识图 | | 版本 | 1.0 | | 产品描述 | 当用户想要针对某一张图片了解更多有关信息时,却找不到图片的具体来源。识图app将会为您解决这个问题。通过OCR技术,支持以图识图,找到图片来源和更多相关信息。 | ### 一、背景/产品特色(MVP、价值主张宣言) 让图片不再神秘,随时随地,一键即知。 ### 二、用户需求/价值主张画布 #### 1.使用场景具体化说明 当用户想要针对某一张图片了解更多有关信息时,却找不到图片的具体来源。识图app将会为您解决这个问题。通过OCR技术,支持以图识图,找到图片来源和更多相关信息。 #### 2.用户画像具体说明 | 姓名 | 张欣怡 | |---|---| | 性别 | 女| | 年龄 | 20 | | 职业 | 艺术类大学生 | | 用户行为 | 在互联网或书籍中学习各种艺术类别,偏好欣赏现代艺术作品。 | | 用户需求 | 因为专业原因,需要对网络上一些未标注作者或画名的绘画进行识别,以进行学习。 | | 姓名 | 谭延 | |---|---| | 性别 | 男 | | 年龄 |17 | | 职业 | 学生 | | 用户行为 | 在日常社交中经常使用表情包,经常使用的表情包类型是可爱猫咪和熊猫头。| | 用户需求 | 希望能够拥有最新最热的表情包,并且能够根据聊天对话的情景搜索对应表情包。 | ![用户1](https://images.gitee.com/uploads/images/2021/0124/000631_56e878b8_5330565.png "用户1.png") ![用户2](https://images.gitee.com/uploads/images/2021/0124/000643_f73780dc_5330565.png "用户2.png") #### 3.用户需求列表展示 - 用户需求列表: | 需求 | API | 优先级 | |---|---| --- | | 搜索到已有图片的相关信息 | OCR | 1 | | 通过关键字索引图片 | 词法分析 | 2 | | 搜索相似图片 | OCR | 3 | - 信息结构图: ![信息](https://images.gitee.com/uploads/images/2021/0123/212553_f404d10b_5330565.png "信息结构图.png") #### 4.利害相关分析 产品主要使用OCR识别技术,这个人工智能对于用户需求的解决方案来说是最匹配的智能类型。面对系统识别的偏差问题,将会对用户搜索结果呈现页,提供“报错反馈”的选项,或者让用户针对搜索结果加以关键字描述后,再次进行搜索,以降低系统误差。 #### 5.商业模式画布 ![商业](https://images.gitee.com/uploads/images/2021/0123/212811_7b453026_5330565.png "商业模式画布完整.png") #### 6.价值主张画布 ![价值](https://images.gitee.com/uploads/images/2021/0123/231542_42821b35_5330565.png "价值主张画布.png") #### 7.加值的输入和输出 ![加值](https://images.gitee.com/uploads/images/2021/0123/233602_53c329d3_5330565.png "加值.png") ### 三、产品架构 #### 1.信息结构图 ![1](https://images.gitee.com/uploads/images/2021/0123/213001_e4720824_5330565.png "信息结构图.png") ![2](https://images.gitee.com/uploads/images/2021/0123/213010_ec3ddc31_5330565.png "信息结构图2.png") #### 2.梳理需求(产品结构图和用户流程图) ![用户流程图](https://images.gitee.com/uploads/images/2021/0123/213055_1fd7172d_5330565.png "用户流程图.png") ![旅程图](https://images.gitee.com/uploads/images/2021/0124/002854_bdadaea6_5330565.png "旅程图.png") #### 3.原型设计(手绘原型,灰模原型,交互原型)(简要版) 完整展示链接:[https://modao.cc/app/66e6d485f2697678413e911c5377c1fcda884b12?simulator_type=device&sticky](https://modao.cc/app/66e6d485f2697678413e911c5377c1fcda884b12?simulator_type=device&sticky) ![简版](https://images.gitee.com/uploads/images/2021/0123/233834_48cabcc0_5330565.png "简版.png") ### 四、界面流程及关键智能交互——原型设计 #### 1.用户体验分析 产品整体页面结构简洁,app功能针对性强,目标用户群体可以直接进行需求的快速实现。 ![流程图](https://images.gitee.com/uploads/images/2021/0123/213504_50c5fcb5_5330565.png "用户流程图.png") #### 2.设计的用户可欲性 主页简洁,并且设置有图片推荐页面,吸引用户停留,争取多用户使用可能性以及可欲性。 #### 3.设计的技术和商业可行性 腾讯云、百度智能云提供了一定数量的免费API调用额度和优惠的额度套餐服务支持我们的产品技术运行。众多开放平台都有OCR技术API的接口可供使用,请求次数在支撑起初步的“识图”产品预计在可承担范围之内。 图形交互以及图片的使用在生活中是必不可少的一部分,对于想要进行可靠的图片搜索的人群来说,识图产品的出现是可以吸引眼球和关注的。在现存的图片搜索功能的app中,能够做到更多的图片信息的收纳的能力少之又少,识图app的出现在商业可行性上存在很大的可能性。 ### 五、数据流程和关键API使用(详细功能) #### 1.数据流程图 ![数据流程图](https://images.gitee.com/uploads/images/2021/0123/213637_f164a4af_5330565.png "数据流程图.png") #### 2.关键API使用 OCR (Optical Character Recognition,光学字符识别)是指电子设备(例如扫描仪或数码相机)检查纸上打印的字符,通过检测暗、亮的模式确定其形状,然后用字符识别方法将形状翻译成计算机文字的过程;即,针对印刷体字符,采用光学的方式将纸质文档中的文字转换成为黑白点阵的图像文件,并通过识别软件将图像中的文字转换成文本格式,供文字处理软件进一步编辑加工的技术。如何除错或利用辅助信息提高识别正确率,是OCR最重要的课题,ICR(Intelligent Character Recognition)的名词也因此而产生。衡量一个OCR系统性能好坏的主要指标有:拒识率、误识率、识别速度、用户界面的友好性,产品的稳定性,易用性及可行性等。 词法分析接口(百度) 接口描述 1、词法分析(通用版):向用户提供分词、词性标注、专名识别三大功能;能够识别出文本串中的基本词汇(分词),对这些词汇进行重组、标注组合后词汇的词性,并进一步识别出命名实体。 2、词法分析(定制版):向用户提供分词、词性标注、专名识别三大功能;用户在控制台中进行个性化配置,支持自定义专有名词词表与规则,通过定制版可有效识别应用场景中的小众词汇与类别。 - 代码测试: 1.OCR(详情可以打开计算机视觉.ipynb这个文件,以下为精简版内容) ``` import os import sys import requests # If you are using a Jupyter notebook, uncomment the following line. # %matplotlib inline import matplotlib.pyplot as plt from PIL import Image from io import BytesIO # Add your Computer Vision subscription key and endpoint to your environment variables. if 'COMPUTER_VISION_SUBSCRIPTION_KEY' in os.environ: subscription_key = os.environ['COMPUTER_VISION_SUBSCRIPTION_KEY'] else: print("\nSet the COMPUTER_VISION_SUBSCRIPTION_KEY environment variable.\n**Restart your shell or IDE for changes to take effect.**") sys.exit() if 'COMPUTER_VISION_ENDPOINT' in os.environ: endpoint = os.environ['COMPUTER_VISION_ENDPOINT'] analyze_url = endpoint + "vision/v3.1/analyze" # Set image_path to the local path of an image that you want to analyze. # Sample images are here, if needed: # https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images image_path = "C:/Users/LINLIN/OneDrive/图片/屏幕快照/2019-06-30 (3).png" # Read the image into a byte array image_data = open(image_path, "rb").read() headers = {'Ocp-Apim-Subscription-Key': subscription_key, 'Content-Type': 'application/octet-stream'} params = {'visualFeatures': 'Categories,Description,Color'} response = requests.post( analyze_url, headers=headers, params=params, data=image_data) response.raise_for_status() # The 'analysis' object contains various fields that describe the image. The most # relevant caption for the image is obtained from the 'description' property. analysis = response.json() print(analysis) image_caption = analysis["description"]["captions"][0]["text"].capitalize() # Display the image and overlay it with the caption. image = Image.open(BytesIO(image_data)) plt.imshow(image) plt.axis("off") _ = plt.title(image_caption, size="x-large", y=-0.1) plt.show() ``` ``` {'categories': [{'name': 'others_', 'score': 0.00390625}, {'name': 'people_', 'score': 0.7109375, 'detail': {'celebrities': [{'name': 'Kanna Hashimoto', 'confidence': 0.9318345189094543, 'faceRectangle': {'left': 632, 'top': 230, 'width': 404, 'height': 404}}]}}], 'color': {'dominantColorForeground': 'Black', 'dominantColorBackground': 'Black', 'dominantColors': ['Black', 'Grey'], 'accentColor': '634949', 'isBwImg': False, 'isBWImg': False}, 'description': {'tags': ['text', 'person', 'necktie', 'suit', 'wearing'], 'captions': [{'text': 'Kanna Hashimoto in a suit', 'confidence': 0.490845650434494}]}, 'requestId': '1879615c-5d80-4078-a1e7-a91f87273fa9', 'metadata': {'height': 1080, 'width': 1920, 'format': 'Png'}} ``` ![ocr](https://images.gitee.com/uploads/images/2021/0123/214536_970f8502_5330565.png "OCR.png") 2.词法分析 ``` def baidu_lexer(text): url = "https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?access_token="+access_token data = { "text" : text } encode_data=json.dumps(data).encode('UTF-8') headers = { 'Content-Type':'application/json' } return requests.post(url,encode_data).content ``` ``` content_lexer = baidu_lexer(text="百度是一家高科技公司") # 二进制转换GBK content_lexer_str = str(content_lexer,encoding="GBK") # str转换dict content_lexer_dict =json.loads(content_str) # 表格化清晰展示词法分析结果 pd.json_normalize(content_lexer_dict["items"]) ``` ![词法](https://images.gitee.com/uploads/images/2021/0123/214551_dd69d374_5330565.png "词法分析.png") ### 六、非功能需求 - 运营需求:app后台管理人员、数据管理人员、技术支持开发人员。 ### 七、心得总结及感谢 从“百度识图,以图搜信息,发现更多可能。” 理想状态下,“百度识图”应该就像一位身边见多识广的朋友,你给他看个东西,他就能告诉你它的细节点滴,然后还能给你点建议...... 然而目前的百度识图显然没有做到那一步,能不误导用户就是万幸了,当然图片精确点效果还是挺惊喜的。 以这个问题为出发点构想“识图”app这个产品。分析一款APP最好的办法就是用用用,在实践中找优缺点,如果你来设计,你会做哪些优化?这个问题也是在产品设计里面非常重要的问题,在后续的开发完善过程当中也是需要重视的。[https://www.jianshu.com/p/1d9f87c62bb2](https://www.jianshu.com/p/1d9f87c62bb2) 在开发构思过程中,[https://www.zhihu.com/question/55568372](https://www.zhihu.com/question/55568372),此网站内的内容给与了我启发和参考。 在了解识图类产品或者功能的方面,通过以下网站进行了参考和学习了解: [https://www.zhihu.com/question/273737693](https://www.zhihu.com/question/273737693) [https://www.bilibili.com/read/cv8688532/](https://www.bilibili.com/read/cv8688532/) [https://zhuanlan.zhihu.com/p/74373625?utm_source=qq](https://zhuanlan.zhihu.com/p/74373625?utm_source=qq) [https://weibo.com/ttarticle/p/show?id=2309404139583641142749&sudaref=www.baidu.com](https://weibo.com/ttarticle/p/show?id=2309404139583641142749&sudaref=www.baidu.com) [https://graph.baidu.com/pcpage/index?tpl_from=pc&query](https://graph.baidu.com/pcpage/index?tpl_from=pc&query) [https://baike.baidu.com/item/%E7%99%BE%E5%BA%A6%E8%AF%86%E5%9B%BE/8231061?fr=aladdin](https://baike.baidu.com/item/%E7%99%BE%E5%BA%A6%E8%AF%86%E5%9B%BE/8231061?fr=aladdin) [https://cloud.baidu.com/product/imagerecognition?track=cp:nsem|pf:pc|pp:nsem-chanpin-tuxiangshibie-xiaoguo|pu:tuxiangshibie-tongyongci|ci:|kw:10032717&bd_vid=11110934165460576351](https://cloud.baidu.com/product/imagerecognition?track=cp:nsem|pf:pc|pp:nsem-chanpin-tuxiangshibie-xiaoguo|pu:tuxiangshibie-tongyongci|ci:|kw:10032717&bd_vid=11110934165460576351) [https://ai.baidu.com/ai-doc/IMAGERECOGNITION/Kk3bcxbxj](https://ai.baidu.com/ai-doc/IMAGERECOGNITION/Kk3bcxbxj) [https://zhuanlan.zhihu.com/p/64668636](https://zhuanlan.zhihu.com/p/64668636) [https://www.csdn.net/tags/MtzaAgxsMTEyMjAtYmxvZwO0O0OO0O0O.html](https://www.csdn.net/tags/MtzaAgxsMTEyMjAtYmxvZwO0O0OO0O0O.html) #### 使用图表共15个、有效链接13个