o
    toi5                     @  s<   d dl mZ d dlZd dlZd dlmZ G dd deZdS )    )annotationsN)OpRunc                   @  s   e Zd Zd	d
ddZdS )ImageDecoderRGBencoded
np.ndarrayreturntuple[np.ndarray]c              
   C  s   zdd l }W n ty } ztd|d }~ww |jt| }|dkr;t|d d d d d d df }|fS |dkrGt|}|fS |dkr_|	d}t|}tj
|dd	}|fS td
|d)Nr   zYPillow must be installed to use the reference implementation of the ImageDecoder operatorBGRr   	GrayscaleL   )axiszpixel_format=z is not supported.)	PIL.ImageImportErrorImageopenioBytesIOtobytesnparrayconvertexpand_dims
ValueError)selfr   pixel_formatPILeimgdecoded r"   W/home/ubuntu/.local/lib/python3.10/site-packages/onnx/reference/ops/op_image_decoder.py_run   s.   "	


zImageDecoder._runN)r   )r   r   r   r	   )__name__
__module____qualname__r$   r"   r"   r"   r#   r      s    r   )
__future__r   r   numpyr   onnx.reference.op_runr   r   r"   r"   r"   r#   <module>   s
   