FLImaging 6.5.16.1
TensorLabels.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "TensorImages.h"
6
7#include <atomic>
8
9namespace FLImaging
10{
11 namespace AI
12 {
13 class FL_EXPORT CValidationImageExtractorDL;
14
15 template <typename T>
16 class FL_EXPORT CTensorLabels : public CTensorImages<T>
17 {
18 public:
19 CTensorLabels();
20
21 CTensorLabels(const CTensorLabels<T>& tsr, bool bDeepCopy = true);
22
23 virtual ~CTensorLabels();
24
25 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
26 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
27
28 virtual const CResult SetBinaryData(const Base::CFLData& fldBinary, int64_t* pI64Offset = nullptr) override;
29 virtual const CResult SetBinaryData(const Base::CFLData* pFldBinary, int64_t* pI64Offset = nullptr) override;
30
31 virtual const CResult Create(const std::vector<int64_t>& vctShape, bool bOrderByDesc = true, bool bCudaAllocation = true) override;
32 virtual const CResult Create(const Base::CFLImage& fli, const std::vector<int64_t>& vctNewSize, EResizeMethod eResizeMethod, bool bROIExtraction, bool bNormalize, const Base::CMultiVar<T>& mvBlankColor, ImageProcessing::EInterpolationMethod eInterpolationMethod, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex, bool* pBAbort) override;
33 virtual const CResult Create(const Base::CFLImage* pFli, const std::vector<int64_t>& vctNewSize, EResizeMethod eResizeMethod, bool bROIExtraction, bool bNormalize, const Base::CMultiVar<T>& mvBlankColor, ImageProcessing::EInterpolationMethod eInterpolationMethod, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex, bool* pBAbort) override;
34 virtual const CResult Create(const Base::CFLImage& fli, bool bNormalize = true, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex = nullptr, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
35 virtual const CResult Create(const Base::CFLImage* pFli, bool bNormalize = true, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex = nullptr, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
36 virtual const CResult Create(const Base::CFLImage& fli, const std::vector<int64_t>& vctNewSize, EResizeMethod eResizeMethod = EResizeMethod_ScaleAllAxises, bool bROIExtraction = false, bool bNormalize = true, const Base::CMultiVar<T>& mvBlankColor = 0., ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex = nullptr, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
37 virtual const CResult Create(const Base::CFLImage* pFli, const std::vector<int64_t>& vctNewSize, EResizeMethod eResizeMethod = EResizeMethod_ScaleAllAxises, bool bROIExtraction = false, bool bNormalize = true, const Base::CMultiVar<T>& mvBlankColor = 0., ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex = nullptr, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
38
39
40 virtual const CResult Create(const wchar_t* pWcFilePath, const std::vector<int64_t>& vctNewSize, EResizeMethod eResizeMethod = EResizeMethod_ScaleAllAxises, bool bROIExtraction = false, bool bNormalize = true, const Base::CMultiVar<T>& mvBlankColor = 0., bool bRecursive = false, ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear);
41 virtual const CResult Create(const wchar_t* pWcFilePath, const std::initializer_list<int64_t>& ilNewSize, EResizeMethod eResizeMethod = EResizeMethod_ScaleAllAxises, bool bROIExtraction = false, bool bNormalize = true, const Base::CMultiVar<T>& mvBlankColor = 0., bool bRecursive = false, ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear);
42
43 virtual const CResult Assign(const CTensor<T>* pTsr, bool bDeepCopy = true) override;
44 virtual const CResult Assign(const CTensorImages<T>* pTsr, bool bDeepCopy = true) override;
45
46 virtual const CResult Assign(const CTensorLabels<T>& tsr, bool bDeepCopy = true);
47 virtual const CResult Assign(const CTensorLabels<T>* pTsr, bool bDeepCopy = true);
48
49 virtual const CResult Append(const Base::CFLImage* pFli, EResizeMethod eResizeMethod = EResizeMethod_ScaleAllAxises, bool bROIExtraction = false, bool bNormalize = true, const Base::CMultiVar<T>& mvBlankColor = 0., ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear, std::atomic<int32_t>* pI32CurrentPreparingTensorIndex = nullptr, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
50
51 virtual const CResult Append(const wchar_t* pWcFilePath, bool bRecursive = false) override;
52
53 virtual const CResult Initialize() override;
54 virtual const CResult Clear() override;
55
56 virtual const CResult SetBatchParameters(const CTensorImages<T>& tsr) override;
57 virtual const CResult SetBatchParameters(const CTensorLabels<T>& tsr);
58 virtual const CResult EnableTrainingMode(bool bMode, bool bRecursively = true) override;
59
60 virtual CTensorLabels<T>& Evaluate() override;
61 virtual CComputationalBase<T>* Clone() const override;
62
63 virtual const CResult Swap(CComputationalBase<T>& cbSwap) override;
64
65 virtual const CResult LoadTensor(const std::vector<int64_t>& vctBatchIndices) override;
66
67 virtual const CResult ConvertClassNumToLabel(bool bIncludingClassName = true) override;
68 virtual const CResult ConvertLabelToClassNum(bool bIncludingClassName = true) override;
69
70 DeclareGetClassType();
71 SupportToDuplicateObject(CTensorLabels, *this);
72 protected:
73 virtual const CResult IsValidImageFormat(EImageType eImageType) const override;
74 virtual const CResult DecodeLabels(const wchar_t* pWcsImagePath, Base::CFLImage* pFli = nullptr) override;
75 virtual const CResult CropImage(const Base::CFLImage* pFliSrc, Base::CFLImage* pFliDst, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
76 virtual const CResult InternalCropImage(const std::vector<int64_t>& vctBatchIndices, const Base::CFLImage* pFliSrc, Base::CFLImage* pFliDst, std::atomic<int32_t>* pI32CurrentPreparingLabelIndex = nullptr, bool* pBAbort = nullptr);
77
78 protected:
79 Foundation::CFLFigureArray m_flfaCroppedLabels;
80 std::vector<std::pair<int64_t, std::vector<int32_t>>>& m_vctLabelCount;
81 std::vector<std::pair<int64_t, std::vector<int32_t>>>& m_vctCumulativeLabelCount;
82
83 private:
84 friend class CValidationImageExtractorDL;
85 public:
86 DeclareGetSignletonObject(CTensorLabels);
87 };
88
89 #define CCGFTensorLabels(...) (*(new CTensorLabels<float>(__VA_ARGS__)))
90 #define CCGDTensorLabels(...) (*(new CTensorLabels<double>(__VA_ARGS__)))
91
92 typedef CTensorLabels<float> CTensorLabelsF;
93 typedef CTensorLabels<double> CTensorLabelsD;
94 }
95}
96
97#endif
@ Assign
Set the value of CGUIPropertyItemView3DFigure to the specified figure.
@ Clear
Clear all the figure objects.