python类imrotate()的实例源码

flappy_double_dqn.py 文件源码 项目:DeepRL-FlappyBird 作者: hashbangCoder 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def run_pretrained(input_state,model,action_states,gameState):
    print '\n\nLoading pretrained weights onto model...'

    model.load_weights(p.PRETRAINED_PATH)
    epsilon=1
    while True:
        print 'Running pretrained model (no exploration) with weights at ', p.PRETRAINED_PATH 

        nn_out = model.predict(input_state,batch_size=1,verbose=0)
        nn_action = [[0,0]]
        nn_action[0][np.argmax(nn_out)] =1
        action,rand_flag = select_action(nn_action+action_states,prob=[epsilon,(1-epsilon)*1/7,(1-epsilon)*6/7])
        rgbDisplay, reward, tState = gameState.frame_step(action)
        grayDisplay = (np.dot(np.fliplr(imrotate(imresize(rgbDisplay, (80,80), interp='bilinear'), -90))[:,:,:3], [0.299, 0.587, 0.114])).reshape((1,1,80,80))
        output_state = np.append(grayDisplay,input_state[:,:p.HISTORY-1,:,:], axis=1)


#############################################################################################################################################################################
data_utils.py 文件源码 项目:Face-Recognition 作者: aswl01 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def read_images_from_disk(input_queue):
    """Consumes a single filename and label as a ' '-delimited string.
    Args:
      filename_and_label_tensor: A scalar string tensor.
    Returns:
      Two tensors: the decoded image, and the string label.
    """
    label = input_queue[1]
    file_contents = tf.read_file(input_queue[0])
    example = tf.image.decode_png(file_contents, channels=3)
    return example, label


# def random_rotate_image(image):
#     angle = np.random.uniform(low=-10.0, high=10.0)
#     return misc.imrotate(image, angle, 'bicubic')
data_utils.py 文件源码 项目:LSH_Memory 作者: RUSH-LAB 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def crawl_directory(directory, augment_with_rotations=False, first_label=0):
  """Crawls data directory and returns stuff."""
  label_idx = first_label
  images = []
  labels = []
  info = []

  # traverse root directory
  for root, _, files in os.walk(directory):
    logging.info('Reading files from %s', root)

    for file_name in files:
      full_file_name = os.path.join(root, file_name)
      img = imread(full_file_name, flatten=True)
      for idx, angle in enumerate([0, 90, 180, 270]):
        if not augment_with_rotations and idx > 0:
          break

        images.append(imrotate(img, angle))
        labels.append(label_idx + idx)
        info.append(full_file_name)

    if len(files) == 20:
      label_idx += 4 if augment_with_rotations else 1
  return images, labels, info
fashion_number.py 文件源码 项目:LifelongVAE 作者: jramapuram 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _rotate_batch(batch, angle):
        return np.vstack([rotate(x_i.reshape(28, 28), angle).reshape([-1, 28*28])
                          for x_i in batch])
facenet.py 文件源码 项目:facerecognition 作者: guoxiaolu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
load_images.py 文件源码 项目:dl-classification 作者: matthieuo 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    # rotate image for data augmentation
    angle = np.random.uniform(low=-20.0, high=20.0)
    return misc.imrotate(image, angle, 'bicubic')
setup_ifruitfly.py 文件源码 项目:iFruitFly 作者: AdnanMuhib 项目源码 文件源码 阅读 92 收藏 0 点赞 0 评论 0
def plotCluster( _x, labels, core_samples_mask, n_clusters_, f):
    unique_labels = set(labels)
    colors = plt.cm.Spectral(np.linspace(0, 1, len(unique_labels)))

    for k, col in zip(unique_labels, colors):
        if k == -1:
            # Black used for noise.
            col = 'k'

        class_member_mask = (labels == k)

        xy = _x[class_member_mask & ~core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=6)

        xy = _x[class_member_mask & core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=14)

    #plt.title('Estimated number of clusters: %d' % n_clusters_)
    #plt.axis('off')

    #misc.imrotate(ax, 270)
    index = f
    print f
    plt.axis('off')
    plt.savefig(f)
    image_rotate(f)
    plt.close()
    #plt.show()
    return
iFruitFly_v2.0.py 文件源码 项目:iFruitFly 作者: AdnanMuhib 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def plotCluster( _x, labels, core_samples_mask, n_clusters_, f):
    unique_labels = set(labels)
    colors = plt.cm.Spectral(np.linspace(0, 1, len(unique_labels)))

    for k, col in zip(unique_labels, colors):
        if k == -1:
            # Black used for noise.
            col = 'k'

        class_member_mask = (labels == k)

        xy = _x[class_member_mask & ~core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=6)

        xy = _x[class_member_mask & core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=14)

    #plt.title('Estimated number of clusters: %d' % n_clusters_)
    #plt.axis('off')

    #misc.imrotate(ax, 270)
    index = f
    print f
    plt.axis('off')
    plt.savefig(f)
    image_rotate(f)
    plt.close()
    #plt.show()
    return
