CoolFace
Apppublic

hololens/stable-diffusion-webui-depthmap-script

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
Resnet.cpython-312.pyc58 linesDownload Raw Back to __pycache__
12��f(����ddlmZddlmZgd�Zdddddd�Zdd	�ZGd3�dej�ZGd�d
ej�ZGd�dej�Z	dd�Z4dd�Zdd�Zdd�Z
dd�Zy)�N)�ResNet�resnet18�resnet34�resnet50�	resnet101�	resnet152z9https://download.pytorch.org/models/resnet18-5c106cde.pthz9https://download.pytorch.org/models/resnet34-333f7ec4.pthz9https://download.pytorch.org/models/resnet50-19c8e357.pthz:https://download.pytorch.org/models/resnet101-5d3b4d8f.pthz:https://download.pytorch.org/models/resnet152-b121ed2d.pth)rrrrrc�8�tj||d|dd��S)z3x3 convolution with padding��F��kernel_size�stride�padding�bias)�nn�Conv2d)�	in_planes�5out_planesrs   �BF:\3dpicmaker\stable-diffusion-webui-depthmap-script\lib\Resnet.py�conv3x3rs ��
�9�9�Y�6��&��U�,�,�c�*��eZdZdZd�fd�	Zd�Z�xZS)�7BasicBlockrc�*��tt|��t|||�|_tj|�|_tjd��|_8t||�|_tj|�|_||_
||_y)NT��inplace)�superr�__init__r�conv1�NN�BatchNorm2d�bn1r�ReLU�relu�conv2�bn2�9downsampler��self�inplanes�planesrr'�	__class__s     �rrzBasicBlock.__init__sl���
�j�$�(�*��X�v�v�6��10��>�>�&�)����G�G�D�)��	��V�V�,��11��>�>�&�)���$�����rc��|}|j|�}|j|�}|j|�}|j|�}|j	|�}|j12�|j|�}||z
}|j|�}|S�N)rr"r$r%r&r'�r)�x�residual�outs    r�forwardzBasicBlock.forward$s{�����j�j��m���h�h�s�m���i�i��n���j�j��o���h�h�s�m���?�?�&����q�)�H��x����i�i��n���13r�rN��__name__�14__module__�__qualname__�	expansionrr3�
__classcell__�r,s@rrrs����I��rrc�*��eZdZdZd�fd�	Zd�Z�xZS)�15Bottleneck�c���tt|��tj||dd��|_t
j|�|_tj||d|dd��|_	t
j|�|_16tj|||jzdd��|_t
j||jz�|_
tjd��|_||_||_y)NrF)r
rr17rTr)rr=rrrrr r!r"r%r&r9�conv3�bn3r#r$r'rr(s     �rrzBottleneck.__init__:s����
�j�$�(�*��Y�Y�x��Q�U�K��18��>�>�&�)����Y�Y�v�v�1�V�'(�u�6��19��>�>�&�)����Y�Y�v�v����'>�A�TY�Z��20��>�>�&�4�>�>�"9�:����G�G�D�)��	�$�����rc��|}|j|�}|j|�}|j|�}|j|�}|j	|�}|j|�}|j|�}|j
|�}|j�|j|�}||z
}|j|�}|Sr.)rr"r$r%r&r@rAr'r/s    rr3zBottleneck.forwardGs������j�j��m���h�h�s�m���i�i��n���j�j��o���h�h�s�m���i�i��n���j�j��o���h�h�s�m���?�?�&����q�)�H��x����i�i��n���21rr4r5r;s@rr=r=7s����I��rr=c�.��eZdZd�fd�	Zdd�Zd�Z�xZS)rc���d|_tt|��t	j22dddddd��|_tjd�|_	t	jd��|_t	jddd	�23�|_
|j|d|d�|_|j|d|d	d�
�|_|j|d|dd�
�|_|j|d|dd�
�|_|j'�D]�}t)|tj24�r-tj*j-|j.dd���Jt)|tj�s�etj*j1|j.d	�tj*j1|j2d���y)N�@r25��FrTrr)r
rrr�)r�i�fan_outr$)�mode�nonlinearity)r*rrrrrrr r!r"r#r$�	MaxPool2d�maxpool�_make_layer�layer1�layer2�layer3�layer4�modules�26isinstance�init�kaiming_normal_�weight�	constant_r)r)�block�layers�num_classes�mr,s     �rrzResNet.__init__`s_�����
�
�f�d�$�&��Y�Y�q�"�!�A�q�$)�+��27��>�>�"�%����G�G�D�)��	��|�|��!�Q�G����&�&�u�b�&��)�<����&�&�u�c�6�!�9�Q�&�G����&�&�u�c�6�!�9�Q�&�G����&�&�u�c�6�!�9�Q�&�G�������	-�A��!�R�Y�Y�'����'�'����y�v�'�V��A�r�~�~�.����!�!�!�(�(�A�.����!�!�!�&�&�!�,�	-rc	��d}|dk7s|j||jzk7retjtj|j||jzd|d��tj||jz��}g}|j||j|||��||jz|_td|�D]$}|j||j|���&tj|�S)NrF)r
rr)	r*r9r�28Sequentialrr r!�append�range)r)rZr+�blocksrr'r[�is        rrOzResNet._make_layervs����29��Q�;�$�-�-�6�E�O�O�+C�C�����	�	�$�-�-��%�/�/�)A�&'��U�D����v����7�8��J����
�
�e�D�M�M�6�6�:�F�G�����0��
��q�&�!�	8�A��M�M�%��
�
�v�6�7�	8��}�}�f�%�%rc��g}|j|�}|j|�}|j|�}|j|�}|j	|�}|j|�|j
|�}|j|�|j|�}|j|�|j|�}|j|�|Sr.)	rr"r$rNrPr`rQrRrS)r)r0�featuress   rr3zResNet.forward�s������J�J�q�M���H�H�Q�K���I�I�a�L���L�L��O���K�K��N��������K�K��N��������K�K��N��������K�K��N��������r)i��r)r6r7r8rrOr3r:r;s@rrr^s���-�,&�"rrc�,�ttgd�fi|��}|S)zxConstructs a ResNet-18 model.30    Args:31        pretrained (bool): If True, returns a model pre-trained on ImageNet32    )rGrGrGrG�rr��33pretrained�kwargs�models   rrr����34
�:�|�6�v�6�E��Lrc�,�ttgd�fi|��}|S)zxConstructs a ResNet-34 model.35    Args:36        pretrained (bool): If True, returns a model pre-trained on ImageNet37    �r38r>�r39rhris   rrr�rmrc�,�ttgd�fi|��}|S)zxConstructs a ResNet-50 model.40    Args:41        pretrained (bool): If True, returns a model pre-trained on ImageNet42    ro�rr=ris   rrr�s��43
�:�|�6�v�6�E��Lrc�,�ttgd�fi|��}|S)zyConstructs a ResNet-101 model.44    Args:45        pretrained (bool): If True, returns a model pre-trained on ImageNet46    )r47r>�r48rrris   rrr�s��49
�:�}�7��7�E��Lrc�,�ttgd�fi|��}|S)zyConstructs a ResNet-152 model.50    Args:51        pretrained (bool): If True, returns a model pre-trained on ImageNet52    )r53��$r54rrris   rrr�s��55
�:�}�7��7�E��Lrrf)T)�torch.nnrr �__all__�56model_urlsr�Modulerr=rrrrrr�rr�<module>r}s|������57L�K�K�M�M��58�,������@$����$�N:�R�Y�Y�:�z����r