Team Ai
Apppublic

David310/Detect_AI-generated_Image

sourceHugging Faceupdated 2y agoView on Hugging Face
4likes
base_options.cpython-38.pyc35 linesDownload Raw Back to __pycache__
1U

2��^f�@s2ddlZddlZddlZddlZGdd�d�ZdS)�Nc@s6eZdZdd�Zdd�Zdd�Zdd�Zd
d3d�ZdS)�BaseOptionscCs4d|_dS)NF)�initialized)�self�r�</root/autodl-tmp/UniversalFakeDetect/options/base_options.py�__init__szBaseOptions.__init__cCs�|jddd�|jdtddd�|jdd	d5�|jddd�|jd
tdd�|jddd�|jdtdd�|jddd�|jddd�|jdddd�|jdddd�|jdddd�|jddd d�|jd!d"d#d�|jd$td%d&d�|jd'd	d6�|jd(td)d*d�|jd+td)d,d�|jd-td.d/d�|jd0td1d2d�|jd3td4d5d�|jd6d7td8d9�|jd:td;d<d�|jd=d	d>d?�|jd@tdAdBd�|jdCd	dDd?�|jdEtdFdGd�|jdHtdIdJd�|jdKdLtdMd9�dN|_|S)ONz--mode�binary)�defaultz--archZres50zsee my_models/__init__.py)�typer	�helpz--fix_backbone�7store_true)�actionz--rz_interp�bilinearz--blur_probg�?)r8r	z9--blur_sigz0.0,3.0z10--jpg_probz--jpg_methodzcv2,pilz11--jpg_qualz30,100z--real_list_pathzponly used if data_mode==ours: path for the list of real images, which should contain train.pickle and val.pickle)r	rz--fake_list_pathzponly used if data_mode==ours: path for the list of fake images, which should contain train.pickle and val.picklez--wang2020_data_pathzIonly used if data_mode==wang2020 it should contain train and test foldersz--data_mode�ourszwang2020 or oursz--data_label�trainz3label to decide whether train or validation datasetz--weight_decaygzloss weight for l2 regz--class_balz--batch_size�zinput batch sizez12--loadSizezscale images to this sizez13--cropSize��zthen crop to this sizez	--gpu_ids�0z+gpu ids: e.g. 0  0,1,2, 0,2. use -1 for CPUz--nameZexperiment_namezDname of the experiment. It decides where to store samples and modelsz
--num_threads�z# threads for loading data)r	r14rz--checkpoints_dirz
./checkpointszmodels are saved herez--serial_batcheszMif true, takes images in order to make batches, otherwise takes them randomly)r
rz--resize_or_cropZscale_and_cropzhscaling and cropping of images at load time [resize_and_crop|crop|scale_width|scale_width_and_crop|none]z	--no_flipz:if specified, do not flip the images for data augmentationz--init_type�normalz9network initialization [normal|xavier|kaiming|orthogonal]z--init_gaing{�G�z�?z1scaling factor for normal, xavier and orthogonal.z--suffix�zTcustomized suffix: opt.name = opt.name + suffix: e.g., {model}_{netG}_size{loadSize}T)�add_argument�str�float�intr)r�parserrrr�15initializes>zBaseOptions.initializecCs8|jstjtjd�}|�|�}|��\}}||_|��S)N)�formatter_class)r�argparse�ArgumentParser�ArgumentDefaultsHelpFormatterr�parse_known_argsr�16parse_args)rr�opt�_rrr�gather_options1s�17zBaseOptions.gather_optionsc18	Cs�d}|d7}tt|����D]F\}}d}|j�|�}||krHdt|�}|d�t|�t|�|�7}q|d7}t|�tj	�19|j|j�}t
�|�tj	�20|d�}t|d��}	|	�|�|	�d�W5QRXdS)	Nrz*----------------- Options ---------------21z	[default: %s]z{:>25}: {:<30}{}22z)----------------- End -------------------zopt.txt�wt�23)�sorted�vars�itemsr�get_defaultr�format�print�os�path�join�checkpoints_dir�name�utilZmkdirs�open�write)24rr#�message�k�v�commentr	Zexpr_dir�	file_nameZopt_filerrr�
print_options>s 2526zBaseOptions.print_optionsTcCsN|��}|j|_|jrF|jdkr6d|jjft|��nd}|j||_|rT|�|�|j�d�}g|_|D] }t	|�}|dkrj|j�27|�qjt|j�dkr�tj
�|jd�|j�d�|_dd�|j�d�D�|_|j�d�|_dd�|j�d�D�|_t|j�dk�r*tt|jd|jd	d	��|_nt|j�dk�rBtd28��||_|jS)Nrr$�,rcSsg|]}t|��qSr)r��.0�srrr�29<listcomp>lsz%BaseOptions.parse.<locals>.<listcomp>cSsg|]}t|��qSr)rr=rrrr@ns��z1Shouldn't have more than 2 values for --jpg_qual.)r%�isTrain�suffixr,r)r2r;�gpu_ids�splitr�append�len�torch�cuda�30set_device�	rz_interp�blur_sig�31jpg_method�jpg_qual�list�range�32ValueErrorr#)rr;r#rDZstr_idsZstr_id�idrrr�parseRs2$33"zBaseOptions.parseN)T)�__name__�34__module__�__qualname__rrr%r;rTrrrrrs35&
r)rr.r3rIrrrrr�<module>s