当前位置: 首页 > news >正文

网站做权重的好处长春网站制作企业

网站做权重的好处,长春网站制作企业,网站建设与规划的书,政府网站建设管理现状文章目录 背景代码 背景 如果我们想要根据json标注文件,获取里面的指定目标的裁剪区域,那么我们可以根据以下代码来实现(也可以校验标注情况)。 代码 from tqdm import tqdm import os, json, cv2, copy import numpy as npdef…

文章目录

  • 背景
  • 代码

背景

如果我们想要根据json标注文件,获取里面的指定目标的裁剪区域,那么我们可以根据以下代码来实现(也可以校验标注情况)。

代码

from tqdm import tqdm
import os, json, cv2, copy
import numpy as npdef get_all_images(path, flags):result_list, filenames = [], []for root, dirs, files in os.walk(path):for file in files:filename, file_extension = os.path.splitext(file)if file_extension.lower() in flags:result_list.append(os.path.join(root, file))filenames.append(file)return result_list, filenamesdef get_labelme_info(label_file, target):anno = json.load(open(label_file, "r", encoding="utf-8"))shapes = anno['shapes']image_path = os.path.basename(anno['imagePath'])labels = []boxes = []for s in shapes:pts = s['points']x1, y1 = pts[0]x2, y2 = pts[1]label = s['label']if label in target:labels.append(label)boxes.append([x1, y1, x2, y2])return image_path, boxes, labelsdef plot_one_ori(image, boxs, label, color, mask_alpha=0.4):[x1, y1, x2, y2] = boxsmask_img = copy.deepcopy(image) # 1ori_img = copy.deepcopy(mask_img) # 1cropped_image = ori_img[y1:y2, x1:x2]img_height, img_width = image.shape[:2]size = min([img_height, img_width]) * 0.0006text_thickness = int(min([img_height, img_width]) * 0.001)cv2.rectangle(image, (x1, y1), (x2, y2), color, 3)caption = f'{"原标签-"}{label}'(tw, th), _ = cv2.getTextSize(text=caption, fontFace=cv2.FONT_HERSHEY_SIMPLEX,fontScale=size, thickness=text_thickness)th = int(th * 1.2)cv2.rectangle(image, (x1, y2),(x1 + tw, y2 + th), color, -1)cv2.rectangle(mask_img, (x1, y2),(x1 + tw, y2 + th), color, -1)cv2.putText(image, caption, (x1, y2 + th), cv2.FONT_HERSHEY_SIMPLEX, size, (255, 255, 255), text_thickness, cv2.LINE_AA)cv2.putText(mask_img, caption, (x1, y2 + th), cv2.FONT_HERSHEY_SIMPLEX, size, (255, 255, 255), text_thickness, cv2.LINE_AA)image = cv2.addWeighted(mask_img, mask_alpha, image, 1 - mask_alpha, 0)return image, cropped_imagedef cv_imread(filePath):cv_img = cv2.imdecode(np.fromfile(filePath, dtype=np.uint8), flags=cv2.IMREAD_COLOR)return cv_imgif __name__ == "__main__":img_folder = r"\\DSJ_NAS_90*******" # 原图和JSON文件位置save_target_path = r"\\DSJ_NA************" # 保存位置target = ["red_face"] # 获取指定目标,可传多个os.makedirs(save_target_path, exist_ok=True)img_list, filenames = get_all_images(img_folder, flags=[".jpg", ".png", ".jpeg"])print(filenames)for filename in filenames:fn, file_extension = os.path.splitext(filename)image_path = os.path.join(img_folder, filename)  # 图片名json_path = os.path.join(img_folder, "{}.json".format(fn))  # 标签文件名save_path = os.path.join(save_target_path, "{}.jpg".format(fn))_, ori_boxes, ori_labels = get_labelme_info(json_path, target)for box, label in zip(ori_boxes, ori_labels):x1, y1, x2, y2 = list(map(int, box))image = cv_imread(image_path)image, crop_image = plot_one_ori(image, [x1, y1, x2, y2], label, color=(0,0,255))# cv2.imshow("1",crop_image)# cv2.waitKey(1)cv2.imencode('.jpg', crop_image)[1].tofile(save_path)
http://www.shuangfujiaoyu.com/news/59331.html

相关文章:

  • 做网站推广前途网站收录教程
  • 网站通常用什么编程做关键词指数批量查询
  • 企业做网站的公司首页关键词排名代发
  • 找人做网站新的营销方式有哪些
  • 实用网站设计步骤长春百度推广排名优化
  • 什么网站发布任务有人做seo文章优化技巧
  • 全球贸易平台上海关键词优化的技巧
  • 成立网站资阳地seo
  • 阳逻开发区网站建设中企动力模板建站公司
  • 生物科技网站建设 中企动力北京建设网站的十个步骤
  • wordpress 阿里云点播seo建站教程
  • wordpress+整站下载app宣传推广方案
  • 网站 建设开发合同模板小说网站排名免费
  • 网红推广seo诊断的网络问题
  • 真人做爰网站视频网站seo工具
  • 做网站文案用哪个软件某个网站seo分析实例
  • 大学生asp网站开发的实训周百度提升优化
  • 怎么看一个网站是由哪个网络公司做的友情链接交易网站
  • 免费制作企业宣传册制作工具郑州百度推广seo
  • 松原做网站百度关键词排名
  • 西宁商城网站建设公司武汉整站优化
  • 建网站开发国外客户开发外包网站
  • 阿里云网站建设方案书一定要嘛百度小说排行榜2020
  • 网站后台修改不了电商网页制作教程
  • 推荐个在广州做网站的如何开发网站平台
  • 成都建设工程安监局网站石家庄百度推广排名优化
  • 怎么做卡盟网站免费如何做好关键词的优化
  • 做网站生意买螃蟹推广模式包括哪些模式
  • 做网站哪个语言好网页代码
  • 合肥外贸网站建设公司价格正规百度推广