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


Python PoseTools.randomly_rotate方法代码示例

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


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

示例1: readImages

# 需要导入模块: import PoseTools [as 别名]
# 或者: from PoseTools import randomly_rotate [as 别名]
def readImages(conf,dbType,distort,sess,data):
    train_data,val_data = data
    cur_data = val_data if (dbType=='val')             else train_data
    xs = []; locs = []

    count = 0
    while count < conf.batch_size:
        [curxs,curlocs] = sess.run(cur_data)
        
        # kk = curlocs[conf.eval2_selpt2,:]-curlocs[conf.eval2_selpt1,:]
        # dd = np.sqrt(kk[0]**2 + kk[1]**2 )
#         if dd>150:
#             continue

        if np.ndim(curxs)<3:
            xs.append(curxs[np.newaxis,:,:])
        else:
            xs.append(curxs)
        locs.append(curlocs)
        count = count+1
    
        
    xs = np.array(xs)    
    locs = np.array(locs)
    locs = multiResData.sanitize_locs(locs)
    if distort:
        if conf.horzFlip:
            xs,locs = PoseTools.randomly_flip_lr(xs, locs)
        if conf.vertFlip:
            xs,locs = PoseTools.randomly_flip_ud(xs, locs)
        xs,locs = PoseTools.randomly_rotate(xs, locs, conf)
        xs = PoseTools.randomly_adjust(xs, conf)

    return xs,locs
开发者ID:mkabra,项目名称:poseTF,代码行数:36,代码来源:poseEval2.py

示例2: read_images

# 需要导入模块: import PoseTools [as 别名]
# 或者: from PoseTools import randomly_rotate [as 别名]
    def read_images(self, db_type, distort, sess, shuffle=None):
        conf = self.conf
        cur_data = self.val_data if (db_type == self.DBType.Val)\
            else self.train_data
        xs = []
        locs = []
        info = []

        if shuffle is None:
            shuffle = distort

        # Tfrecords doesn't allow shuffling. Skipping a random
        # number of records
        # as a way to simulate shuffling. very hacky.

        for _ in range(conf.batch_size):
            if shuffle:
                for _ in range(np.random.randint(100)):
                    sess.run(cur_data)
            [cur_xs, cur_locs, cur_info] = sess.run(cur_data)
            xs.append(cur_xs)
            locs.append(cur_locs)
            info.append(cur_info)
        xs = np.array(xs)
        tw = (2*conf.time_window_size + 1)
        b_sz = conf.batch_size * tw
        xs = xs.reshape( (b_sz, ) + xs.shape[2:])
        locs = np.array(locs)
        locs = multiResData.sanitize_locs(locs)

        xs = PoseTools.adjust_contrast(xs, conf)

        # ideally normalize_mean should be here, but misc.imresize in scale_images
        # messes up dtypes. It converts float64 back to uint8.
        # so for now it'll be in update_fd.
        # xs = PoseTools.normalize_mean(xs, conf)
        if distort:
            if conf.horzFlip:
                xs, locs = PoseTools.randomly_flip_lr(xs, locs, tw)
            if conf.vertFlip:
                xs, locs = PoseTools.randomly_flip_ud(xs, locs, tw)
            xs, locs = PoseTools.randomly_rotate(xs, locs, conf, tw)
            xs, locs = PoseTools.randomly_translate(xs, locs, conf, tw)
            xs = PoseTools.randomly_adjust(xs, conf, tw)
        # else:
        #     rows, cols = xs.shape[2:]
        #     for ndx in range(xs.shape[0]):
        #         orig_im = copy.deepcopy(xs[ndx, ...])
        #         ii = copy.deepcopy(orig_im).transpose([1, 2, 0])
        #         mat = np.float32([[1, 0, 0], [0, 1, 0]])
        #         ii = cv2.warpAffine(ii, mat, (cols, rows))
        #         if ii.ndim == 2:
        #             ii = ii[..., np.newaxis]
        #         ii = ii.transpose([2, 0, 1])
        #         xs[ndx, ...] = ii

        self.xs = xs
        self.locs = locs
        self.info = info
开发者ID:mkabra,项目名称:poseTF,代码行数:61,代码来源:PoseCommon.py

示例3: read_images

