本文整理汇总了Python中tinydb.TinyDB.groups方法的典型用法代码示例。如果您正苦于以下问题:Python TinyDB.groups方法的具体用法?Python TinyDB.groups怎么用?Python TinyDB.groups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinydb.TinyDB
的用法示例。
在下文中一共展示了TinyDB.groups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Exception
# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import groups [as 别名]
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')
if args.filter == None:
qi = np.int32(qi)
elif args.filter == 'raw,sobel':
qi = np.int32(do_filter(qi, args.filter))
else:
print >> sys.stderr, "unknown filter"
sys.exit(1)
if args.filterout != None:
ip.write_rgb_image(args.filterout, ip.unflatten_rgb_image(np.uint8(qi), d, d))
# -----------------------------
def compute_distance(datachunks):
return [np.linalg.norm(qi - do_filter(np.fromstring(c, np.uint8), args.filter)) for c in datachunks]
c = 0
for result in process(db.groups(400), compute_distance):
for k in result:
print k, c
c += 1
示例2: TinyDB
# 需要导入模块: from tinydb import TinyDB [as 别名]
# 或者: from tinydb.TinyDB import groups [as 别名]
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):
k = np.matrix([np.fromstring(i, np.uint8) for i in m]) - mean
k = k / std
return k.transpose() * k
jobs = process(tdb.groups(args.rows), compute)
m = reduce(lambda acc, x: acc + x, jobs, np.zeros((DIM, DIM), np.float64))
print >> sys.stderr, "processed rows:", tdb.count()
sio.savemat(args.o, {"c": m, "n": tdb.count()}, do_compression = True)