2424 get_device_and_parallelism ,
2525 get_device_str ,
2626 get_model_dtype ,
27+ is_diffusion_model ,
2728 set_cuda_visible_devices ,
2829)
2930
@@ -113,6 +114,59 @@ def __init__(self, *args, **kwargs):
113114 help = "(for vllm) Custom vllm arguments in format: 'arg1=value1,arg2=value2'. "
114115 "Example: 'tensor_parallel_size=2,gpu_memory_utilization=0.9'" ,
115116 )
117+ # Diffusion model specific arguments
118+ diffusion_args = self .add_argument_group ("diffusion model arguments" )
119+ diffusion_args .add_argument (
120+ "--prompt_file" ,
121+ default = None ,
122+ type = str ,
123+ help = "File containing prompts for evaluation, one per line. "
124+ "Use this for batch evaluation with multiple prompts." ,
125+ )
126+ diffusion_args .add_argument (
127+ "--prompt" ,
128+ default = None ,
129+ type = str ,
130+ help = "Single prompt for quick testing. " "Overrides prompt_file if both are specified." ,
131+ )
132+ diffusion_args .add_argument (
133+ "--metrics" ,
134+ "--metric" ,
135+ default = "clip" ,
136+ help = "Evaluation metrics for generated images. "
137+ "'clip': CLIP score measuring text-image alignment. "
138+ "'clip-iqa': CLIP-based image quality assessment. "
139+ "'imagereward': Learned metric for image quality." ,
140+ )
141+ diffusion_args .add_argument (
142+ "--image_save_dir" ,
143+ default = "./tmp_image_save" ,
144+ type = str ,
145+ help = "Directory to save generated images during evaluation. " "Useful for visual inspection of results." ,
146+ )
147+ diffusion_args .add_argument (
148+ "--guidance_scale" ,
149+ default = 7.5 ,
150+ type = float ,
151+ help = "Classifier-free guidance scale for diffusion models. "
152+ "Higher values (7-20) make the model follow the prompt more closely. "
153+ "Lower values give more creative/random results." ,
154+ )
155+ diffusion_args .add_argument (
156+ "--num_inference_steps" ,
157+ default = 50 ,
158+ type = int ,
159+ help = "Number of denoising steps in the diffusion process. "
160+ "More steps (50-100) usually give better quality but take longer. "
161+ "Fewer steps (10-30) are faster but lower quality." ,
162+ )
163+ diffusion_args .add_argument (
164+ "--generator_seed" ,
165+ default = None ,
166+ type = int ,
167+ help = "Random seed for image generation reproducibility. "
168+ "Using the same seed produces identical results across runs." ,
169+ )
116170
117171
118172def _eval_init (tasks , model_path , device , disable_trust_remote_code = False , dtype = "auto" ):
@@ -134,6 +188,13 @@ def eval(args):
134188 "lm_eval>=0.4.2" , "lm-eval is required for evaluation, please install it with `pip install 'lm-eval>=0.4.2'`"
135189 )
136190
191+ if is_diffusion_model (args .model ):
192+ from auto_round .eval .evaluation import evaluate_diffusion_model
193+ from auto_round .utils import diffusion_load_model
194+
195+ pipe , _ = diffusion_load_model (args .model )
196+ evaluate_diffusion_model (args , pipe = pipe )
197+ return
137198 if args .eval_backend == "vllm" :
138199 assert isinstance (args .model , str ), "vllm evaluation only supports model name or path."
139200 eval_with_vllm (args )
0 commit comments