--- title: StyleGAN v1 emoji: 🎨 colorFrom: blue colorTo: purple sdk: gradio sdk_version: "5.49.0" app_file: app.py python_version: "3.11" pinned: false license: mit --- # StyleGAN v1 – Image generation Generate images with your trained StyleGAN v1 generator. ## How to use 1. **Number of images**: Choose how many images to generate (1–16). 2. **Resolution**: Select output resolution (4 up to 256). 3. **Random seed** (optional): Set a seed for reproducible samples. 4. Click **Generate**. ## Adding your weights to this Space Your trained weights must be in this repo so the app can load them. ### Option A: Keras weights (recommended) 1. Save your generator in training with: ```python generator.save_weights("weights/generator.weights.h5") ``` 2. Create a `weights` folder in this repo and upload `generator.weights.h5` there. 3. Or push the file with Git LFS if it is large: ```bash git lfs install git lfs track "weights/*.h5" git add weights/generator.weights.h5 .gitattributes git commit -m "Add generator weights" git push ``` ### Option B: State checkpoint (gen_state) If your training script saves a checkpoint with `ema_trainable` and `non_trainable` (e.g. with `pickle`): 1. Save it as `weights/gen_state.pkl`. 2. Add the `weights` folder and `gen_state.pkl` to this repo (or use Git LFS for large files). ## Run locally ```bash pip install -r requirements.txt # Add your weights to weights/generator.weights.h5 (or weights/gen_state.pkl) gradio app.py ``` Open http://localhost:7860 in your browser. ## Project structure - `app.py` – Gradio UI and entrypoint for the Space - `inference.py` – Loads weights and runs generation - `loading_model.py` – Builds the StyleGAN generator - `layers.py` – Generator/discriminator layers - `configuration.py` – Resolutions and hyperparameters - `weights/` – Put your generator weights here