CoolFace
Apppublic

samH98/LungCancerDetection

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
hubconf.cpython-39.pyc47 linesDownload Raw Back to __pycache__
1a

2�t�c�
�@s�dZddlmZddlZddlmZddlmZmZddl	m3Z4ddlmZdd	gZ
eee�jd5dd�e�d
d�Zddd�Zddd�Zedkr�edd�ZddlZddlmZe�d�gZee�Ze��e��dS)zXPyTorch Hub models6 7Usage:8    import torch9    model = torch.hub.load('repo', 'model')10�)�PathN)�Model)�check_requirements�set_logging)�attempt_download)�
select_device�torch�yamlzrequirements.txt)ZpycocotoolsZthop)�excludec
11sz�ttt�jd�|�d���d}t|||�}|r�|�d�}t|�tj|t�	d�d�}|�12��|d���13�}	�fdd	�|	��D�}	|j
|	d14d�t|dj�|kr�|dj|_|r�|��}ttj��r�dnd�}15|�|16�WSt�y}zd
}t|�|�WYd}~n17d}~00dS)a%Creates a specified model18 19    Arguments:20        name (str): name of model, i.e. 'yolov7'21        pretrained (bool): load pretrained weights into the model22        channels (int): number of input channels23        classes (int): number of model classes24 25    Returns:26        pytorch model27    �cfgz.yamlrz.pt�cpu��map_location�modelcs&i|]\}}�|j|jkr||�qS�)�shape)�.0�k�v�Zmsdr�models\hubconf.py�28<dictcomp>+�zcreate.<locals>.<dictcomp>F)�strict�0z2Cache maybe be out of date, try force_reload=True.N)�listr�__file__�parent�rglobrrr�load�device�29state_dict�float�items�load_state_dict�len�names�	autoshaper�cuda�is_available�to�	Exception)
�name�30pretrained�channels�classesr'rr�fnameZckpt�csdr �e�srrr�creates("31r4�path/to/model.ptTcCs�t|t�rtj|t�d�d�n|}t|t�rB||�d�r<dnd}t|j��	t32|���j�}|�|�
����|j|_|r�|��}ttj��r�dnd�}|�	|�S)acustom mode33 34    Arguments (3 options):35        path_or_model (str): 'path/to/model.pt'36        path_or_model (dict): torch.load('path/to/model.pt')37        path_or_model (nn.Module): torch.load('path/to/model.pt')['model']38 39    Returns:40        pytorch model41    rr
Zemarr)�42isinstance�strrrr �dict�getrr	r*�next�43parametersr$r"r!r&r'rr(r))�
path_or_modelr'rZ	hub_modelr rrr�custom9s"44r=��PcCstd||||�S)N�yolov7)r4)r-r.r/r'rrrr@Qsr@�__main__z	yolov7.pt)r<)�Image)i�i�r>)r5T)Tr>r?T)�__doc__�pathlibrrZmodels.yolorZ
utils.generalrrZutils.google_utilsrZutils.torch_utilsr�dependenciesrrr4r=r@�__name__r�numpy�np�PILrB�zerosZimgs�results�print�saverrrr�<module>s(#454647