示例#1
0
    public async Task <bool> LoadModel()
    {
        try
        {
            StorageFile imageRecoModelFile = await StorageFile.GetFileFromApplicationUriAsync(modelFile);

            if (imageRecoModelFile == null)
            {
                Debug.Log("Could not read model file");
                return(false);
            }

#if SDK_1809
            model = await TinyYoloV2O12Model.CreateFromStreamAsync(imageRecoModelFile);
#else
            model = await TinyYoloV2O1Model.CreateTinyYoloV2O1Model(imageRecoModelFile);
#endif
            if (model == null)
            {
                Debug.Log("Could not instantiate model");
                return(false);
            }
        }
        catch (Exception e)
        {
            Debug.Log($"Could not get file: {e.Message}");
            throw;
        }
        return(true);
    }
示例#2
0
    public static async Task <TinyYoloV2O1Model> CreateTinyYoloV2O1Model(StorageFile file)
    {
        LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

        TinyYoloV2O1Model model = new TinyYoloV2O1Model();

        model.learningModel = learningModel;
        return(model);
    }