Share via


ImageFeatureDescriptor 클래스

정의

모델이 예상하는 이미지의 속성을 설명합니다.

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

Windows 요구 사항

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

예제

다음 예제에서는 로컬 파일에서 모델을 로드하고, 해당 파일에서 세션을 만들고, 입력 및 출력 기능을 가져옵니다.

private async Task LoadModelAsync(string _modelFileName)
{
    LearningModel _model;
    LearningModelSession _session;
    ImageFeatureDescriptor _inputImageDescription;
    TensorFeatureDescriptor _outputImageDescription;

    try
    {
        // Load and create the model
        var modelFile = 
            await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{_modelFileName}"));
        _model = await LearningModel.LoadFromStorageFileAsync(modelFile);

        // Create the evaluation session with the model
        _session = new LearningModelSession(_model);

        //Get input and output features of the model
        List<ILearningModelFeatureDescriptor> inputFeatures = _model.InputFeatures.ToList();
        List<ILearningModelFeatureDescriptor> outputFeatures = _model.OutputFeatures.ToList();

        // Retrieve the first input feature which is an image
        _inputImageDescription = inputFeatures.FirstOrDefault(
            feature => feature.Kind == LearningModelFeatureKind.Image) as ImageFeatureDescriptor;

        // Retrieve the first output feature which is a tensor
        _outputImageDescription = outputFeatures.FirstOrDefault(
            feature => feature.Kind == LearningModelFeatureKind.Tensor) as TensorFeatureDescriptor;
    }
    catch (Exception ex)
    {
        StatusBlock.Text = $"error: {ex.Message}";
        _model = null;
    }
}

설명

Windows Server

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

스레드로부터의 안전성

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

속성

BitmapAlphaMode

이미지의 예상 알파 모드를 지정합니다.

BitmapPixelFormat

예상 픽셀 형식(채널 순서, 비트 깊이 및 데이터 형식)을 지정합니다.

Description

이 기능이 모델에서 사용되는 용도에 대한 설명입니다.

Height

예상 이미지 높이입니다.

IsRequired

true이면 LearningModelSession.Evaluate를 호출하기 전에 이 기능에 값을 바인딩해야 합니다.

Kind

기능의 종류 - 사용할 파생 클래스를 파악하는 데 사용합니다.

Name

이 기능에 값을 바인딩하는 데 사용하는 이름입니다.

PixelRange

모델에 사용할 수 있는 예상 LearningModelPixelRange 정보를 제공합니다.

Width

예상 이미지 너비입니다.

적용 대상

추가 정보