o
    7?e_                     @   s    d dl ZdZG dd deZdS )    Nu   Iván de Paz Centenoc                   @   sj   e Zd ZddefddZdd Zdefdd	ZddefddZdd Z	dde
fddZdd Zdd Zd
S )NetworkT	trainablec                 C   s\   || _ || _i | _d| _tjj| jj	
  |   W d   dS 1 s'w   Y  dS )z
        Initializes the network.
        :param trainable: flag to determine if this network should be trainable or not.
        N)_session_Network__trainable_Network__layers_Network__last_layer_nametfcompatv1variable_scope	__class____name__lower_config)selfsessionr    r   N/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/mtcnn/network.py__init__!   s   
"zNetwork.__init__c                 C      t d)zk
        Configures the network layers.
        It is usually done using the LayerFactory() class.
        z/This method must be implemented by the network.NotImplementedErrorr   r   r   r   r   .   s   zNetwork._confignamec                 C   s   || j |< || _dS )z
        Adds a layer to the network.
        :param name: name of the layer to add
        :param layer_output: output layer.
        N)r   r   )r   r   Zlayer_outputr   r   r   	add_layer5   s   

zNetwork.add_layerNc                 C   s   |du r| j }| j| S )z
        Retrieves the layer by its name.
        :param name: name of the layer to retrieve. If name is None, it will retrieve the last added layer to the
        network.
        :return: layer output
        N)r   r   )r   r   r   r   r   	get_layer>   s   
zNetwork.get_layerc                 C   s   | j S )z0
        Getter for the trainable flag.
        )r   r   r   r   r   is_trainableJ   s   zNetwork.is_trainableFweights_valuesc                 C   s   | j j }tjj|R |D ]F}tjjj|dd3 ||  D ]$\}}ztjjj|dd}| j	
|| W q" tyF   |sD Y q"w W d   n1 sQw   Y  qW d   dS 1 sbw   Y  dS )z
        Sets the weights values of the network.
        :param weights_values: dictionary with weights for each layer
        T)ZreuseF)Zuse_resourceN)r   r   r   r   r	   r
   r   itemsZget_variabler   runZassign
ValueError)r   r   Zignore_missingnetwork_nameZ
layer_name
param_namedatavarr   r   r   set_weightsP   s$   "zNetwork.set_weightsc                 C   sH   | j j }tjj| | |W  d   S 1 sw   Y  dS )z
        Feeds the network with an image
        :param image: image (perhaps loaded with CV2)
        :return: network result
        N)r   r   r   r   r	   r
   r   _feed)r   imager!   r   r   r   feedc   s   $zNetwork.feedc                 C   r   )NzMethod not implemented.r   )r   r'   r   r   r   r&   n   s   zNetwork._feed)T)N)F)r   
__module____qualname__boolr   r   strr   r   r   dictr%   r(   r&   r   r   r   r   r      s    	r   )Z
tensorflowr   
__author__objectr   r   r   r   r   <module>   s   