Downloads · 30 days
111
2% of all-time downloads
bghira/pseudo-flex-base
pseudo-flex-base is a text-to-image model from bghira. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as creativeml-openrail-m.
stable-diffusion-2-1 (stabilityai/stable-diffusion-2-1) finetuned with different aspect ratios, into a photography model (ptx0/pseudo-real-beta).
Downloads · 30 days
111
2% of all-time downloads
All-time downloads
7.2K
Public
Parameters
866M
31 GB on disk
Likes
10
Public
Click a slice to open those files.
.safetensors12.9 GB · 100%
From the Hugging Face model README

stable-diffusion-2-1 (stabilityai/stable-diffusion-2-1) finetuned with different aspect ratios, into a photography model (ptx0/pseudo-real-beta).
Seed: 2695929547
Steps: 25
Sampler: DDIM, default model config settings
Version: Pytorch 2.0.1, Diffusers 0.17.1
Guidance: 9.2
Guidance rescale: 0.0
| resolution | model | stable diffusion | pseudo-flex | realism-engine |
|---|---|---|---|---|
| 753x1004 (4:3) | v2-1 | ![]() | ![]() | ![]() |
| 1280x720 (16:9) | v2-1 | ![]() | ![]() | ![]() |
| 1024x1024 (1:1) | v2-1 | ![]() | ![]() | ![]() |
| 1024x1024 (1:1) | v2-1 | ![]() | ![]() | ![]() |
The ptx0/pseudo-real-beta pretrained checkpoint had its unet trained for 4,200 steps and its text encoder trained for 15,600 steps at a batch size of 15 with 10 gradient accumulations, on a diverse dataset:
It has a diverse capability of photorealistic and adventure with strong prompt coherence. However, it lacks multi-aspect capability.
The code used to train pseudo-real-beta did not have aspect bucketing support. I discovered pseudo-flex-base by @ttj, which supported theories I had.
I added thorough aspect bucketing support to my training loop dataloader by having it throw away any image under 1024x1024, and condition all images so that the smaller side of the image is 1024. The aspect ratio of the image is used to determine the new length of the other dimension, eg. used as a multiple for landscape or a divisor for portrait mode.
All batches have image of the same resolution. Different resolutions at the same aspect are all conditioned to 1024x... or ...x1024. A 1920x1080 image becomes approx 1820x1024.
This model, pseudo-flex-base was created by fine-tuning the base stabilityai/stable-diffusion-2-1 768 model on its frozen text encoder, for 1000 steps on 148,000 images from LAION HD using the TEXT field as their caption.
The batch size was effectively 150 again. Batch size of 15 with 10 accumulations. This is very slow at very high resolutions, an aspect ratio of 1.5-1.7 will cause this to take about 700 seconds per iter on an A100 80G.
This training took two days.
At 1000 steps, the text encoder from ptx0/pseudo-real-beta was used experimentally with this model's unet in an attempt to resolve some residual image noise, eg. pixelation. That worked!
The training was restarted from ckpt 1000 with this text encoder.
Validation prompts began to "pull together" from 1300 to 2950 steps. Some checkpoints show regression, but these usually resolve in about 100 steps. Improvements were always present, despite regresions.
As training has been going on for some time now on 148,000 images at a batch size of 150 over 3000 steps, images began to degrade. This is presumably due to having completed 3 repeats on all images in the set, and that's IF all images in the set had been used. Considering some of the image filters discarded about 50,000 images, we landed at 9 repeats per image on our super low learning rate.
This caused two issues:
Ergo, at 1300 steps, the decision was made to cease training on the original LAION HD dataset, and instead, train on a new freshly-retrieved subset of high-resolution Midjourney v5.1 data.
This consisted of 17,800 images at a base resolution of 1024x1024, with about 700 samples in portrait and 700 samples in landscape.
As the checkpoint 3275 was tested, a common observation was that darker images were washed out, and brighter images seemed "meh".
Various CFG rescale and guidance levels were tested, with the best dark images occurring around guidance_scale=9.2 and guidance_rescale=0.0 but they remained "washed out".
A new LAION subset was prepared with unique images and no square images - just a limited collection of aspect ratios:
This was intended to speed up the understanding of the model, and prevent overfitting on captions.
This LAION subset contained 17,800 images, evenly distributed through aspect ratios.
The images were then captioned using T5 Flan with BLIP2, to obtain highly accurate results.
Offset noise and SNR gamma were applied experimentally to the checkpoint 4250:
snr_gamma=5.0noise_offset=0.2noise_pertubation=0.1Within 25 steps of training, the contrast was back, and the prompt a solid black square once again produced a reasonable result.
At 50 steps of offset noise, things really seemed to "click" and a solid black square had the fewest deformities I've seen.
Step 75 checkpoint was broken. The SNR gamma math results in numeric instability and was disabled. The offset noise parameters were untouched.
Similar to the text encoder swap, the images showed a marked improvement over the next several checkpoints.
It was left to its own devices, and at step 4475, enough improvement was observed that another revision in this repository was created.
This model has been packaged up in a test form so that it can be thoroughly assessed by users.
For usage, see - How to Get Started with the Model
Generated images looks like they are cropped from a larger image.
Generating non-square images creates weird results, due to the model being trained on square images.
For 1:1 aspect ratio, it's fine-tuned at 1024x1024, although ptx0/pseudo-real-beta that it was based on, was last finetuned at 768x768.
stable-diffusion-2-1 (stabilityai/stable-diffusion-2-1 and ptx0/pseudo-real-beta) finetuned for dynamic aspect ratios.
finetuned resolutions:
| width | height | aspect ratio | images | |
|---|---|---|---|---|
| 0 | 1024 | 1024 | 1:1 | 90561 |
| 1 | 1536 | 1024 | 3:2 | 8716 |
| 2 | 1365 | 1024 | 4:3 | 6933 |
| 3 | 1468 | 1024 | ~3:2 | 113 |
| 4 | 1778 | 1024 | ~5:3 | 6315 |
| 5 | 1200 | 1024 | ~5:4 | 6376 |
| 6 | 1333 | 1024 | ~4:3 | 2814 |
| 7 | 1281 | 1024 | ~5:4 | 52 |
| 8 | 1504 | 1024 | ~3:2 | 139 |
| 9 | 1479 | 1024 | ~3:2 | 25 |
| 10 | 1384 | 1024 | ~4:3 | 1676 |
| 11 | 1370 | 1024 | ~4:3 | 63 |
| 12 | 1499 | 1024 | ~3:2 | 436 |
| 13 | 1376 | 1024 | ~4:3 | 68 |
Other aspects were in smaller buckets. It could have been done more succinctly or carefully, but careless handling of the data was a part of the experiment parameters.
All pre-processing is done via the scripts in bghira/SimpleTuner on GitHub.
Dataset size: 100k image-caption pairs, after filtering.
Hardware: 1 A100 80G GPUs
Optimizer: 8bit Adam
Batch size: 150
Learning rate: Constant 4e-8 which was adjusted by reducing batch size over time.
Training steps: WIP (ongoing)
Training time: approximately 4 days (so far)
More information needed
pseudoterminal
Use the code below to get started with the model.
# Use Pytorch 2!
import torch
from diffusers import StableDiffusionPipeline, DiffusionPipeline, AutoencoderKL, UNet2DConditionModel, DDPMScheduler
from transformers import CLIPTextModel
# Any model currently on Huggingface Hub.
model_id = 'ptx0/pseudo-flex-base'
pipeline = DiffusionPipeline.from_pretrained(model_id)
# Optimize!
pipeline.unet = torch.compile(pipeline.unet)
scheduler = DDPMScheduler.from_pretrained(
model_id,
subfolder="scheduler"
)
# Remove this if you get an error.
torch.set_float32_matmul_precision('high')
pipeline.to('cuda')
prompts = {
"woman": "a woman, hanging out on the beach",
"man": "a man playing guitar in a park",
"lion": "Explore the ++majestic beauty++ of untamed ++lion prides++ as they roam the African plains --captivating expressions-- in the wildest national geographic adventure",
"child": "a child flying a kite on a sunny day",
"bear": "best quality ((bear)) in the swiss alps cinematic 8k highly detailed sharp focus intricate fur",
"alien": "an alien exploring the Mars surface",
"robot": "a robot serving coffee in a cafe",
"knight": "a knight protecting a castle",
"menn": "a group of smiling and happy men",
"bicycle": "a bicycle, on a mountainside, on a sunny day",
"cosmic": "cosmic entity, sitting in an impossible position, quantum reality, colours",
"wizard": "a mage wizard, bearded and gray hair, blue star hat with wand and mystical haze",
"wizarddd": "digital art, fantasy, portrait of an old wizard, detailed",
"macro": "a dramatic city-scape at sunset or sunrise",
"micro": "RNA and other molecular machinery of life",
"gecko": "a leopard gecko stalking a cricket"
}
for shortname, prompt in prompts.items():
# old prompt: ''
image = pipeline(prompt=prompt,
negative_prompt='malformed, disgusting, overexposed, washed-out',
num_inference_steps=32, generator=torch.Generator(device='cuda').manual_seed(1641421826),
width=1368, height=720, guidance_scale=7.5, guidance_rescale=0.3, num_inference_steps=25).images[0]
image.save(f'test/{shortname}_nobetas.png', format="PNG")