coco数据集train2014图片缺失问题

import json
import os
import subprocess

with open('/home/yunchuan/L2D-master/data/coco2014/train_anno.json', 'rb') as f:
    images_info = json.load(f)

# 指定包含图像的目录路径
image_directory = '/home/yunchuan/L2D-master/data/coco2014/train2014/'

# 遍历字典,检查每个文件是否存在
missing_files = []
for image in images_info:
    file_path = os.path.join(image_directory, image['file_name'])
    if not os.path.exists(file_path):
        missing_files.append(image['file_name'])

# 输出缺失的文件名
print("缺失的文件有:")
for file_name in missing_files:
    print(file_name)

# 指定下载文件的目录
download_directory = '/home/yunchuan/L2D-master/data/coco2014/lose_images'
os.makedirs(download_directory, exist_ok=True)

# COCO数据集的基础URL
base_url = 'http://images.cocodataset.org/train2014/'

# 遍历缺失文件并下载
for file_name in missing_files:
    # 构建完整的下载URL
    download_url = f'{base_url}{file_name}'

    # 构建wget命令
    wget_command = f'wget -P {download_directory} {download_url}'

    # 执行wget命令
    subprocess.run(wget_command, shell=True)

# 输出已完成下载的信息
print("下载完成")
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值