Team9. Taehyeok Ha, Kyoosik Lee, Hyeonbeen Park
This repository is extended research of Debiasing Vision-Language Models via Biased Prompts
The code has only been tested with the below environment and this all packages can downloaded by requirements.txt
- python=3.6
- torch=1.10.1
- PIL
- diffusers
- scikit-learn
- clip
- transformers
- CUDA 12.1
-
Create a python virtual environment using
venv
in current folder, e.g.,python -m venv myenv
-
Activate the virtual environment in current folder
source myenv/bin/activate
-
Install the specified packages, run
pip install -r requirements.txt
-
Change directory to
./generative
-
Run following or user customized commend, below commends is example
python main.py --cls Nurse --debias-method singleGender --lam 0 --preprompt A
python main.py --cls Florist --debias-method singleRace --lam 500 --preprompt A
python main.py --cls HollywoodActor --debias-method singleGender --lam 500 --preprompt A
python main.py --cls Nurse --debias-method pair --lam 500 --preprompt A
python main.py --cls Florist --debias-method multiple --multiple-param simple --lam 500 --preprompt A
python main.py --cls HollywoodActor --debias-method multiple --multiple-param composite --lam 500 --preprompt A
- This is detail explanation of flags
--cls
: Select the target class that user what to test for any job- e.g., Florist, HollywoodActor, Doctor
--lam
: Hyperparameter lambda of debiasing algorithm- high lambda value means high level debiasing
--debias_method
: Choice multi-vector or single-vectorsingleRace
singleGender
multiple --multiple-param composite
multiple --multiple-param simple
pair
--preprompt
: Type of prompt sentecesA
: "A photo of a"B
: "This is a"C
: "Photo cropped face of a"
- Experiments results(Image, ) will be shown in generative folder
Bias in Vision-Language Model (VLM) has been a long issue in the Artificial Intelligence community. An example of known biases are tendency towards certain gender, race, religion, etc. There are existing works to modify the embedding vector of a prompt to mitigate the bias. However, to the best of our knowledge, these works has focused on addressing only one type of bias at a time. Our work further extends this by mitigating multi-bias at the same time.
The code aims to remove the multi-bias of Stable Diffusion v2.1.
Keywords: Vision-Language pre-trained model, Debiasing, Ethical AI
Above image is generated by this code.
Figure shows the analysis of 3D visualization of embedding vectors
In general, debiasing method shows improved performance, compared to the previouse Stable Diffusion v2.1. Figure shows the comparison of Stable Diffusion, Reference method, and method of the job nurse. Stable Diffusion is known to have bias on White female. The results show that gender is almost correctly Notably, all three participants in study produced the same results for every test case, with no indiscernable case regarding race or gender. This indicates that method not only excels in producing balanced results but also generates distinguishable images.
We present an extended method for removing multi-bias method
- In general, our method remove the bias for gender and race at the same time
- Visualize the embedding vector space and explain why the quality of the image is lower