mediapipe
mediapipe copied to clipboard
python ImageClassifier RuntimeError: File loading is not yet supported on Windows
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