Update README.md
Browse files
README.md
CHANGED
@@ -22,4 +22,42 @@ inference:
|
|
22 |
|
23 |
# BLOOM-560m RLHF SD2 Prompter Aesthetic
|
24 |
|
25 |
-
This is a further finetuned version of [crumb/bloom-560m-RLHF-SD2-prompter](https://hf.co/crumb/bloom-560m-RLHF-SD2-prompter) to optimize for aesthetic score with models from https://github.com/crowsonkb/simulacra-aesthetic-models instead of me hand scoring each image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# BLOOM-560m RLHF SD2 Prompter Aesthetic
|
24 |
|
25 |
+
This is a further finetuned version of [crumb/bloom-560m-RLHF-SD2-prompter](https://hf.co/crumb/bloom-560m-RLHF-SD2-prompter) to optimize for aesthetic score with models from https://github.com/crowsonkb/simulacra-aesthetic-models instead of me hand scoring each image
|
26 |
+
|
27 |
+
donate so i can do this on real hardware : https://github.com/aicrumb/aicrumb/blob/main/README.md
|
28 |
+
|
29 |
+
## Example usage
|
30 |
+
|
31 |
+
```python
|
32 |
+
# Install libraries needed to run the models
|
33 |
+
!pip install transformers diffusers accelerate -qq
|
34 |
+
|
35 |
+
# Import the libraries
|
36 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
37 |
+
from transformers import pipeline
|
38 |
+
import torch
|
39 |
+
|
40 |
+
# This is the model that the transformer was finetuned to generate prompts for
|
41 |
+
model_id = "stabilityai/stable-diffusion-2-base"
|
42 |
+
|
43 |
+
# Use the Euler scheduler here
|
44 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
45 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16)
|
46 |
+
pipe = pipe.to("cuda")
|
47 |
+
|
48 |
+
# Load the transformer model
|
49 |
+
prompt_pipe = pipeline("text-generation", model="crumb/bloom-560m-RLHF-SD2-prompter")
|
50 |
+
prompt = "cool landscape"
|
51 |
+
|
52 |
+
# Auto-complete prompt
|
53 |
+
prompt = "<s>Prompt: " + prompt + ","
|
54 |
+
extended_prompt = prompt_pipe(prompt, do_sample=True, max_length=42)[0]['generated_text']
|
55 |
+
extended_prompt = extended_prompt[10:]
|
56 |
+
print("Prompt is now: ", extended_prompt)
|
57 |
+
|
58 |
+
# Generate image
|
59 |
+
image = pipe(extended_prompt).images[0]
|
60 |
+
|
61 |
+
image.save("output.png")
|
62 |
+
image
|
63 |
+
```
|