A men-only SD Webui Guide to running BroGAN
Want unique, highly-detailed (over 4 BILLION) hot guys with just a click of a button? Wish there was a thispersondoesnotexist.com but for men? Then BroGAN is for you!
Introduction to StyleGAN
- StyleGAN (developed from NV Labs) stands for Generative Adversarial Networks, or GAN for short. It is very effective at generating large high-quality but diverse images.
- It's an image generator on its own and is 100% separate from Stable Diffusion
- If you've ever been to thispersondoesnotexist.com, you have used StyleGAN.
- They are hard to control (there is no prompt) but excel at generating high quality diverse images with a single button click
Introduction to BroGAN
- StyleGAN uses checkpoints, just like Stable Diffusion
- BroGAN is a StyleGAN model that was trained to generate attractive male faces.
- It was trained using a database of 50k faces scraped from pinterest
- See the banner above for sample output
Installation Instructions
Note: This installation was tested on stable-diffusion-webui-forge on Windows with an Nvidia GPU
A) Installing SD Webui Forge
- Install stable-diffusion-webui-forge using one-click installations (easiest setup)
- Unzip installation package (e.g.
webui_forge_cu121_torch21
)
B) Installing the sd-webui-gan-generator extension
- Start stable-diffusion-webui-forge via
run.bat
- After starting the gui, navigate to
extensions
tab and clickInstall from URL
- Place https://github.com/zerxiesderxies/sd-webui-gan-generator/ under URL for extension's git repository and Install
(If you get the error:Extension directory already exists
, addsd-webui-gan-generator
to Local directory name - Under
Installed
tab clickApply and Restart UI
- After reloading sd-webui-forge, you should see a new
GAN Generator
tab appear - Exit sd-webui-forge
C) NEW: node for ComfyUI!
clone this into custom_nodes directory: ComfyUI-StyleGan
D) Downloading the BroGAN v1.0.0 Checkpoint
- Navigate to the BroGANv1.0.0 HuggingFace repository
- Download
BroGANv1.0.0.pkl
- Place the checkpoint .pkl file in your
extensions\sd-webui-gan-generator\models
folder
- Note: You can also download any StyleGAN2 or StyleGAN3 checkpoint to use with this extension:
How-To Guides
NOTE: StyleGAN2/3 pretrained checkpoints (pickles) contain additional classes (e.g. torch_utils) that are not compatible with stable-diffusion-webui's pickle scanner. You will need to set --disable-safe-unpickle
in order to load them.
WARNING: Setting --disable-safe-unpickle
turns off the safe pickle check and exposes sd-webui to malicious code hidden in other pickle files. Use at your own risk. Please verify the integrity of your .pkl files before using. I promise BroGAN has no viruses!
TODO: finding a workaround...
AA) Simple Generation Guide
AA1) Generating Your First Bro Using CPU
- Inside the webui folder in Windows, modify
webui-user.bat
and add--disable-safe-unpickle
toCOMMANDLINE_ARGS
- Start
webui-user.bat
- Navigate to
GAN Generator
tab - Under model selection, select
BroGANv1.0.0.pkl
from the drop down menu. Click refresh to update the model list. - Under
generation device
, selectcpu
for now - Under
Image Padding Factor
, leave at1.5
- The
Simple Image Gen
tab handles basic seed to image generation. - Under
seed,
set it to0
- Under
truncation psi
, keep it at0.7
- Click
Generate Simple Image
and wait until image appears onResults
section:
a) This will initate the StyleGAN3 image generation process on the cpu. Please be patient. Depending on speed it can take 10-30 seconds.
b) You will now see our handsome bloke namedBro 0
show up on theResults
section, like below:
AA2) Generating Faster Bros Using GPU
Prerequisites - StyleGAN requires additional custom-built cuda plugins to run. If you have a cuda enabled card installed with Python 3.10 and Cuda 12.1, these plugin binaries have been included out of the box. If you have a different cuda or python version, it may still work, but at this moment has not been tested.
- Under
generation device
, selectcuda:0
to select image generator using your primary GPU - Click
Generate Simple Image
and wait for the torch_utils libraries to be loaded.
a)bias_act_plugin
b)filtered_lrelu_plugin
- In the sd-webui command window you should see the following:
- You know you're using CUDA if these bros generate in tenths of a second.
NOTE: If you see Module not found. Proceeding with build...
that means the plugins could not be loaded, and you must build from scratch. This is very involved (guide not available). You could always keep generating with cpu.
AA3) Generating More Bros
- Each seed is an integer that represents a different face. For example each time you reload thispersondoesnotexist, you get a new seed.
- You can pick a value between 0 and 4294967295
- You can also check
Random Seed
to have it automatically pick a random seed after you click Generate
AA4) Definition of Simple Gen Tab Parameters
Here is a description of each of the parameters used in Simple Gen.
Seed:
Integer input to create the latent vector. Each seed represents an image. Range of 32-bit unsigned integer (0 to 2^32-1).Truncation psi:
A float that represents how much to deviate from the global average (1 = no truncation, 0 = global average). Higher values will be more diverse but with worse quality.
BB) Style-Mixing Guide
In Work. You can go to https://github.com/zerxiesderxies/sd-webui-gan-generator as there's some documentation there.
CC) Bringing your BroGAN characters to life using IP Adapter/FaceSwapLab
In Work. Because the faces are closeups, padding them seems to help with results.
DD)
Close-Out
Hope this guide works out for you and is easy enough to follow.
Though there are over 4 billion men, you'll start seeing similar dudes eventually since this was trained on only 50k images.
Good luck and have fun making AI Bros! I'd love to see your creations as even working on this for hundreds of hours I haven't seen even a 0.001% of the dudes waiting inside this model.
-ZerxiesDerxies
Credits
Credits to NVLabs and tocantrell. This is my first gradio project and a beginner in ML/AI, so take this with a grain of salt.
License
MIT License
Please don't hesitate to give credit as developing extensions takes effort :)
Copyright (c) 2024 zerxiesderxies
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.