VersusDebias: Universal Zero-Shot Debiasing for Text-to-Image Models via SLM-Based Prompt Engineering and Generative Adversary
This repository is supplement material for the paper: VersusDebias: Universal Zero-Shot Debiasing for Text-to-Image Models via SLM-Based Prompt Engineering and Generative Adversary
-
Self-adaptive framework. Our generative adversarial mechanism (GAM) generates specialized attribute arrays for each prompt, diminishing the influence of hallucinations from T2I models.
-
Zero-shot capability. Our framework provides zero-shot debiasing capability and custom optimization for different prompts..
-
Universal application. VersusDebias can debias arbitrary models across multiple protected attributes simultaneously, including gender, race, and age.
In few-shot scenarios, the cosine similarity between generated image and ground truth increased 12.56% in Stable Difussion-v1, 13.18% in Stable Difussion-X, and 16.33% in PixArt
In zero-shot scenarios, the cosine similarity between generated image and ground truth increased 13.91% in Stable Difussion-v1, 13.12% in Stable Difussion-XL, and 16.32% in PixArt
conda create -n bigbench python=3.11pip install -r requirements.txt- download finetuned InternVL-4B and qwen1-5b, and put them into
./model
-
First, download finetuned InternVL-4B and qwen1-5b, and put them into
./model -
Second, change
modelingam.pyto your generator model. If your model is not on the list, you can changemodelto your model name mannually (make sure your workflow{model}.jsonis under./workflow). Changeserver_addressingam.pyto the address of your own Comfyui and run Comfyui independently. Changeepoch(default 5) to a quarter of the number of the original array (default 20) in./tools/orgin_array.py. Then, you may rungam.pyto use GAM. The results will be stored in./GAM_result. -
Third, change
modelinresult_select.pyto the generator model used in GAM and runresult_select.pyto select the best result of each prompt from GAM. The result will be stored in./GAM_result. -
Last, change
original_prompt_pathindgm.pyto the prompts (in .txt file) you want to debias. Changegenerator_modelto your generator model (notice that this generator model can be different to the one in GAM part). Changeground_truthto your ground truth path. Then you may rundgm.pyto generate the debiased prompts of your own prompts and the images based on these debiased prompts. The result will be stored in./promptand./Debiased_Image. -
Eval: If you want to evaluate our framework in few-shot or zero-shot scenarios, follow the instruction in
dgm.py,eval_align.pyandeval_result.pyto modify them. Then, run these three files in order ofdgm.py,eval_align.pyandeval_result.py. The result will be stored in./alignand./evaluate


