python tool method 44 data simulation generation (paste target slices to the background image, data label verification)

Data is a very important factor in deep learning training. When the data is not enough, we need to enhance and generate new data based on the existing data. In addition, in some special cases, if the prediction effect is poor for certain target slice data (for example, stone segmentation slices), its frequency in the training data needs to be enhanced. Therefore, we can crop out the targets in the existing data annotations and paste them as samples into other background images to generate new training data.同时,我们还实现了目标切片移除方法,基于该方法可以在没有外部数据的情况下生成背景图片,也可以用于检验数据标注是否完全正确。

1. Target slice generation

Target cropping needs to be extracted according to the json annotation format. The following code will crop out all the sk categories in the annotation data in the sk_new directory and save them in the crops directory.

import cv2
import json
import numpy as np
import os
#石块裁剪函数
def imgcrop(root,fpath):
    

おすすめ

転載: blog.csdn.net/a486259/article/details/135038236