コード例 #1
0
def setup(opts):
    with open(opts["checkpoint"], 'rb') as f:
        var_dict = pickle.load(f)

    image_placeholder = tf.placeholder(dtype=tf.float32, shape=[None,227,227,3])
    global_feature_placeholder = network.vfn_rl(image_placeholder, var_dict)

    h_placeholder = tf.placeholder(dtype=tf.float32, shape=[None,1024])
    c_placeholder = tf.placeholder(dtype=tf.float32, shape=[None,1024])
    action, h, c = network.vfn_rl(image_placeholder, var_dict, global_feature=global_feature_placeholder,
                                                           h=h_placeholder, c=c_placeholder)
    sess = tf.Session()

    return {"sess" : sess,
            "action" : action,
            "h" : h,
            "c" : c,
            "img_ph" : image_placeholder,
            "global_f_ph" : global_feature_placeholder,
            "h_ph" : h_placeholder,
            "c_ph" : c_placeholder
                }
コード例 #2
0
import numpy as np
import tensorflow as tf

import skimage.io as io

import network
from actions import command2action, generate_bbox, crop_input

global_dtype = tf.float32

with open('vfn_rl.pkl', 'rb') as f:
    var_dict = pickle.load(f)

image_placeholder = tf.placeholder(dtype=global_dtype,
                                   shape=[None, 227, 227, 3])
global_feature_placeholder = network.vfn_rl(image_placeholder, var_dict)

h_placeholder = tf.placeholder(dtype=global_dtype, shape=[None, 1024])
c_placeholder = tf.placeholder(dtype=global_dtype, shape=[None, 1024])
action, h, c = network.vfn_rl(image_placeholder,
                              var_dict,
                              global_feature=global_feature_placeholder,
                              h=h_placeholder,
                              c=c_placeholder)
sess = tf.Session()


def auto_cropping(origin_image):
    batch_size = len(origin_image)

    terminals = np.zeros(batch_size)