本文整理汇总了Python中dataset.DataSet.add_empty_image方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.add_empty_image方法的具体用法?Python DataSet.add_empty_image怎么用?Python DataSet.add_empty_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.add_empty_image方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import add_empty_image [as 别名]
def parse(path, crawl = False):
if crawl == True:
raise StandardError()
pos_filename = os.path.join(path, "pos.lst")
neg_filename = os.path.join(path, "neg.lst")
pos_dir = os.path.join(path, "pos")
neg_dir = os.path.join(path, "neg")
if not os.path.isfile(pos_filename):
print "%s is not a file."%(pos_filename,)
return None
if not os.path.isfile(neg_filename):
print "%s is not a file."%(neg_filename,)
return None
if not os.path.isdir(pos_dir):
print "%s is not a directory."%(pos_dir,)
return None
if not os.path.isdir(neg_dir):
print "%s is not a directory."%(neg_dir,)
return None
ret = DataSet()
pos = open(pos_filename, "r")
pos_names = [line[line.rfind("/")+1:] for line in pos.read().split()]
pos.close()
for name in pos_names:
filename = os.path.join(pos_dir, name)
ret.add_obj(name, WholeImage(name))
neg = open(neg_filename, "r")
neg_names = [line[line.rfind("/")+1:] for line in neg.read().split()]
neg.close()
for name in neg_names:
ret.add_empty_image(name)
return ret