当前位置: 首页>>代码示例>>Python>>正文


Python TinyDB.arg_parser方法代码示例

本文整理汇总了Python中tinydb.TinyDB.arg_parser方法的典型用法代码示例。如果您正苦于以下问题:Python TinyDB.arg_parser方法的具体用法?Python TinyDB.arg_parser怎么用?Python TinyDB.arg_parser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tinydb.TinyDB的用法示例。


在下文中一共展示了TinyDB.arg_parser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TinyDB

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
#!/usr/bin/env python

import cv2
import numpy as np

from tinydb import TinyDB

tdb = TinyDB(parse_args = None)
tdb.arg_parser().add_argument("-o", required = True)
tdb.arg_parser().add_argument("-i", type = int, required = True)
args = tdb.parse_args()

x = np.fromstring(tdb.at(args.i), np.uint8).reshape((32, 32, 3), order = 'F')
r = x[:, :, 0]
g = x[:, :, 1]
b = x[:, :, 2]
x[:, :, 0], x[:, :, 2] = b.copy(), r.copy()

cv2.imwrite(args.o, x)
开发者ID:daniel-e,项目名称:tinyimages,代码行数:21,代码来源:db2img.py

示例2: len

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
	if len(images) == 0:
		return m
	i = images[0]
	h = i.shape[0]
	w = i.shape[1]
	emptyrows = np.zeros((h, w * cols, i.shape[2]), np.uint8)
	if m == None:
		return mosaic(images, cols, emptyrows, col)
	elif col == cols:
		return mosaic(images, cols, np.append(m, emptyrows, axis = 0), 0)
	else:
		m[-h:, col*w:col*w+w, :] = i
		return mosaic(images[1:], cols, m, col + 1)

tdb = TinyDB(dimensions = WIDTH * HEIGHT * CHANNELS, parse_args = False)
p = tdb.arg_parser()
p.add_argument("-o", required = True)
p.add_argument("-k", type = int, default = 100)
p.add_argument("-c", type = int, default = 10)
p.add_argument("--seed", type = int, default = -1)
p.add_argument("idx", type = int, nargs = '*')
args = tdb.parse_args()

# number of images
n = tdb.rows()

# if no index is given select indexes at random
idx = []
if len(args.idx) > 0:
	idx = args.idx
else:
开发者ID:daniel-e,项目名称:tinyimages,代码行数:33,代码来源:mosaic.py

示例3: TinyDB

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
#!/usr/bin/env python

from tinydb import TinyDB
import numpy as np

tdb = TinyDB(parse_args = False)
tdb.arg_parser().add_argument("-o", required = True)
args = tdb.parse_args()

z = np.zeros(tdb.dim(), np.int64)
for i in tdb.chunks():
	z += np.fromstring(i, np.uint8)
z = np.float64(z) / tdb.count()

open(args.o, "w").write(" ".join([repr(i) for i in z.flatten()]))
开发者ID:daniel-e,项目名称:tinyimages,代码行数:17,代码来源:mean.py

示例4: TinyDB

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
#!/usr/bin/env python

from tinydb import TinyDB
from parallel import process

import numpy as np
import scipy.io as sio


db = TinyDB(parse_args = False)
# add additional parameters
db.arg_parser().add_argument("-k", type = int, required = True)
db.arg_parser().add_argument("--rows", type = int, default = 20000)
db.arg_parser().add_argument("-o", required = True)
db.arg_parser().add_argument("--umatrix", required = True)
args = db.parse_args()

# load umatrix

def compute(data):
	

with open(args.o, "w") as f:
	for r in process(db.groups(args.rows), compute):
		f.write(r)

x = rand(5000, 3);
y = (x(:,1) > 0.2) .* (x(:,1) < 0.8) .* (x(:,2) > 0.2) .* (x(:,2) < 0.8) .* (x(:,3) > 0.2) .* (x(:,3) < 0.8);
z = x(y == 0, :)
plot3(z(:,1), z(:,2),z(:,3), 'x', 'color', 'r');
开发者ID:daniel-e,项目名称:tinyimages,代码行数:32,代码来源:applypca.py

示例5: TinyDB

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
#!/usr/bin/env python

from tinydb import TinyDB
from parallel import process
import imageprocessing as ip

import cv2, sys
import numpy as np

db = TinyDB(parse_args = False)
db.arg_parser().add_argument('--image', required = True)
db.arg_parser().add_argument('--filter', default = None)
db.arg_parser().add_argument('--filterout', default = None)
args = db.parse_args()

d = 32

qi = ip.flatten_rgb_image(ip.read_rgb_image(args.image))

# ---------- filter -----------

def do_filter(arr, filt):
	if filt == None:
		return arr
	elif filt == 'raw,sobel':
		i = ip.unflatten_rgb_image(arr, d, d)
		i = ip.sobel_scipy(i)
		i = ip.gray_as_rgb(i)
		return ip.flatten_rgb_image(i)
	raise Exception('unknown filter')
开发者ID:daniel-e,项目名称:tinyimages,代码行数:32,代码来源:knn.py

示例6: TinyDB

# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import arg_parser [as 别名]
#!/usr/bin/env python

import sys
import numpy as np
import scipy.io as sio

from tinydb import TinyDB
from parallel import process

WIDTH = 32
HEIGHT = 32
CHANNELS = 3
DIM = WIDTH * HEIGHT * CHANNELS

tdb = TinyDB(dimensions = DIM, parse_args = None)
tdb.arg_parser().add_argument("--mean", required = True)
tdb.arg_parser().add_argument("--std", required = True)
tdb.arg_parser().add_argument("--rows", type = int, default = 20000)
tdb.arg_parser().add_argument("-o", required = True)
args = tdb.parse_args()

# read the mean for each dimension
mean = np.array([float(i) for i in open(args.mean).readline().strip().split(" ")], np.float64)
assert(len(mean) == DIM)

# read the standard deviation for each dimension
std = np.array([float(i) for i in open(args.std).readline().strip().split(" ")], np.float64)
assert(len(std) == DIM)


def compute(m):
开发者ID:daniel-e,项目名称:tinyimages,代码行数:33,代码来源:cov.py


注:本文中的tinydb.TinyDB.arg_parser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。