# 需要导入模块: import PoseTools [as 别名]
# 或者: from PoseTools import randomly_rotate [as 别名]
def read_images(conf, db_type, distort, sess, data):
    train_data, val_data = data
    cur_data = val_data if (db_type == 'val') else train_data
    xs = []
    locs = []
    exp_data = []

    count = 0
    while count < conf.batch_size:
        [cur_xs, cur_locs, cur_exp_data] = sess.run(cur_data)

        # kk = cur_locs[conf.shape_selpt2, :] - cur_locs[conf.shape_selpt1, :]
        # dd = np.sqrt(kk[0] ** 2 + kk[1] ** 2)
        # if dd>150:
        #   continue

        if np.ndim(cur_xs) < 3:
            xs.append(cur_xs[np.newaxis, :, :])
        else:
            cur_xs = np.transpose(cur_xs,[2,0,1])
            xs.append(cur_xs)
        locs.append(cur_locs)
        exp_data.append(cur_exp_data)
        count += 1


    xs = np.array(xs)
    locs = np.array(locs)
    if distort:
        if conf.horzFlip:
            xs, locs = PoseTools.randomly_flip_lr(xs, locs)
        if conf.vertFlip:
            xs, locs = PoseTools.randomly_flip_ud(xs, locs)
        xs, locs = PoseTools.randomly_rotate(xs, locs, conf)
        # xs = PoseTools.randomlyAdjust(xs, conf)

    return xs, locs, exp_data
开发者ID:mkabra,项目名称:poseTF,代码行数:39,代码来源:poseShape.py

示例4: readImages

# 需要导入模块: import PoseTools [as 别名]
# 或者: from PoseTools import randomly_rotate [as 别名]
def readImages(conf,dbType,distort,sess,data):
    train_data,val_data = data
    cur_data = val_data if (dbType=='val')             else train_data
    xs = []; locs = []
    
    for ndx in range(conf.batch_size):
        [curxs,curlocs] = sess.run(cur_data)
        if np.ndim(curxs)<3:
            xs.append(curxs[np.newaxis,:,:])
        else:
            xs.append(curxs)
        locs.append(curlocs)
    xs = np.array(xs)    
    locs = np.array(locs)
    locs = multiResData.sanitize_locs(locs)
    if distort:
        if conf.horzFlip:
            xs,locs = PoseTools.randomly_flip_lr(xs, locs)
        if conf.vertFlip:
            xs,locs = PoseTools.randomly_flip_ud(xs, locs)
        xs,locs = PoseTools.randomly_rotate(xs, locs, conf)
        xs = PoseTools.randomly_adjust(xs, conf)

    return xs,locs
开发者ID:mkabra,项目名称:poseTF,代码行数:26,代码来源:poseEval.py

示例5: range

# 需要导入模块: import PoseTools [as 别名]
# 或者: from PoseTools import randomly_rotate [as 别名]
for n in range(50):
    X_train, in_locs = build_toy_dataset(50)
    X_all.append(X_train)
    l_all.append(in_locs)
#
count = 0
from stephenHeadConfig import conf
conf.trange = 10
conf.rrange = 90
for i in range(n_epoch):
    count = (count+1) % len(X_all)
    X_test, test_locs = build_toy_dataset(50)
    X_train = copy.deepcopy(X_all[count][:,np.newaxis,...])
    in_locs = copy.deepcopy(l_all[count][:,np.newaxis,...])
    X_train, in_locs = PoseTools.randomly_translate(X_train, in_locs, conf)
    X_train, in_locs = PoseTools.randomly_rotate(X_train, in_locs, conf)
    X_train = X_train[:,0,...]
    in_locs = in_locs[:,0,...]

    if myOpt:
        sess.run(optimizer,feed_dict={X_ph:X_train,
                                      y_ph:in_locs,
                                      step:i})
        train_loss[i] = sess.run(inference.loss,
                              feed_dict={X_ph: X_train,
                                        y_ph: in_locs})
        test_loss[i] = sess.run(inference.loss,
                              feed_dict={X_ph: X_test,
                                        y_ph: test_locs})
        if i%50==0:
            pred_weights, pred_means, pred_std = \
开发者ID:mkabra,项目名称:poseTF,代码行数:33,代码来源:testEdward_ims.py


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