RichardErkhov commited on
Commit
583e4a6
·
verified ·
1 Parent(s): 35b8eef

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +108 -0
README.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ bloom-560m-RLHF-SD2-prompter - bnb 4bits
11
+ - Model creator: https://huggingface.co/crumb/
12
+ - Original model: https://huggingface.co/crumb/bloom-560m-RLHF-SD2-prompter/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ license: bigscience-bloom-rail-1.0
20
+ tags:
21
+ - stable-diffusion
22
+ - diffusion
23
+ model-index:
24
+ - name: bloom-560m-RLHF-SD2-prompter
25
+ results: []
26
+
27
+ datasets:
28
+ - Gustavosta/Stable-Diffusion-Prompts
29
+
30
+ widget:
31
+ - text: "<s>Prompt: "
32
+
33
+ inference:
34
+ parameters:
35
+ eos_token_id: 2
36
+ max_length: 128
37
+ do_sample: true
38
+ ---
39
+
40
+ # BLOOM-560m RLHF SD2 Prompter
41
+
42
+ **COLAB DEMO INCLUDING STABLE DIFFUSION: https://colab.research.google.com/github/aicrumb/doohickey/blob/main/rlhf_prompt_tuner.ipynb**
43
+
44
+ Using RLHF (Reinforcement Learning from Human Feedback) to finetune [mrm8488/bloom-560m-finetuned-sd-prompts](https://hf.co/mrm8488/bloom-560m-finetuned-sd-prompts) further for SD2.0
45
+
46
+ ```
47
+ batch_size = 16
48
+ learning_rate = 0.001 # this is why I didn't have to spend _forever_ on it
49
+ ```
50
+
51
+ Generate extension with "\<s>Prompt: " and whatever your normal prompt is.
52
+
53
+ I did this myself. I sat down and just ranked images for so long. It's gone through a couple iterations. Only the biases and layernorm weights were trained. The commit messages are a MESS. **First iteration of this project**
54
+
55
+ donate so i can do this on real hardware : https://github.com/aicrumb/aicrumb/blob/main/README.md
56
+
57
+ ## Example usage
58
+
59
+ ```python
60
+ # Install libraries needed to run the models
61
+ !pip install transformers diffusers accelerate -qq
62
+
63
+ # Import the libraries
64
+ from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
65
+ from transformers import pipeline
66
+ import torch
67
+
68
+ # This is the model that the transformer was finetuned to generate prompts for
69
+ model_id = "stabilityai/stable-diffusion-2-base"
70
+
71
+ # Use the Euler scheduler here
72
+ scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
73
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16)
74
+ pipe = pipe.to("cuda")
75
+
76
+ # Load the transformer model
77
+ prompt_pipe = pipeline("text-generation", model="crumb/bloom-560m-RLHF-SD2-prompter")
78
+ prompt = "cool landscape"
79
+
80
+ # Auto-complete prompt
81
+ prompt = "<s>Prompt: " + prompt + ","
82
+ extended_prompt = prompt_pipe(prompt, do_sample=True, max_length=42)[0]['generated_text']
83
+ extended_prompt = extended_prompt[10:]
84
+ print("Prompt is now: ", extended_prompt)
85
+
86
+ # Generate image
87
+ image = pipe(extended_prompt).images[0]
88
+
89
+ image.save("output.png")
90
+ image
91
+ ```
92
+ *Prompt is now: cool landscape, concept art*
93
+ ![](https://cdn.discordapp.com/attachments/1010693530181718146/1047831482808406067/image.png)
94
+
95
+ *Prompt is now: cool landscape, concept art, sharp focus, digital painting*
96
+ ![](https://cdn.discordapp.com/attachments/1010693530181718146/1047832480335536249/image.png)
97
+
98
+ short additions, they work though I guess (results vary)
99
+
100
+ It's also very good at generating prompts by itself, with just the "Prompt:" prompt.
101
+
102
+ *\<s>Prompt: 1 0 th century, highly detailed, concept art, cinematic lighting, unreal engine, trending on artstation, artstation hd, artstation hq, very very detailed*
103
+ ![](https://cdn.discordapp.com/attachments/1010693530181718146/1047843202050310174/image.png)
104
+
105
+ Further testing to be done in this area (automated training with aesthetic predicting models, larger data collection about prompt scores, better training in general)
106
+
107
+ Also, enjoy this graphic I had to make myself because I kept being indecisive of the reward methodology ![](https://cdn.discordapp.com/attachments/1010693530181718146/1047846272096292925/image.png)
108
+