DaoAI World C# SDK INDUSTRIAL 2025.3.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/dwsdk/model.h"
6#include "../daoai_dl_sdk/include/export/dwsdk/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();
19
24 static int getNumCUDADevices();
25 };
26
27 public enum class ModelType : int
28 {
29 Object_Detection = DaoAI::DeepLearning::ModelType::Object_Detection,
30 Multilabel_Detection = DaoAI::DeepLearning::ModelType::Multilabel_Detection,
31 Instance_Segmentation = DaoAI::DeepLearning::ModelType::Instance_Segmentation,
32 Keypoint_Detection = DaoAI::DeepLearning::ModelType::Keypoint_Detection,
33 Classification = DaoAI::DeepLearning::ModelType::Classification,
34 OCR = DaoAI::DeepLearning::ModelType::OCR,
35 Supervised_Defect_Segmentation = DaoAI::DeepLearning::ModelType::Supervised_Defect_Segmentation,
36 Auto_Segmentation = DaoAI::DeepLearning::ModelType::Auto_Segmentation,
37 Rotated_Object_Detection = DaoAI::DeepLearning::ModelType::Rotated_Object_Detection,
38#ifdef INDUSTRIAL
39 Presence_Checking = DaoAI::DeepLearning::ModelType::Presence_Checking,
40 Positioning = DaoAI::DeepLearning::ModelType::Positioning,
41 Unsupervised_Defect_Segmentation = DaoAI::DeepLearning::ModelType::Unsupervised_Defect_Segmentation
42#endif // INDUSTRIAL
43 };
44
45 public enum class DeviceType {
46 CPU = DaoAI::DeepLearning::DeviceType::CPU,
47 GPU = DaoAI::DeepLearning::DeviceType::GPU
48 };
49
50 public enum class DetectionLevel {
51 PIXEL_FAST = DaoAI::DeepLearning::Vision::DetectionLevel::PIXEL_FAST,
52 PIXEL_ACCURATE = DaoAI::DeepLearning::Vision::DetectionLevel::PIXEL_ACCURATE,
53 IMAGE = DaoAI::DeepLearning::Vision::DetectionLevel::IMAGE
54 };
55
56
60 public ref class ModelInfo
61 {
62 public:
65 cli::array<String^>^ class_labels;
66 cli::array<int>^ num_keypoints;
67 cli::array<String^>^ keypoint_labels;
68 };
69
70 namespace Vision
71 {
72 public ref class ObjectDetection : public ManagedObject<DaoAI::DeepLearning::Vision::ObjectDetection>
73 {
74 public:
81 ObjectDetection(String^ model_file_path, DeviceType device, int device_idx);
82
83
90
96 cli::array<ObjectDetectionResult^>^ inference(cli::array<Image^>^ images);
97
98
100
105 void setBatchSize(int batch_size);
106
112
117 void setConfidenceThreshold(float threshold);
118
124
129 void setIOUThreshold(float threshold);
130
136 };
137 public ref class RotatedObjectDetection : public ManagedObject<DaoAI::DeepLearning::Vision::RotatedObjectDetection>
138 {
139 public:
146 RotatedObjectDetection(String^ model_file_path, DeviceType device, int device_idx);
147
148
155
161 cli::array<RotatedObjectDetectionResult^>^ inference(cli::array<Image^>^ images);
162
163
165
170 void setBatchSize(int batch_size);
171
177
182 void setConfidenceThreshold(float threshold);
183
189
194 void setIOUThreshold(float threshold);
195
201 };
202
203 public ref class MultilabelDetection : public ManagedObject<DaoAI::DeepLearning::Vision::MultilabelDetection>
204 {
205 public:
212 MultilabelDetection(String^ model_file_path, DeviceType device, int device_idx);
213
214
221
227 cli::array<MultilabelDetectionResult^>^ inference(cli::array<Image^>^ images);
228
229
231
236 void setBatchSize(int batch_size);
237
243
248 void setConfidenceThreshold(float threshold);
249
255
260 void setIOUThreshold(float threshold);
261
267 };
268
269 public ref class InstanceSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::InstanceSegmentation>
270 {
271 public:
278 InstanceSegmentation(String^ model_file_path, DeviceType device, int device_idx);
279
286
292 cli::array<InstanceSegmentationResult^>^ inference(cli::array<Image^>^ images);
293
295
300 void setBatchSize(int batch_size);
301
307
312 void setConfidenceThreshold(float threshold);
313
319
324 void setIOUThreshold(float threshold);
325
331 };
332
333 public ref class KeypointDetection : public ManagedObject<DaoAI::DeepLearning::Vision::KeypointDetection>
334 {
335 public:
342 KeypointDetection(String^ model_file_path, DeviceType device, int device_idx);
343
350
356 cli::array<KeypointDetectionResult^>^ inference(cli::array<Image^>^ images);
357
359
364 void setBatchSize(int batch_size);
365
371
376 void setConfidenceThreshold(float threshold);
377
383
388 void setIOUThreshold(float threshold);
389
395 };
396
397 public ref class OCR : public ManagedObject<DaoAI::DeepLearning::Vision::OCR>
398 {
399 public:
406 OCR(String^ model_file_path, DeviceType device, int device_idx);
407
408
415
421 cli::array<OCRResult^>^ inference(cli::array<Image^>^ images);
422
424
429 void setBatchSize(int batch_size);
430
436 };
437
438 public ref class Classification : public ManagedObject<DaoAI::DeepLearning::Vision::Classification>
439 {
440 public:
447 Classification(String^ model_file_path, DeviceType device, int device_idx);
448
449
456
462 cli::array<ClassificationResult^>^ inference(cli::array<Image^>^ images);
463
465
470 void setBatchSize(int batch_size);
471
477 };
478
479 public ref class SupervisedDefectSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::SupervisedDefectSegmentation>
480 {
481 public:
488 SupervisedDefectSegmentation(String^ model_file_path, DeviceType device, int device_idx);
489
490
497
503 cli::array<SupervisedDefectSegmentationResult^>^ inference(cli::array<Image^>^ images);
504
506
511 void setBatchSize(int batch_size);
512
518 };
519
520 public ref class AutoSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::AutoSegmentation>
521 {
522 public:
529 AutoSegmentation(String^ model_file_path, DeviceType device, int device_idx);
530
538 AutoSegmentationResult^ inference(ImageEmbedding^ embedding, cli::array<Point^>^ points);
539
547 AutoSegmentationResult^ inference(ImageEmbedding^ embedding, cli::array<Box^>^ boxes, cli::array<Point^>^ points);
548
556 cli::array<AutoSegmentationResult^>^ inference(cli::array<ImageEmbedding^>^ embeddings, cli::array<cli::array<Box^>^>^ boxes, cli::array<cli::array<Point^>^>^ points);
557
563 cli::array<ImageEmbedding^>^ generateImageEmbeddings(cli::array<Image^>^ images);
564
571
577
582 void setBatchSize(int batch_size);
583
588 int getBatchSize();
589 };
590
591#ifdef INDUSTRIAL
592 public ref class PresenceChecking : public ManagedObject<DaoAI::DeepLearning::Vision::PresenceChecking>
593 {
594 public:
601 PresenceChecking(String^ model_file_path, DeviceType device, int device_idx);
602
603
610
616 cli::array<PresenceCheckingResult^>^ inference(cli::array<Image^>^ images);
617
625
630 void setBatchSize(int batch_size);
631
637
642 void setConfidenceThreshold(float threshold);
643
649
654 void setIOUThreshold(float threshold);
655
661 };
662
663 public ref class Positioning : public ManagedObject<DaoAI::DeepLearning::Vision::Positioning>
664 {
665 public:
672 Positioning(String^ model_file_path, DeviceType device, int device_idx);
673
674
681
687 cli::array<PositioningResult^>^ inference(cli::array<Image^>^ images);
688
690
695 void setBatchSize(int batch_size);
696
702
707 void setConfidenceThreshold(float threshold);
708
714
719 void setIOUThreshold(float threshold);
720
726 };
727
728 public ref class ComponentMemory : public ManagedObject<DaoAI::DeepLearning::ComponentMemory>
729 {
730 public:
731
736 ComponentMemory(String^ file_path);
737
743 ComponentMemory(const DaoAI::DeepLearning::ComponentMemory& component_memory);
744
749 void setImageThreshold(float value);
750
755 float getImageThreshold();
756
761 void setPixelThreshold(float value);
762
767 float getPixelThreshold();
768
773 void save(String^ file_path);
774
779 void load(String^ file_path);
780 };
781
782 public ref class UnsupervisedDefectSegmentation : public ManagedObject<DaoAI::DeepLearning::Vision::UnsupervisedDefectSegmentation>
783 {
784 public:
785
791
792
799
805 cli::array<UnsupervisedDefectSegmentationResult^>^ inference(cli::array<Image^>^ images);
806
813 UnsupervisedDefectSegmentationResult^ inference(Image^ image, String^ component_name);
814
821 cli::array<UnsupervisedDefectSegmentationResult^>^ inference(cli::array<Image^>^ images, cli::array<String^>^ component_names);
822
827 void setBatchSize(int batch_size);
828
833 int getBatchSize();
834
835
841 void addComponentMemory(String^ component_name, String^ component_memory_file_path);
842
848 void addComponentMemory(String^ component_name, ComponentMemory^ component_memory);
849
854 void addComponentArchive(String^ archive_path);
855
860 void removeComponentMemory(String^ component_name);
861
866 Dictionary<String^, ComponentMemory^>^ listComponentMemory();
867
873
881 ComponentMemory^ createComponentMemory(String^ component_name, cli::array<Image^>^ good_images, cli::array<Image^>^ bad_images, cli::array<Image^>^ masks, bool append_memory);
882 };
883#endif // INDUSTRIAL
884 }
885 }
886}
static int getNumCUDADevices()
Definition model.cpp:12
static void initialize()
Definition model.cpp:8
Definition common.h:173
Definition managed_object.h:60
: Deprecated, will be removed in the future
Definition model.h:61
cli::array< int > num_keypoints
Definition model.h:66
cli::array< String^> class_labels
Definition model.h:65
ModelType model_type
Definition model.h:63
DeviceType device
Definition model.h:64
cli::array< String^> keypoint_labels
Definition model.h:67
int getBatchSize()
Get the batch size for the model.
Definition model.cpp:153
AutoSegmentationResult inference(ImageEmbedding^ embedding, cli::array< Point^>^ points)
Run inferent on image.
Definition model.cpp:158
void setBatchSize(int batch_size)
Set the batch size for the model.
Definition model.cpp:148
cli::array< ImageEmbedding^> generateImageEmbeddings(cli::array< Image^>^ images)
Generate image embeddings for a list of images.
Definition model.cpp:216
AutoSegmentation(String^ model_file_path, DeviceType device, int device_idx)
Construct model specified by model path onto the designated device.
Definition model.cpp:115
ModelInfo getModelInfo()
Get the model info for the model.
Definition model.cpp:127
int getBatchSize()
Get the batch size for the model.
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...
cli::array< ClassificationResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
float getImageThreshold()
get the image threshold
Definition model.cpp:266
void setImageThreshold(float value)
set the image threshold
Definition model.cpp:261
void setPixelThreshold(float value)
set the pixel threshold
Definition model.cpp:271
void load(String^ file_path)
Load the component memory from a file.
Definition model.cpp:255
float getPixelThreshold()
get the pixel threshold
Definition model.cpp:276
ComponentMemory(String^ file_path)
Construct a component memory object.
Definition model.cpp:238
void save(String^ file_path)
Save the component memory to a file.
Definition model.cpp:249
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.
cli::array< InstanceSegmentationResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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.
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
cli::array< KeypointDetectionResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
int getBatchSize()
Get the batch size for the model.
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.
MultilabelDetectionResult inference(Image^ image)
: Run inferent on image
float getConfidenceThreshold()
Get the confidence 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.
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
float getIOUThreshold()
Get the IOU threshold for the model.
MultilabelDetection(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...
cli::array< MultilabelDetectionResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
int getBatchSize()
Get the batch size for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
OCRResult inference(Image^ image)
: Run inferent on image
cli::array< OCRResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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.
cli::array< ObjectDetectionResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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...
cli::array< PositioningResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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.
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.
cli::array< PresenceCheckingResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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...
ModelInfo getModelInfo()
: Run inferent on multiple images
float getConfidenceThreshold()
Get the confidence threshold for the model.
void setIOUThreshold(float threshold)
Set the IOU threshold for the model.
void setBatchSize(int batch_size)
Set the batch size for the model.
float getIOUThreshold()
Get the IOU threshold for the model.
int getBatchSize()
Get the batch size for the model.
RotatedObjectDetectionResult inference(Image^ image)
: Run inferent on image
void setConfidenceThreshold(float threshold)
Set the confidence threshold for the model.
cli::array< RotatedObjectDetectionResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
RotatedObjectDetection(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.
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
cli::array< SupervisedDefectSegmentationResult^> inference(cli::array< Image^>^ images)
: Run inferent on multiple images
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:362
void addComponentMemory(String^ component_name, String^ component_memory_file_path)
Add a component memory to the component memory list.
Definition model.cpp:342
UnsupervisedDefectSegmentationResult inference(Image^ image)
Run inference on image.
Definition model.cpp:286
void setDetectionLevel(DetectionLevel value)
Set the detection level for the base model, whether image-level or pixel-level.
Definition model.cpp:378
int getBatchSize()
Get the batch size for the model.
Definition model.cpp:337
UnsupervisedDefectSegmentation(DeviceType device)
Construct model specified by its configuration and weight file paths onto the designated device.
Definition model.cpp:281
void addComponentArchive(String^ archive_path)
Add a component memory archive to the component memory list.
Definition model.cpp:356
Dictionary< String^, ComponentMemory^> listComponentMemory()
Get the list of component memory objects.
Definition model.cpp:368
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:383
void setBatchSize(int batch_size)
Set the batch size for the model.
Definition model.cpp:332
DeviceType
Definition model.h:45
ModelType
Definition model.h:28
DetectionLevel
Definition model.h:50
Definition common.cpp:6