iFruitFly_Testing_weka.py 文件源码 项目:iFruitFly 作者: AdnanMuhib 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plotCluster(_x, labels, core_samples_mask, n_clusters_, f):
    unique_labels = set(labels)
    colors = plt.cm.Spectral(np.linspace(0, 1, len(unique_labels)))

    for k, col in zip(unique_labels, colors):
        if k == -1:
            # Black used for noise.
            col = 'k'

        class_member_mask = (labels == k)

        xy = _x[class_member_mask & ~core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=6)

        xy = _x[class_member_mask & core_samples_mask]
        ax = plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                    markeredgecolor='k', markersize=14)

    #plt.title('Estimated number of clusters: %d' % n_clusters_)
    #plt.axis('off')

    #misc.imrotate(ax, 270)
    index = f
    print f
    plt.axis('off')
    plt.savefig(f)
    image_rotate(f)
    plt.close()
    #plt.show()
    return

##############################################################################################
# Rotating the image, as output was comming tilted
facenet.py 文件源码 项目:faceNet_RealTime 作者: jack55436001 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
test_invariance_on_lfw.py 文件源码 项目:faceNet_RealTime 作者: jack55436001 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def rotate_images(images, angle, image_size):
    images_list = [None] * images.shape[0]
    for i in range(images.shape[0]):
        images_list[i] = misc.imrotate(images[i,:,:,:], angle)
    images_rot = np.stack(images_list,axis=0)
    sz1 = images_rot.shape[1]/2
    sz2 = image_size/2
    images_crop = images_rot[:,(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]
    return images_crop
facenet.py 文件源码 项目:icyface_api 作者: bupticybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
keras_dqn.py 文件源码 项目:DeepRL-FlappyBird 作者: hashbangCoder 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def run_pretrained(input_state,model,action_states,gameState):
    print '\n\nLoading pretrained weights onto model...'
    model.load_weights(p.PRETRAINED_PATH)
    epsilon=1
    while True:
        print 'Running pretrained model (no exploration) with weights at ', p.PRETRAINED_PATH 

        nn_out = model.predict(input_state,batch_size=1,verbose=0)
        nn_action = [[0,1]] if np.argmax(nn_out) else [[1,0]]
        action,rand_flag = select_action(nn_action+action_states,prob=[epsilon,(1-epsilon)/2,(1-epsilon)/2])
        rgbDisplay, reward, tState = gameState.frame_step(action)
        #grayDisplay = (np.dot(imresize(rgbDisplay, (80,80), interp='bilinear')[:,:,:3], [0.299, 0.587, 0.114])).reshape((1,1,80,80))
        grayDisplay = (np.dot(np.fliplr(imrotate(imresize(rgbDisplay, (80,80), interp='bilinear'), -90))[:,:,:3], [0.299, 0.587, 0.114])).reshape((1,1,80,80))
        output_state = np.append(input_state[:,1:,:,:], grayDisplay,axis=1)



#############################################################################################################################################################################
rotation.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def rotate_frame(frame, angle):

    # Perform the image rotation and update the fits header
    #frame[np.isnan(frame)] = 0.0
    new_frame = ndimage.interpolation.rotate(frame, angle, reshape=False, order=1, mode='constant', cval=float('nan'))

    #new_frame = misc.imrotate(frame, angle, interp="bilinear")

    # Return the rotated frame
    return new_frame
rotation.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def rotate_frame(frame, angle):

    # Perform the image rotation and update the fits header
    #frame[np.isnan(frame)] = 0.0
    new_frame = ndimage.interpolation.rotate(frame, angle, reshape=False, order=1, mode='constant', cval=float('nan'))

    #new_frame = misc.imrotate(frame, angle, interp="bilinear")

    # Return the rotated frame
    return new_frame
facenet.py 文件源码 项目:facenet 作者: davidsandberg 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
test_invariance_on_lfw.py 文件源码 项目:facenet 作者: davidsandberg 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rotate_images(images, angle, image_size):
    images_list = [None] * images.shape[0]
    for i in range(images.shape[0]):
        images_list[i] = misc.imrotate(images[i,:,:,:], angle)
    images_rot = np.stack(images_list,axis=0)
    sz1 = images_rot.shape[1]/2
    sz2 = image_size/2
    images_crop = images_rot[:,(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]
    return images_crop
image_utils.py 文件源码 项目:Face-Recognition 作者: aswl01 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
facenet.py 文件源码 项目:real-time-face-recognition 作者: iwantooxxoox 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
mnist_number.py 文件源码 项目:LifelongVAE 作者: jramapuram 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _rotate_batch(batch, angle):
        return np.vstack([rotate(x_i.reshape(28, 28), angle).reshape([-1, 28*28])
                          for x_i in batch]) / 255.


问题


面经


文章

微信
公众号

扫码关注公众号