NYUAD-ComNets commited on
Commit
e0c0421
1 Parent(s): 1bb0b13

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -14
README.md CHANGED
@@ -12,24 +12,104 @@ tags:
12
  inference: true
13
  ---
14
 
15
- # LoRA text2image fine-tuning - NYUAD-ComNets/Middle_Eastern_Male_Profession_Model
16
 
17
- These are LoRA adaption weights for stabilityai/stable-diffusion-xl-base-1.0. The weights were fine-tuned on the NYUAD-ComNets/Middle_Eastern_Male_Profession dataset. You can find some example images in the following.
 
18
 
19
- ![img_0](./image_0.png)
20
- ![img_1](./image_1.png)
21
- ![img_2](./image_2.png)
22
- ![img_3](./image_3.png)
23
- ![img_4](./image_4.png)
24
- ![img_5](./image_5.png)
25
- ![img_6](./image_6.png)
26
- ![img_7](./image_7.png)
27
- ![img_8](./image_8.png)
28
- ![img_9](./image_9.png)
29
- ![img_10](./image_10.png)
30
- ![img_11](./image_11.png)
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  LoRA for the text encoder was enabled: False.
34
 
35
  Special VAE used for training: madebyollin/sdxl-vae-fp16-fix.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  inference: true
13
  ---
14
 
 
15
 
16
+ # Model description
17
+ LoRA text2image fine-tuning - NYUAD-ComNets/Middle_Eastern_Male_Profession_Model
18
 
19
+ These are LoRA adaption weights for stabilityai/stable-diffusion-xl-base-1.0. The weights were fine-tuned on the NYUAD-ComNets/Middle_Eastern_Male_Profession dataset.
20
+ You can find some example images.
 
 
 
 
 
 
 
 
 
 
21
 
22
+ prompt: a photo of a {profession}, looking at the camera, closeup headshot facing forward, ultra quality, sharp focus
23
+
24
+ # How to use this model:
25
+
26
+ ``` python
27
+
28
+
29
+ import torch
30
+ from compel import Compel, ReturnedEmbeddingsType
31
+ from diffusers import DiffusionPipeline
32
+
33
+ import random
34
+
35
+
36
+ negative_prompt = "cartoon, anime, 3d, painting, b&w, low quality"
37
+
38
+
39
+ models=["NYUAD-ComNets/Asian_Female_Profession_Model","NYUAD-ComNets/Black_Female_Profession_Model","NYUAD-ComNets/White_Female_Profession_Model",
40
+ "NYUAD-ComNets/Indian_Female_Profession_Model","NYUAD-ComNets/Latino_Hispanic_Female_Profession_Model","NYUAD-ComNets/Middle_Eastern_Female_Profession_Model",
41
+ "NYUAD-ComNets/Asian_Male_Profession_Model","NYUAD-ComNets/Black_Male_Profession_Model","NYUAD-ComNets/White_Male_Profession_Model",
42
+ "NYUAD-ComNets/Indian_Male_Profession_Model","NYUAD-ComNets/Latino_Hispanic_Male_Profession_Model","NYUAD-ComNets/Middle_Eastern_Male_Profession_Model"]
43
+
44
+ adapters=["asian_female","black_female","white_female","indian_female","latino_female","middle_east_female",
45
+ "asian_male","black_male","white_male","indian_male","latino_male","middle_east_male"]
46
+
47
+ pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", variant="fp16", use_safetensors=True, torch_dtype=torch.float16).to("cuda")
48
+
49
+
50
+ for i,j in zip(models,adapters):
51
+ pipeline.load_lora_weights(i, weight_name="pytorch_lora_weights.safetensors",adapter_name=j)
52
+
53
+
54
+ prof='doctor'
55
+
56
+
57
+ pipeline.set_adapters(random.choice(adapters))
58
+
59
+
60
+ compel = Compel(tokenizer=[pipeline.tokenizer, pipeline.tokenizer_2] ,
61
+ text_encoder=[pipeline.text_encoder, pipeline.text_encoder_2],
62
+ returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,
63
+ requires_pooled=[False, True],truncate_long_prompts=False)
64
+
65
+
66
+ conditioning, pooled = compel("a photo of a {}, looking at the camera, closeup headshot facing forward, ultra quality, sharp focus".format(prof))
67
+
68
+ negative_conditioning, negative_pooled = compel(negative_prompt)
69
+ [conditioning, negative_conditioning] = compel.pad_conditioning_tensors_to_same_length([conditioning, negative_conditioning])
70
+
71
+ image = pipeline(prompt_embeds=conditioning, negative_prompt_embeds=negative_conditioning,
72
+ pooled_prompt_embeds=pooled, negative_pooled_prompt_embeds=negative_pooled,
73
+ num_inference_steps=40).images[0]
74
+
75
+ image.save('/../../x.jpg')
76
+
77
+ ```
78
+
79
+
80
+ # Examples
81
+
82
+ | | | |
83
+ |:-------------------------:|:-------------------------:|:-------------------------:|
84
+ |<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_0.png"> | <img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_1.png">|<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_2.png">|
85
+ |<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_3.png"> | <img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_4.png">|<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_5.png">|
86
+ |<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_6.png"> | <img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_7.png">|<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_8.png">|
87
+ |<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_9.png"> | <img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_10.png">|<img width="500" alt="screen shot 2017-08-07 at 12 18 15 pm" src="./image_11.png">|
88
+
89
+
90
+
91
+
92
+ # Training data
93
+
94
+ NYUAD-ComNets/Middle_Eastern_Male_Profession dataset was used to fine-tune stabilityai/stable-diffusion-xl-base-1.0
95
+
96
+
97
+
98
+ # Configurations
99
 
100
  LoRA for the text encoder was enabled: False.
101
 
102
  Special VAE used for training: madebyollin/sdxl-vae-fp16-fix.
103
+
104
+
105
+
106
+ # BibTeX entry and citation info
107
+
108
+ ```
109
+ @misc{ComNets,
110
+ url={[https://huggingface.co/NYUAD-ComNets/Middle_Eastern_Male_Profession_Model](https://huggingface.co/NYUAD-ComNets/Middle_Eastern_Male_Profession_Model)},
111
+ title={Middle_Eastern_Male_Profession_Model},
112
+ author={Nouar AlDahoul, Talal Rahwan, Yasir Zaki}
113
+ }
114
+ ```
115
+