H55555555

    def computeOks(self, imgId, catId):
        p = self.params
        # dimention here should be Nxm
        gts = self._gts[imgId, catId]
        dts = self._dts[imgId, catId]
        inds = np.argsort([-d['score'] for d in dts], kind='mergesort')
        dts = [dts[i] for i in inds]
        if len(dts) > p.maxDets[-1]:
            dts = dts[0:p.maxDets[-1]]
        # if len(gts) == 0 and len(dts) == 0:
        if len(gts) == 0 or len(dts) == 0:
            return []
        ious = np.zeros((len(dts), len(gts)))
        sigmas = p.kpt_oks_sigmas
        vars = (sigmas * 2)**2
        k = len(sigmas)
        # compute oks between each detection and ground truth object
        for j, gt in enumerate(gts):
            # create bounds for ignore regions(double the gt bbox)
            g = np.array(gt['keypoints'])
            xg = g[0::3]; yg = g[1::3]; vg = g[2::3]
            k1 = np.count_nonzero(vg > 0)
            bb = gt['bbox']
            x0 = bb[0] - bb[2]; x1 = bb[0] + bb[2] * 2
            y0 = bb[1] - bb[3]; y1 = bb[1] + bb[3] * 2
            for i, dt in enumerate(dts):
                d = np.array(dt['keypoints'])
                xd = d[0::3]; yd = d[1::3]
                if k1>0:
                    # measure the per-keypoint distance if keypoints visible
                    dx = xd - xg
                    dy = yd - yg
                else:
                    # measure minimum distance to keypoints in (x0,y0) & (x1,y1)
                    z = np.zeros((k))
                    dx = np.max((z, x0-xd),axis=0)+np.max((z, xd-x1),axis=0)
                    dy = np.max((z, y0-yd),axis=0)+np.max((z, yd-y1),axis=0)
                e = (dx**2 + dy**2) / vars / (gt['area']+np.spacing(1)) / 2
                if k1 > 0:
                    e=e[vg > 0]
                ious[i, j] = np.sum(np.exp(-e)) / e.shape[0]
        return ious
import os
import shutil

def list_tif_files(folder):
    """Return a set of .tif files in the given folder."""
    return set(f for f in os.listdir(folder) if f.endswith('.tif'))

def compare_folders(folder1, folder2):
    """Return the .tif files that are in folder1 but not in folder2."""
    files1 = list_tif_files(folder1)
    files2 = list_tif_files(folder2)
    return files1 - files2

def copy_files(files, source_folder, destination_folder):
    """Copy specified files from source_folder to destination_folder."""
    if not os.path.exists(destination_folder):
        os.makedirs(destination_folder)
    for file in files:
        shutil.copy(os.path.join(source_folder, file), os.path.join(destination_folder, file))
        print(f"Copied {file} to {destination_folder}")

def main():
    folder1 = 'path/to/source_folder'  # Replace with the path to the source folder
    folder2 = 'path/to/comparison_folder'  # Replace with the path to the comparison folder
    destination_folder = 'path/to/destination_folder'  # Replace with the path to the destination folder
    
    extra_files = compare_folders(folder1, folder2)
    
    if extra_files:
        print("The following .tif files are in source_folder but not in comparison_folder:")
        for file in extra_files:
            print(file)
        copy_files(extra_files, folder1, destination_folder)
    else:
        print("There are no extra .tif files in source_folder compared to comparison_folder.")

if __name__ == "__main__":
    main()

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值