ImageFeatureDescriptor 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
描述模型期望的图像的属性。
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 : ILearningModelFeatureDescriptorPublic NotInheritable Class ImageFeatureDescriptor
Implements ILearningModelFeatureDescriptor- 继承
- 属性
- 实现
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 | 指定图像的预期 alpha 模式。 | 
| BitmapPixelFormat | 指定预期的像素格式 (通道排序、位深度和数据类型) 。 | 
| Description | 描述此功能在模型中的用途。 | 
| Height | 预期的图像高度。 | 
| IsRequired | 如果为 true,则必须在调用 LearningModelSession.Evaluate 之前将值绑定到此功能。 | 
| Kind | 功能类型 - 使用此类型可知道要使用哪个派生类。 | 
| Name | 用于将值绑定到此功能的名称。 | 
| PixelRange | 提供用于模型的预期 LearningModelPixelRange 信息。 | 
| Width | 预期的图像宽度。 |