我正在尝试编写一个程序来抓取图像,以创建用于神经网络的数据集,但是我遇到了一些问题
代码如下:
from imutils import paths
import argparse
import requests
import cv2
import os
ap = argparse.ArgumentParser()
ap.add_argument("-u", "--C:/Users/artus/datasets/urls.txt",
required=False, help="path containing URLs")
ap.add_argument("-o", "--C:/Users/artus/datasets/ShoesImage",
required=False, help="folder for downloaded images")
args = vars(ap.parse_args())
# grab the list of URLs from the input file, then initialize the
# total number of images downloaded thus far
rows = open(args["urls"]).read().strip().split("\n")
total = 0
在执行时,它应该从urls.txt文件中指定的urls下载所有图像,但是我得到了这个错误:
Traceback (most recent call last):
File "C:/Users/artus/untitled5/imagescraping.py", line 16, in <module>
rows = open(args["urls"]).read().strip().split("\n")
KeyError: 'urls'
https://stackoverflow.com/questions/56745387
复制相似问题