ImageFeatureValue Classe

Définition

Décrit les propriétés de l’image utilisée pour passer dans un modèle.

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
Héritage
Object Platform::Object IInspectable ImageFeatureValue
Attributs
Implémente

Configuration requise pour Windows

Famille d’appareils
Windows 10, version 1809 (introduit dans 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (introduit dans v1.0)

Exemples

L’exemple suivant crée un LearningModelSession et un LearningModelBinding, lie l’entrée à une ImageFeatureValue créée à partir d’un VideoFrame, puis lie la sortie.

#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));
}

Remarques

Il s’agit de la méthode recommandée pour passer des images en tant qu’entrées et sorties. Il vous permet de vous concentrer sur l’image et de ne pas avoir à vous soucier des conversions ou de la tenseur. Vous pouvez créer un ImageFeatureValue à l’aide de la méthode ImageFeatureValue.CreateFromVideoFrame .

Windows ML prend en charge deux types de VideoFrame : SoftwareBitmap et IDirect3DSurface. Le système prend en charge la conversion et la tenseur pour que les images correspondent au format requis par le modèle. Les types de formats de modèles actuellement pris en charge sont Gray8, Rgb8 et Bgr8, et la plage de pixels actuellement prise en charge est 0-255.

Windows Server

Pour utiliser cette API sur Windows Server, vous devez utiliser Windows Server 2019 avec Expérience de bureau.

Sécurité des threads

Cette API est thread-safe.

Propriétés

Kind

Retourne le type associé à la fonctionnalité.

VideoFrame

Obtient l’image vidéo.

Méthodes

CreateFromVideoFrame(VideoFrame)

Crée une imageFeatureValue à l’aide de l’image vidéo donnée.

S’applique à

Voir aussi