Python net 模块,py() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用net.py()

项目:tinyYOLOv2    作者:simo23    | 项目源码 | 文件源码
def inference(sess,preprocessed_image):

  # Forward pass of the preprocessed image into the network defined in the net.py file
  predictions = sess.run(net.o9,feed_dict={net.x:preprocessed_image})

  return predictions


### MAIN ##############################################################################################################
项目:tinyYOLOv2    作者:simo23    | 项目源码 | 文件源码
def inference(sess,preprocessed_image):

  # Forward pass of the preprocessed image into the network defined in the net.py file
  predictions = sess.run(net.o9,feed_dict={net.x:preprocessed_image})

  return predictions


### MAIN ##############################################################################################################
项目:tinyYOLOv2    作者:simo23    | 项目源码 | 文件源码
def main(_):

    # Definition of the paths
    weights_path = './tiny-yolo-voc.weights'
    input_img_path = './horses.jpg'
    output_image_path = './output.jpg'

    # If you do not have the checkpoint yet keep it like this! When you will run test.py for the first time it will be created automatically
    ckpt_folder_path = './ckpt/'

    # Definition of the parameters
    input_height = 416
    input_width = 416
    score_threshold = 0.3
    iou_threshold = 0.3

    # Definition of the session
    sess = tf.InteractiveSession()
    tf.global_variables_initializer().run()

    # Check for an existing checkpoint and load the weights (if it exists) or do it from binary file
    print('Looking for a checkpoint...')
    saver = tf.train.Saver()
    _ = weights_loader.load(sess,weights_path,ckpt_folder_path,saver)

    # Preprocess the input image
    print('Preprocessing...')
    preprocessed_image = preprocessing(input_img_path,input_height,input_width)

    # Compute the predictions on the input image
    print('Computing predictions...')
    predictions = inference(sess,preprocessed_image)

    # Postprocess the predictions and save the output image
    print('Postprocessing...')
    output_image = postprocessing(predictions,input_img_path,score_threshold,iou_threshold,input_height,input_width)
    cv2.imwrite(output_image_path,output_image)
项目:Emotion_Voice_Recognition_Chainer-    作者:SnowMasaya    | 项目源码 | 文件源码
def __set_cpu_or_gpu(self):
        # Prepare multi-layer perceptron model, defined in net.py
        if self.gpu >= 0:
            cuda.get_device(self.gpu).use()
            self.model.to_gpu()
        self.xp = np if self.gpu < 0 else cuda.cupy
项目:Emotion_Voice_Recognition_Chainer-    作者:SnowMasaya    | 项目源码 | 文件源码
def __set_cpu_or_gpu(self):
        # Prepare multi-layer perceptron model, defined in net.py
        if self.gpu >= 0:
            cuda.get_device(self.gpu).use()
            self.model.to_gpu()
        self.xp = np if self.gpu < 0 else cuda.cupy