mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

python ImageClassifier RuntimeError: File loading is not yet supported on Windows

Open lonngxiang opened this issue 8 months ago • 2 comments

import mediapipe as mp

BaseOptions = mp.tasks.BaseOptions
ImageClassifier = mp.tasks.vision.ImageClassifier
ImageClassifierOptions = mp.tasks.vision.ImageClassifierOptions
VisionRunningMode = mp.tasks.vision.RunningMode

options = ImageClassifierOptions(
    base_options=BaseOptions(model_asset_path=r"C:\Users\loong\Downloads\mediapipe\model.tflite"),
    max_results=5,
    running_mode=VisionRunningMode.IMAGE)

with ImageClassifier.create_from_options(options) as classifier:
    # The classifier is initialized. Use it here.
    # Load the input image from an image file.
    mp_image = mp.Image.create_from_file(r"C:****\sunflowers\9558627290_353a14ba0b_m.jpg")

    # Load the input image from a numpy array.
    mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=numpy_image)

    # Perform image classification on the provided single image.
    classification_result = classifier.classify(mp_image)
    classification_result

image

lonngxiang avatar Oct 30 '23 07:10 lonngxiang