本文整理汇总了Python中imutils.paths.list_images方法的典型用法代码示例。如果您正苦于以下问题:Python paths.list_images方法的具体用法?Python paths.list_images怎么用?Python paths.list_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imutils.paths
的用法示例。
在下文中一共展示了paths.list_images方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: animate
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def animate(src, gif_name, reshape=None, fps=25):
if not isinstance(src, list):
if os.path.isdir(src):
src = list(paths.list_images(src))
for idx, image in enumerate(src):
src[idx] = cv2.imread(image)
if reshape:
for idx, image in enumerate(src):
src[idx] = cv2.resize(image, reshape)
for idx, image in enumerate(src):
src[idx] = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
src = np.array(src)
imageio.mimsave(gif_name, src, fps=fps)
示例2: generateTrainingImages2
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def generateTrainingImages2():
currentNumOfData = len(sorted(list(paths.list_images("generatedData/"))))
print("[INFO] Type anything and press enter to begin...")
input()
startTime = time.time()
i = 0
while (True):
if (time.time()-startTime > 1):
print("--------Captured Data--------")
im = ImageGrab.grab()
im.save("generatedData/input" + str(i+1+currentNumOfData) + ".png")
i += 1
startTime = time.time()
示例3: loadTrainingImages1
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def loadTrainingImages1():
x_train = np.zeros((96, 32, 32, 3))
imagePaths = sorted(list(paths.list_images("trainData/")))
for i in range(len(imagePaths)):
img = cv2.imread(imagePaths[i])
img = cv2.resize(img, (32, 32))
img = img_to_array(img)
x_train[i] = img
y_train = np.zeros(len(x_train))
for i in range(len(y_train)):
y_train[i] = i
return x_train, y_train
示例4: modelPredicts1
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def modelPredicts1():
loadTestingImages1()
imageNames = sorted(list(paths.list_images("trainData/")))
for i in range(len(imageNames)):
imageNames[i] = imageNames[i][imageNames[i].find('/')+1:-4]
print("[INFO] loading network...")
model = load_model("testNet.model")
for i in range(8):
img = cv2.imread("testData/output" + str(i+1) + ".png")
orig = img.copy()
img = cv2.resize(img, (32, 32))
img = img.astype("float")/255.0
img = img_to_array(img)
img = np.expand_dims(img, axis=0)
output = model.predict(img)[0]
label = output.argmax()
print(output)
print(label)
label = "{}: {:.2f}%".format(imageNames[label], output[label] * 100)
print(label)
orig = cv2.resize(orig, (400, 400))
cv2.putText(orig, label, (10, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
cv2.imshow("Output", orig)
cv2.waitKey(0)
示例5: labelTrainingData2
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def labelTrainingData2():
imagePaths = sorted(list(paths.list_images("generatedData/")))
currentNumOfLabeledData = len(sorted(list(paths.list_images("trainData2/"))))
root = tkinter.Tk()
myFrame = tkinter.LabelFrame(root, text="Unlabeled Data", labelanchor="n")
myFrame.pack()
labeledCount = 0
for i in range(len(imagePaths)):
img = Image.open(imagePaths[i])
img.thumbnail((1500, 1500), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
panel = tkinter.Label(myFrame, image = img)
panel.image = img
panel.grid(row=0, column=0)
root.update()
label = input()
if (label != 'e'):
copyfile(imagePaths[i], "trainData2/"+label+"input"+str(labeledCount+currentNumOfLabeledData)+".png")
labeledCount += 1
os.remove(imagePaths[i])
示例6: createCardCollection
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def createCardCollection():
imageNames = sorted(list(paths.list_images("trainData/")))
for i in range(len(imageNames)):
imageNames[i] = imageNames[i][imageNames[i].find('/')+1:-4]
cardCollection = dict()
for x in imageNames:
print(x)
cardCollection[x] = int(input())
with open('cardCollection.txt', 'w') as f:
for key, value in cardCollection.items():
f.write('%s:%s\n' % (key, value))
示例7: __init__
# 需要导入模块: from imutils import paths [as 别名]
# 或者: from imutils.paths import list_images [as 别名]
def __init__(self, img_dir, imgSize, lpr_max_len, PreprocFun=None):
self.img_dir = img_dir
self.img_paths = []
for i in range(len(img_dir)):
self.img_paths += [el for el in paths.list_images(img_dir[i])]
random.shuffle(self.img_paths)
self.img_size = imgSize
self.lpr_max_len = lpr_max_len
if PreprocFun is not None:
self.PreprocFun = PreprocFun
else:
self.PreprocFun = self.transform