NVIDIA DLI 最终评估

Posted

技术标签:

【中文标题】NVIDIA DLI 最终评估【英文标题】:NVIDIA DLI final assessment 【发布时间】:2020-03-28 07:06:09 【问题描述】:

我正在学习智能视频分析和计算机视觉课程中的 NVIDIA DLI 深度学习。 我在做最终评估时遇到问题。这是帮助您了解我一直在做的事情的链接。( https://medium.com/altotech/part-6-final-assessment-deep-learning-in-intelligence-video-analytics-and-computer-vision -workshop-318bb0f5458e)

我正在按照该文章的指南修复一些错误。 这是代码:

import caffe
import cv2
import sys
def deploy(img_path):
    caffe.set_mode_gpu()
    MODEL_JOB_DIR = '/dli/data/digits/20191203-135349-c1c3'
    ARCHITECTURE = MODEL_JOB_DIR + '/' + 'deploy.prototxt'
    WEIGHTS = MODEL_JOB_DIR + '/' + 'snapshot_iter_540.caffemodel'
    # Initialize the Caffe model using the model trained in DIGITS. Which two files constitute your trained model?
    net = caffe.Classifier(ARCHITECTURE, WEIGHTS,
                           channel_swap=(2,1,0),
                           raw_scale=255,
                           image_dims=(256, 256))

    # Create an input that the network expects. This is different for each project, so don't worry about the exact steps, but find the dataset job directory to show you know that whatever preprocessing is done during training must also be done during deployment.
    input_image= caffe.io.load_image(img_path)
    input_image = cv2.resize(input_image, (256,256))
    DATA_JOB_DIR = '/dli/data/digits/20191203-135017-353f'
    mean_image = caffe.io.load_image(DATA_JOB_DIR + '/mean.jpg')
    input_image = input_image-mean_image
# Make prediction. What is the function and the input to the function needed to make a prediction?
    prediction = net.predict([input_image])
# Create an output that is useful to a user. What is the condition that should return "whale" vs. "not whale"?
    if prediction.argmax() == 0: 
        return "whale"
    else:
        return "not whale"

!python submission.py '/dli/data/whale/data/train/face/w_1.jpg' 

错误消息是:

文件“submission.py”,第 22 行 prediction = net.##REPLACE 用返回网络输出的函数##([##用函数的输入替换##])

                                                                                                                                  ^

SyntaxError: 无效语法

我一直在将“input_img”替换为“output_img”

如果有人知道如何处理这个答案请告诉我

【问题讨论】:

【参考方案1】:

mean_image = caffe.io.load_image('/dli/data/digits/20180707-144641-812f/mean.jpg')

input_image = input_image-mean_image


# Make prediction. What is the function and the input to the function needed to make a 

预测?

prediction = net.predict([input_image])

【讨论】:

以上是关于NVIDIA DLI 最终评估的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu 14.04 如何安装nvidia显卡驱动

安装使用NVIDIA-Docker-- 可使用GPU的Docker容器

如何在 nvidia/cuda 基础 docker 中仅安装 nvcc?

nvidia tesla k40

NVIDIA|深度学习性能架构组-TensorRT

为 Python 3.8.5 安装 NVIDIA Apex 并与 PyTorch 1.9 兼容