a
    Sic                     @   s^   d Z ddlZddlZddlZddlZddlZddlm  mZ	 ddl
mZ dd Zdd ZdS )z5Saving utilities to support Python's Pickle protocol.    N)savec           	   
   C   s   dt   }t| }tj|dd}| D ]}tjj	||}|
|}tjjtj| | r0tjj|d$}|||  W d   q01 s0    Y  q0W d   n1 s0    Y  t|}tjj| |S )zReconstruct a Model from the output of `serialize_model_as_bytecode`.

    Args:
        serialized_model: (np.array) return value from
          `serialize_model_as_bytecode`.

    Returns:
        keras.Model: Keras Model instance.
    ram://rfileobjmodewbN)uuiduuid4ioBytesIOtarfileopengetnamestfgfilejoin	getmembermakedirsospathdirnameisfileGFilewriteextractfilereadsave_module
load_modelrmtree)	Zserialized_modeltemp_dirbarchivename	dest_pathmemberfmodel r(   U/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/saving/pickle_utils.pydeserialize_model_from_bytecode   s    


R
r*   c                 C   sD  dt   }| | t }tj|dd}tjj	|D ]\}}}|D ]0}tjj
||}t|}	tj|	_||	 qL|D ]r}
tjj
||
}tjj|d>}tjtj||d}| |_|j||d W d   q1 s0    Y  qq>W d   n1 s0    Y  tjj| |d tt| fS )	zConvert a Keras Model into a bytecode representation for pickling.

    Args:
        model: (tf.keras.Model) Keras Model instance.

    Returns:
        tuple: tuple of arguments that can be sent to
            `deserialize_from_bytecode`.
    r   wr   rb)r#   )tarinfor   Nr   )r	   r
   r   r   r   r   r   r   r   walkr   TarInfoDIRTYPEtypeaddfiler   r   r   relpathsizer   seeknumpyasarray
memoryviewr   )r'   r    r!   r"   rootdirs	filenamesr   r$   tfilenamer&   infor(   r(   r)   serialize_model_as_bytecode4   s*    



P
r?   )__doc__r   r   r   r	   r6   tensorflow.compat.v2compatv2r   keras.savingr   r   r*   r?   r(   r(   r(   r)   <module>   s   