ImageFeatureValue 클래스

정의

모델에 전달하는 데 사용되는 이미지의 속성을 설명합니다.

public ref class ImageFeatureValue sealed : ILearningModelFeatureValue
/// [Windows.Foundation.Metadata.ContractVersion(Windows.AI.MachineLearning.MachineLearningContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ImageFeatureValue final : ILearningModelFeatureValue
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.AI.MachineLearning.MachineLearningContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ImageFeatureValue : ILearningModelFeatureValue
Public NotInheritable Class ImageFeatureValue
Implements ILearningModelFeatureValue
상속
Object Platform::Object IInspectable ImageFeatureValue
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10, version 1809 (10.0.17763.0에서 도입되었습니다.)
API contract
Windows.AI.MachineLearning.MachineLearningContract (v1.0에서 도입되었습니다.)

예제

다음 예제에서는 LearningModelSessionLearningModelBinding을 만들고, 입력을 VideoFrame에서 만든 ImageFeatureValue에 바인딩한 다음 출력을 바인딩합니다.

#include <winrt/Windows.AI.MachineLearning.h>
#include <winrt/Windows.Media.h>
using namespace winrt;
using namespace Windows::AI::MachineLearning;
using namespace Windows::Media;

...

void BindModel(
    LearningModel model,
    LearningModelDeviceKind deviceKind,
    winrt::hstring inputName,
    winrt::hstring outputName,
    VideoFrame imageFrame)
{
    // Create a session and binding.
    LearningModelSession session = LearningModelSession{ model, LearningModelDevice(deviceKind) };
    LearningModelBinding binding = LearningModelBinding{ session };

    // Bind the intput image.
    binding.Bind(inputName, ImageFeatureValue::CreateFromVideoFrame(imageFrame));

    // Bind the output.
    std::vector<int64_t> shape({ 1, 1000, 1, 1 });
    binding.Bind(outputName, TensorFloat::Create(shape));
}

설명

이는 이미지를 입력 및 출력으로 전달하는 데 권장되는 방법입니다. 이를 통해 이미지에 집중할 수 있으며 변환 또는 텐서화에 대해 걱정할 필요가 없습니다. ImageFeatureValue.CreateFromVideoFrame 메서드를 사용하여 ImageFeatureValue를 만들 수 있습니다.

Windows ML은 SoftwareBitmapIDirect3DSurface라는 두 가지 유형의 VideoFrame을 지원합니다. 시스템은 모델에 필요한 형식과 일치하도록 이미지의 변환 및 텐서화를 모두 처리합니다. 현재 지원되는 모델 형식은 Gray8, Rgb8 및Bgr8이며 현재 지원되는 픽셀 범위는 0-255입니다.

Windows Server

Windows Server에서 이 API를 사용하려면 데스크톱 환경과 함께 Windows Server 2019를 사용해야 합니다.

스레드로부터의 안전성

이 API는 스레드로부터 안전합니다.

속성

Kind

기능과 연결된 Kind를 반환합니다.

VideoFrame

비디오 프레임을 가져옵니다.

메서드

CreateFromVideoFrame(VideoFrame)

지정된 비디오 프레임을 사용하여 ImageFeatureValue 를 만듭니다.

적용 대상

추가 정보