How to use winrt - 10 common examples

To help you get started, we’ve selected a few winrt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ninthDevilHAUNSTER / ArknightsAutoHelper / Arknights / ocr / windows_media_ocr_impl.py View on Github external
def recognize(img, lang, *, hints=None):
    if hints == None:
        hints = []
    if OcrHint.SINGLE_LINE in hints:
        img = ImageOps.expand(img, 32, fill=img.getpixel((0, 0)))

    lang = Language(lang)
    assert (OcrEngine.is_language_supported(lang))
    eng = OcrEngine.try_create_from_language(lang)
    swbmp = _swbmp_from_pil_image(img)
    return _dump_ocrresult(_blocking_wait(eng.recognize_async(swbmp)))
github ninthDevilHAUNSTER / ArknightsAutoHelper / Arknights / ocr / windows_media_ocr_impl.py View on Github external
def recognize(img, lang, *, hints=None):
    if hints == None:
        hints = []
    if OcrHint.SINGLE_LINE in hints:
        img = ImageOps.expand(img, 32, fill=img.getpixel((0, 0)))

    lang = Language(lang)
    assert (OcrEngine.is_language_supported(lang))
    eng = OcrEngine.try_create_from_language(lang)
    swbmp = _swbmp_from_pil_image(img)
    return _dump_ocrresult(_blocking_wait(eng.recognize_async(swbmp)))
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def bind_model(model, image_frame):
    device = winml.LearningModelDevice(winml.LearningModelDeviceKind.DEFAULT)
    session = winml.LearningModelSession(model, device)
    binding = winml.LearningModelBinding(session)
    image_feature_value = winml.ImageFeatureValue.create_from_video_frame(image_frame)
    binding.bind("data_0", image_feature_value)
    shape = winml.TensorFloat.create([1, 1000, 1, 1])
    binding.bind("softmaxout_1", shape)
    return (session, binding)
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def load_model(model_path):
    return winml.LearningModel.load_from_file_path(os.fspath(model_path))
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def evaluate_model(session, binding):
    results = session.evaluate(binding, "RunId")
    o = results.outputs["softmaxout_1"]
    result_tensor = winml.TensorFloat._from(o)
    return result_tensor.get_as_vector_view()
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def bind_model(model, image_frame):
    device = winml.LearningModelDevice(winml.LearningModelDeviceKind.DEFAULT)
    session = winml.LearningModelSession(model, device)
    binding = winml.LearningModelBinding(session)
    image_feature_value = winml.ImageFeatureValue.create_from_video_frame(image_frame)
    binding.bind("data_0", image_feature_value)
    shape = winml.TensorFloat.create([1, 1000, 1, 1])
    binding.bind("softmaxout_1", shape)
    return (session, binding)
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def bind_model(model, image_frame):
    device = winml.LearningModelDevice(winml.LearningModelDeviceKind.DEFAULT)
    session = winml.LearningModelSession(model, device)
    binding = winml.LearningModelBinding(session)
    image_feature_value = winml.ImageFeatureValue.create_from_video_frame(image_frame)
    binding.bind("data_0", image_feature_value)
    shape = winml.TensorFloat.create([1, 1000, 1, 1])
    binding.bind("softmaxout_1", shape)
    return (session, binding)
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def bind_model(model, image_frame):
    device = winml.LearningModelDevice(winml.LearningModelDeviceKind.DEFAULT)
    session = winml.LearningModelSession(model, device)
    binding = winml.LearningModelBinding(session)
    image_feature_value = winml.ImageFeatureValue.create_from_video_frame(image_frame)
    binding.bind("data_0", image_feature_value)
    shape = winml.TensorFloat.create([1, 1000, 1, 1])
    binding.bind("softmaxout_1", shape)
    return (session, binding)
github ninthDevilHAUNSTER / ArknightsAutoHelper / Arknights / ocr / windows_media_ocr_impl.py View on Github external
def _ibuffer(s):
    """create WinRT IBuffer instance from a bytes-like object"""
    return CryptographicBuffer.decode_from_base64_string(base64.b64encode(s).decode('ascii'))
github microsoft / xlang / samples / python / winml_tutorial / complete_winml_tutorial.py View on Github external
def bind_model(model, image_frame):
    device = winml.LearningModelDevice(winml.LearningModelDeviceKind.DEFAULT)
    session = winml.LearningModelSession(model, device)
    binding = winml.LearningModelBinding(session)
    image_feature_value = winml.ImageFeatureValue.create_from_video_frame(image_frame)
    binding.bind("data_0", image_feature_value)
    shape = winml.TensorFloat.create([1, 1000, 1, 1])
    binding.bind("softmaxout_1", shape)
    return (session, binding)