|
6 | 6 |
|
7 | 7 | 1. Open the `generate.py` file and locate the `--weight_path` parameter. Modify the path in the parameter to the path of your model weights, for example `/your/path/weight/model.pt`. |
8 | 8 |
|
9 | | -2. Set the necessary parameters such as `--conditional`, `--generate_name`, `--num_images`, `--num_classes`(**No need to set for models after version 1.1.4**), `--class_name`, `--image_size`, `--result_path`, etc. If no parameters are set, the default settings will be used. There are two ways to set the parameters: one is to directly modify the `parser` in the `if __name__ == "__main__":` section of the `generate.py` file, and the other is to use the following commands in the console while in the `/your/path/Defect-Diffusion-Model/tools` directory: |
| 9 | +2. Set the necessary parameters such as `--conditional`,`--latent`, `--generate_name`, `--num_images`, `--num_classes`(**No need to set for models after version 1.1.4**), `--class_name`, `--image_size`, `--result_path`, etc. If no parameters are set, the default settings will be used. There are two ways to set the parameters: one is to directly modify the `parser` in the `if __name__ == "__main__":` section of the `generate.py` file, and the other is to use the following commands in the console while in the `/your/path/Defect-Diffusion-Model/tools` directory: |
10 | 10 |
|
11 | 11 | **Conditional Generation Command (version > 1.1.1)** |
12 | 12 |
|
|
32 | 32 | python generate.py --generate_name df --num_images 8 --image_size 64 --weight_path /your/path/weight/model.pt --sample ddpm --network unet --act gelu |
33 | 33 | ``` |
34 | 34 |
|
| 35 | + **Conditional Latent Generation Command (version > 1.2.0)** |
| 36 | + |
| 37 | + ```bash |
| 38 | + python generate.py --conditional --latent --generate_name df --num_images 8 --class_name 0 --image_size 64 --weight_path /your/path/weight/model.pt --sample ddim --autoencoder_ckpt /your/path/weight/autoencoder_model.pt |
| 39 | + ``` |
| 40 | + |
| 41 | + **Unconditional Latent Generation Command (version > 1.2.0)** |
| 42 | + |
| 43 | + ```bash |
| 44 | + python generate.py --latent --generate_name df --num_images 8 --image_size 64 --weight_path /your/path/weight/model.pt --sample ddim --autoencoder_ckpt /your/path/weight/autoencoder_model.pt |
| 45 | + ``` |
| 46 | + |
35 | 47 | 3. Wait for the generation process to complete. |
36 | 48 |
|
37 | 49 | ##### Python generation |
@@ -65,20 +77,22 @@ for i in range(num_images): |
65 | 77 | > |
66 | 78 | > `--num_classes` do not need to set for models after **version 1.1.4** |
67 | 79 |
|
68 | | -| Parameter Name | Conditional | Usage | Type | Description | |
69 | | -| --------------- | :---------: | ------------------------------- | :--: | ------------------------------------------------------------ | |
70 | | -| --conditional | | Enable conditional generation | bool | If enabled, allows custom configuration, such as modifying classes or classifier-free guidance interpolation weights | |
71 | | -| --generate_name | | File name | str | File name to initialize the model for saving purposes | |
72 | | -| --image_size | | Input image size | int | Size of input images, adaptive input/output size. if class name is -1 and conditional is True, the model would output one image per class. | |
73 | | -| --image_format | | Generated image format | str | Generated image format, jpg/png/jpeg. Recommend to use png for better generation quality. | |
74 | | -| --num_images | | Number of generated images | int | Number of images to generate | |
75 | | -| --weight_path | | Path to model weights | str | Path to the model weights file, required for network generation | |
76 | | -| --result_path | | Save path | str | Path to save the generated images | |
77 | | -| --use_gpu | | Set the use GPU | int | Set the use GPU in generate, input is GPU's id | |
78 | | -| --sample | | Sampling method | str | Set the sampling method type, currently supporting DDPM and DDIM. **(No need to set for models after version 1.1.1)** | |
79 | | -| --network | | Training network | str | Set the training network, currently supporting UNet, CSPDarkUNet. **(No need to set for models after version 1.1.1)** | |
80 | | -| --act | | Activation function | str | Activation function selection. Currently supports gelu, silu, relu, relu6 and lrelu. If you do not set the same activation function as the model, mosaic phenomenon will occur. **(No need to set for models after version 1.1.1)** | |
81 | | -| --num_classes | ✓ | Number of classes | int | Number of classes for classification **(No need to set for models after version 1.1.1)** | |
82 | | -| --class_name | ✓ | Class name | int | Index of the class to generate images. if class name is `-1`, the model would output one image per class. | |
83 | | -| --cfg_scale | ✓ | Classifier-free guidance weight | int | Weight for classifier-free guidance interpolation, for better generation model performance | |
| 80 | +| Parameter Name | Conditional | Usage | Type | Description | |
| 81 | +| ------------------ | :---------: | ------------------------------- | :--: | ------------------------------------------------------------ | |
| 82 | +| --conditional | | Enable conditional generation | bool | If enabled, allows custom configuration, such as modifying classes or classifier-free guidance interpolation weights. | |
| 83 | +| --generate_name | | File name | str | File name to initialize the model for saving purposes. | |
| 84 | +| --latent | | Enable latent diffusion model | bool | If enabled, the model will use latent diffusion. | |
| 85 | +| --image_size | | Input image size | int | Size of input images, adaptive input/output size. if class name is -1 and conditional is True, the model would output one image per class. | |
| 86 | +| --image_format | | Generated image format | str | Generated image format, jpg/png/jpeg. Recommend to use png for better generation quality. | |
| 87 | +| --num_images | | Number of generated images | int | Number of images to generate. | |
| 88 | +| --weight_path | | Path to model weights | str | Path to the model weights file, required for network generation. | |
| 89 | +| --autoencoder_ckpt | | VAE model weight path | str | VAE model weight path. | |
| 90 | +| --result_path | | Save path | str | Path to save the generated images. | |
| 91 | +| --use_gpu | | Set the use GPU | int | Set the use GPU in generate, input is GPU's id. | |
| 92 | +| --sample | | Sampling method | str | Set the sampling method type, currently supporting DDPM and DDIM. **(No need to set for models after version 1.1.1)** | |
| 93 | +| --network | | Training network | str | Set the training network, currently supporting UNet, CSPDarkUNet. **(No need to set for models after version 1.1.1)** | |
| 94 | +| --act | | Activation function | str | Activation function selection. Currently supports gelu, silu, relu, relu6 and lrelu. If you do not set the same activation function as the model, mosaic phenomenon will occur. **(No need to set for models after version 1.1.1)** | |
| 95 | +| --num_classes | ✓ | Number of classes | int | Number of classes for classification. **(No need to set for models after version 1.1.1)** | |
| 96 | +| --class_name | ✓ | Class name | int | Index of the class to generate images. if class name is `-1`, the model would output one image per class. | |
| 97 | +| --cfg_scale | ✓ | Classifier-free guidance weight | int | Weight for classifier-free guidance interpolation, for better generation model performance. | |
84 | 98 |
|
0 commit comments