DaoAI World C# SDK INDUSTRIAL 2024.8.0
Loading...
Searching...
No Matches
model.h
Go to the documentation of this file.
1#pragma once
2#include "managed_object.h"
3#include "common.h"
4#include "prediction.h"
5#include "../daoai_dl_sdk/include/export/model.h"
6#include "../daoai_dl_sdk/include/export/component_memory.h"
7
8using namespace System;
9using namespace System::Collections::Generic;
10namespace DaoAI
11{
12 namespace DeepLearningCLI
13 {
14 public ref class Application
15 {
16 public:
17 // Initialize DaoAI Deep Learning SDK
18 static void initialize(bool use_shared_memory, int resevered_vram_size);
19
24 static int getNumCUDADevices();
25 };
26
27 public enum class ModelType : int
28 {
29 Object_Detection = DaoAI::DeepLearning::ModelType::Object_Detection,
30 Instance_Segmentation = DaoAI::DeepLearning::ModelType::Instance_Segmentation,
31 Keypoint_Detection = DaoAI::DeepLearning::ModelType::Keypoint_Detection,
32 Classification = DaoAI::DeepLearning::ModelType::Classification,
33 OCR = DaoAI::DeepLearning::ModelType::OCR,
34 Supervised_Defect_Segmentation = DaoAI::DeepLearning::ModelType::Supervised_Defect_Segmentation,
35 Auto_Segmentation = DaoAI::DeepLearning::ModelType::Auto_Segmentation,
36#ifdef INDUSTRIAL
37 Presence_Checking = DaoAI::DeepLearning::ModelType::Presence_Checking,
38 Positioning = DaoAI::DeepLearning::ModelType::Positioning,
39 Unsupervised_Defect_Segmentation = DaoAI::DeepLearning::ModelType::Unsupervised_Defect_Segmentation
40#endif // INDUSTRIAL
41 };
42
43 public enum class DeviceType {
44 CPU = DaoAI::DeepLearning::DeviceType::CPU,
45 GPU = DaoAI::DeepLearning::DeviceType::GPU
46 };
47
48 public enum class DetectionLevel {
49 PIXEL = DaoAI::DeepLearning::DetectionLevel::PIXEL,
50 IMAGE = DaoAI::DeepLearning::DetectionLevel::IMAGE
51 };
52
53
54 public ref class ModelInfo
55 {
56 public:
59 cli::array<String^>^ class_labels;
60 cli::array<int>^ num_keypoints;
61 cli::array<String^>^ keypoint_labels;
62 };
63
64 namespace Vision
65 {
66 public ref class ObjectDetection : public ManagedObject<DaoAI::DeepLearning::Vision::ObjectDetection>
67 {
68 public:
69
76 ObjectDetection(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
77
84 ObjectDetection(String^ model_file_path, DeviceType device, int device_idx);
85
86
93
95
100 void setBatchSize(int batch_size);
101
107
112 void setConfidenceThreshold(float threshold);
113
119
124 void setIOUThreshold(float threshold);
125
131 };
132
133 public ref class InstanceSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::InstanceSegmentation>
134 {
135 public:
136
143 InstanceSegmentation(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
144
151 InstanceSegmentation(String^ model_file_path, DeviceType device, int device_idx);
152
159
161
166 void setBatchSize(int batch_size);
167
173
178 void setConfidenceThreshold(float threshold);
179
185
190 void setIOUThreshold(float threshold);
191
197 };
198
199 public ref class KeypointDetection : public ManagedObject<DaoAI::DeepLearning::Vision::KeypointDetection>
200 {
201 public:
202
209 KeypointDetection(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
210
217 KeypointDetection(String^ model_file_path, DeviceType device, int device_idx);
218
225
227
232 void setBatchSize(int batch_size);
233
239
244 void setConfidenceThreshold(float threshold);
245
251
256 void setIOUThreshold(float threshold);
257
263 };
264
265 public ref class OCR : public ManagedObject<DaoAI::DeepLearning::Vision::OCR>
266 {
267 public:
268
275 OCR(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
276
283 OCR(String^ model_file_path, DeviceType device, int device_idx);
284
285
292
294
299 void setBatchSize(int batch_size);
300
306 };
307
308 public ref class Classification : public ManagedObject<DaoAI::DeepLearning::Vision::Classification>
309 {
310 public:
311
318 Classification(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
319
326 Classification(String^ model_file_path, DeviceType device, int device_idx);
327
328
335
337
342 void setBatchSize(int batch_size);
343
349 };
350
351 public ref class SupervisedDefectSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::SupervisedDefectSegmentation>
352 {
353 public:
354
361 SupervisedDefectSegmentation(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
362
369 SupervisedDefectSegmentation(String^ model_file_path, DeviceType device, int device_idx);
370
371
378
380
385 void setBatchSize(int batch_size);
386
392 };
393
394 public ref class AutoSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::AutoSegmentation>
395 {
396 public:
403 AutoSegmentation(String^ model_file_path, DeviceType device, int device_idx);
404
412 AutoSegmentationResult^ inference(ImageEmbedding^ embedding, cli::array<Point^>^ points);
413
421 AutoSegmentationResult^ inference(ImageEmbedding^ embedding, cli::array<Box^>^ boxes, cli::array<Point^>^ points);
422
430 cli::array<AutoSegmentationResult^>^ inference(cli::array<ImageEmbedding^>^ embeddings, cli::array<cli::array<Box^>^>^ boxes, cli::array<cli::array<Point^>^>^ points);
431
437 cli::array<ImageEmbedding^>^ generateImageEmbeddings(cli::array<Image^>^ images);
438
445
451
456 void setBatchSize(int batch_size);
457
462 int getBatchSize();
463 };
464
465#ifdef INDUSTRIAL
466 public ref class PresenceChecking : public ManagedObject<DaoAI::DeepLearning::Vision::PresenceChecking>
467 {
468 public:
469
476 PresenceChecking(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
477
484 PresenceChecking(String^ model_file_path, DeviceType device, int device_idx);
485
486
493
495
500 void setBatchSize(int batch_size);
501
507
512 void setConfidenceThreshold(float threshold);
513
519
524 void setIOUThreshold(float threshold);
525
531 };
532
533 public ref class Positioning : public ManagedObject<DaoAI::DeepLearning::Vision::Positioning>
534 {
535 public:
536
543 Positioning(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx);
544
551 Positioning(String^ model_file_path, DeviceType device, int device_idx);
552
553
560
562
567 void setBatchSize(int batch_size);
568
574
579 void setConfidenceThreshold(float threshold);
580
586
591 void setIOUThreshold(float threshold);
592
598 };
599
600 public ref class ComponentMemory : public ManagedObject<DaoAI::DeepLearning::ComponentMemory>
601 {
602 public:
603
608 ComponentMemory(String^ file_path);
609
615 ComponentMemory(const DaoAI::DeepLearning::ComponentMemory& component_memory);
616
621 void save(String^ file_path);
622
627 void load(String^ file_path);
628 };
629
630 public ref class UnsupervisedDefectSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::UnsupervisedDefectSegmentation>
631 {
632 public:
633
639
640
647
655 UnsupervisedDefectSegmentationResult^ inference(Image^ image, String^ component_name, float sensitivity);
656
664 cli::array<UnsupervisedDefectSegmentationResult^>^ inference(cli::array<Image^>^ images, cli::array<String^>^ component_names, cli::array<float>^ sensitivities);
665
670 void setBatchSize(int batch_size);
671
676 int getBatchSize();
677
678
684 void addComponentMemory(String^ component_name, String^ component_memory_file_path);
685
691 void addComponentMemory(String^ component_name, ComponentMemory^ component_memory);
692
697 void addComponentArchive(String^ archive_path);
698
703 void removeComponentMemory(String^ component_name);
704
709 Dictionary<String^, ComponentMemory^>^ listComponentMemory();
710
716
724 ComponentMemory^ createComponentMemory(String^ component_name, cli::array<Image^>^ good_images, cli::array<Image^>^ bad_images, cli::array<Image^>^ masks, bool append_memory);
725 };
726#endif // INDUSTRIAL
727 }
728 }
729}
static int getNumCUDADevices()
Definition model.cpp:12
static void initialize(bool use_shared_memory, int resevered_vram_size)
Definition model.cpp:8
Definition common.h:173
Definition managed_object.h:18
cli::array< int > num_keypoints
Definition model.h:60
cli::array< String^> class_labels
Definition model.h:59
ModelType model_type
Definition model.h:57
DeviceType device
Definition model.h:58
cli::array< String^> keypoint_labels
Definition model.h:61
int getBatchSize()
Get the batch size for the model.
Definition model.cpp:146
AutoSegmentationResult inference(ImageEmbedding^ embedding, cli::array< Point^>^ points)
Run inferent on image.
Definition model.cpp:151
void setBatchSize(int batch_size)
Set the batch size for the model.
Definition model.cpp:141
cli::array< ImageEmbedding^> generateImageEmbeddings(cli::array< Image^>^ images)
Generate image embeddings for a list of images.
Definition model.cpp:209
AutoSegmentation(String^ model_file_path, DeviceType device, int device_idx)
Construct model specified by model path onto the designated device.
Definition model.cpp:108
ModelInfo getModelInfo()
Get the model info for the model.
Definition model.cpp:120
int getBatchSize()
Get the batch size for the model.
Classification(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
ClassificationResult inference(Image^ image)
: Run inferent on image
void setBatchSize(int batch_size)
Set the batch size for the model.
Classification(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
void load(String^ file_path)
Load the component memory from a file.
Definition model.cpp:248
ComponentMemory(String^ file_path)
Construct a component memory object.
Definition model.cpp:231
void save(String^ file_path)
Save the component memory to a file.
Definition model.cpp:242
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
InstanceSegmentationResult inference(Image^ image)
: Run inferent on image
float getIOUThreshold()
Get the IOU threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
InstanceSegmentation(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
float getConfidenceThreshold()
Get the confidence threshold for the model.
int getBatchSize()
Get the batch size for the model.
InstanceSegmentation(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
KeypointDetection(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
KeypointDetectionResult inference(Image^ image)
: Run inferent on image
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
int getBatchSize()
Get the batch size for the model.
KeypointDetection(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
float getIOUThreshold()
Get the IOU threshold for the model.
float getConfidenceThreshold()
Get the confidence threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
OCRResult inference(Image^ image)
: Run inferent on image
OCR(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
OCR(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
int getBatchSize()
Get the batch size for the model.
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
ObjectDetectionResult inference(Image^ image)
: Run inferent on image
void setBatchSize(int batch_size)
Set the batch size for the model.
ObjectDetection(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
int getBatchSize()
Get the batch size for the model.
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
ObjectDetection(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
float getIOUThreshold()
Get the IOU threshold for the model.
float getConfidenceThreshold()
Get the confidence threshold for the model.
Positioning(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
PositioningResult inference(Image^ image)
: Run inferent on image
float getConfidenceThreshold()
Get the confidence threshold for the model.
float getIOUThreshold()
Get the IOU threshold for the model.
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
Positioning(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
int getBatchSize()
Get the batch size for the model.
PresenceChecking(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
PresenceCheckingResult inference(Image^ image)
: Run inferent on image
int getBatchSize()
Get the batch size for the model.
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
float getIOUThreshold()
Get the IOU threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
PresenceChecking(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
float getConfidenceThreshold()
Get the confidence threshold for the model.
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
SupervisedDefectSegmentation(String^ model_config_path, String^ model_weight_path, DeviceType device, int device_idx)
: Construct model specified by its configuration and weight file paths onto the designated device
int getBatchSize()
Get the batch size for the model.
SupervisedDefectSegmentation(String^ model_file_path, DeviceType device, int device_idx)
: Load the model specified by its configuration and weight files from the model directory onto the de...
SupervisedDefectSegmentationResult inference(Image^ image)
: Run inferent on image
void setBatchSize(int batch_size)
Set the batch size for the model.
void removeComponentMemory(String^ component_name)
Remove a component memory from the component memory list.
Definition model.cpp:325
void addComponentMemory(String^ component_name, String^ component_memory_file_path)
Add a component memory to the component memory list.
Definition model.cpp:305
UnsupervisedDefectSegmentationResult inference(Image^ image)
Run inference on image.
Definition model.cpp:259
void setDetectionLevel(DetectionLevel value)
Set the detection level for the base model, whether image-level or pixel-level.
Definition model.cpp:341
int getBatchSize()
Get the batch size for the model.
Definition model.cpp:300
UnsupervisedDefectSegmentation(DeviceType device)
Construct model specified by its configuration and weight file paths onto the designated device.
Definition model.cpp:254
void addComponentArchive(String^ archive_path)
Add a component memory archive to the component memory list.
Definition model.cpp:319
Dictionary< String^, ComponentMemory^> listComponentMemory()
Get the list of component memory objects.
Definition model.cpp:331
ComponentMemory createComponentMemory(String^ component_name, cli::array< Image^>^ good_images, cli::array< Image^>^ bad_images, cli::array< Image^>^ masks, bool append_memory)
Train a component memory.
Definition model.cpp:346
void setBatchSize(int batch_size)
Set the batch size for the model.
Definition model.cpp:295
DeviceType
Definition model.h:43
ModelType
Definition model.h:28
DetectionLevel
Definition model.h:48
Definition common.cpp:6