推广 热搜:   中国  未来  系统  政策  行业  设备  基金  快速  教师 

初探机器学习之使用百度AI服务实现图片识别与相似图片

   日期:2024-12-11     作者:caijiyuan    caijiyuan   评论:0    移动:http://mip.tpjde.com/news/3134.html
核心提示:public class Program{private static ImageSearch aipSearchClient;static Program(){aipSearchClient = new ImageSearch(Baidu
    public class Program

初探机器学习之使用百度AI服务实现图片识别与相似图片

{
private static ImageSearch aipSearchClient; static Program() { aipSearchClient = new ImageSearch(BaiduAipSimSettings.ApiKey, BaiduAipSimSettings.SecretKey); } public static void Main(string[] args) { var filePath = @"Images卧室.jpg"; // 相似图片Demo SimilarImageDemo(filePath); Console.ReadKey(); } private static void SimilarImageDemo(string filePath) {// 检索 var searchOptions = new Dictionary<string, object>{ {"tags", "100,1"}, {"tag_logic", "0"}, {"pn", "0"}, {"rn", "10"} }; SimilarSearchFromLib(filePath, searchOptions); } /// <summary> /// 单张图片入库 /// </summary> private static void importToLib(string filePath, Dictionary<string, object> options = null) { var image = File.ReadAllBytes(filePath); try { var result = aipSearchClient.SimilarAdd(image, options); Console.WriteLine("Api Response :"); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(ex.Message); } } /// <summary> /// 相似图检索 /// </summary> private static void SimilarSearchFromLib(string filePath, Dictionary<string, object> options = null) { var image = File.ReadAllBytes(filePath); try { var response = aipSearchClient.SimilarSearch(image, options).ToObject<SearchResponse>(); var result = response.Result.Take(5); Console.WriteLine("Similarity Result :"); foreach (var item in result) { Console.WriteLine("{0}:{1}", item.Brief, item.Score); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
本文地址:http://www.tpjde.com/news/3134.html    推平第 http://www.tpjde.com/ , 查看更多
 
 
更多>同类行业资讯
0相关评论

新闻列表
企业新闻
推荐企业新闻
推荐图文
推荐行业资讯
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2023001713号