23 #ifndef __IMAGE_NET_H__ 24 #define __IMAGE_NET_H__ 34 #define IMAGENET_DEFAULT_INPUT "data" 40 #define IMAGENET_DEFAULT_OUTPUT "prob" 47 #define IMAGENET_USAGE_STRING "imageNet arguments: \n" \ 48 " --network NETWORK pre-trained model to load, one of the following:\n" \ 50 " * googlenet (default)\n" \ 59 " --model MODEL path to custom model to load (.caffemodel, .uff, or .onnx)\n" \ 60 " --prototxt PROTOTXT path to custom prototxt to load (for .caffemodel only)\n" \ 61 " --labels LABELS path to text file containing the labels for each class\n" \ 62 " --input_blob INPUT name of the input layer (default is '" IMAGENET_DEFAULT_INPUT "')\n" \ 63 " --output_blob OUTPUT name of the output layer (default is '" IMAGENET_DEFAULT_OUTPUT "')\n" \ 64 " --batch_size BATCH maximum batch size (default is 1)\n" 121 static imageNet*
Create(
const char* prototxt_path,
const char* model_path,
122 const char* mean_binary,
const char* class_labels,
153 int Classify(
float* rgba, uint32_t width, uint32_t height,
float* confidence=NULL );
161 int Classify(
float* confidence=NULL );
168 bool PreProcess(
float* rgba, uint32_t width, uint32_t height );
210 bool init(
const char* prototxt_path,
const char* model_path,
const char* mean_binary,
const char* class_path,
const char* input,
const char* output, uint32_t maxBatchSize,
precisionType precision,
deviceType device,
bool allowGPUFallback );
precisionType
Enumeration for indicating the desired precision that the network should run in, if available in hard...
Definition: tensorNet.h:79
const char * GetClassPath() const
Retrieve the path to the file containing the class descriptions.
Definition: imageNet.h:194
GPU (if multiple GPUs are present, a specific GPU can be selected with cudaSetDevice() ...
Definition: tensorNet.h:108
const char * GetClassSynset(uint32_t index) const
Retrieve the class synset category of a particular class.
Definition: imageNet.h:189
#define IMAGENET_DEFAULT_INPUT
Name of default input blob for imageNet model.
Definition: imageNet.h:34
uint32_t mCustomClasses
Definition: imageNet.h:213
bool init(NetworkType networkType, uint32_t maxBatchSize, precisionType precision, deviceType device, bool allowGPUFallback)
GoogleNet trained 1000-class ILSVRC12.
Definition: imageNet.h:81
uint32_t GetNumClasses() const
Retrieve the number of image recognition classes (typically 1000)
Definition: imageNet.h:179
const char * GetClassDesc(uint32_t index) const
Retrieve the description of a particular class.
Definition: imageNet.h:184
bool loadClassInfo(const char *filename)
deviceType
Enumeration for indicating the desired device that the network should run on, if available in hardwar...
Definition: tensorNet.h:106
#define IMAGENET_DEFAULT_OUTPUT
Name of default output confidence values for imageNet model.
Definition: imageNet.h:40
The fastest detected precision should be use (i.e.
Definition: tensorNet.h:82
static const char * NetworkTypeToStr(NetworkType network)
Convert a NetworkType enum to a string.
Custom model provided by the user.
Definition: imageNet.h:79
const char * GetNetworkName() const
Retrieve a string describing the network name.
Definition: imageNet.h:204
VGG-16 trained on 1000-class ILSVRC14.
Definition: imageNet.h:87
bool PreProcess(float *rgba, uint32_t width, uint32_t height)
Perform pre-processing on the image to apply mean-value subtraction and to organize the data into NCH...
ResNet-50 trained on 1000-class ILSVRC15.
Definition: imageNet.h:84
bool Process()
Process the network, without determining the classification argmax.
NetworkType
Network choice enumeration.
Definition: imageNet.h:77
NetworkType mNetworkType
Definition: imageNet.h:220
ResNet-50 trained on 1000-class ILSVRC15.
Definition: imageNet.h:86
Image recognition with classification networks, using TensorRT.
Definition: imageNet.h:71
int Classify(float *rgba, uint32_t width, uint32_t height, float *confidence=NULL)
Determine the maximum likelihood image class.
#define DEFAULT_MAX_BATCH_SIZE
Default maximum batch size.
Definition: tensorNet.h:65
Abstract class for loading a tensor network with TensorRT.
Definition: tensorNet.h:188
std::vector< std::string > mClassSynset
Definition: imageNet.h:216
ResNet-101 trained on 1000-class ILSVRC15.
Definition: imageNet.h:85
std::vector< std::string > mClassDesc
Definition: imageNet.h:217
AlexNet trained on 1000-class ILSVRC12.
Definition: imageNet.h:80
GoogleNet trained on 12-class subset of ImageNet ILSVRC12 from the tutorial.
Definition: imageNet.h:82
std::string mClassPath
Definition: imageNet.h:219
static NetworkType NetworkTypeFromStr(const char *model_name)
Parse a string to one of the built-in pretrained models.
#define IMAGENET_USAGE_STRING
Command-line options able to be passed to imageNet::Create()
Definition: imageNet.h:47
ResNet-18 trained on 1000-class ILSVRC15.
Definition: imageNet.h:83
Inception-v4 trained on 1000-class ILSVRC12.
Definition: imageNet.h:89
uint32_t mOutputClasses
Definition: imageNet.h:214
NetworkType GetNetworkType() const
Retrieve the network type (alexnet or googlenet)
Definition: imageNet.h:199
virtual ~imageNet()
Destroy.
VGG-19 trained on 1000-class ILSVRC14.
Definition: imageNet.h:88
static const char * Usage()
Usage string for command line arguments to Create()
Definition: imageNet.h:137
static imageNet * Create(NetworkType networkType=GOOGLENET, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
Load a new network instance.