ajsbsd/CyberRealistic-Pony
26

CyberRealistic Pony Generator
A Gradio-based UI for running the CyberRealistic Pony SDXL model on HuggingFace Spaces with ZeroGPU support.
Supports Text-to-Image and Image-to-Image generation with EulerAncestral scheduling. Generated images are returned with embedded PNG metadata (prompt, seed, CFG, steps).
Requirements
See `requirements.txt`. Key dependencies:
Usage
The app is designed to run on HuggingFace Spaces with ZeroGPU. It is not intended for local CPU-only use.
- Open the Text to Image tab, enter a prompt and optional negative prompt
- Adjust Steps (≤25 recommended to avoid ZeroGPU timeouts), CFG, width, height, and seed
- Click Generate — the image and a downloadable PNG with embedded metadata will be returned
- Use the Image to Image tab to transform an existing image with a prompt and strength slider
Architecture Notes
- The model is downloaded once at startup via
hf_hub_downloadand loaded as a single-file SDXL checkpoint - Two isolated pipeline instances (
txt2img_pipe,img2img_pipe) share the same underlying model weights (UNet, VAE, text encoders) to minimise RAM usage - Each pipeline uses an independent
EulerAncestralDiscreteScheduler - Both pipelines are loaded onto CPU at startup and moved to CUDA only within a
@spaces.GPUcontext, then immediately offloaded back to CPU withtorch.cuda.empty_cache()after each inference call
Changelog
2025 — Code Quality Fixes
- `requirements.txt`: Fixed
transformersversion operator (<=→>=4.40.0), pinnedgradio==5.32.0to matchsdk_version, added missingtorch>=2.0.0,torchvision>=0.15.0, andPillow>=9.0.0dependencies - `app.py`: Replaced deprecated
tempfile.mktemp()withtempfile.NamedTemporaryFile(delete=False)to eliminate TOCTOU race condition - `app.py`: Replaced
torch.seed()withtorch.randint(0, 2**32 - 1, (1,)).item()to prevent potential overflow inmanual_seed() - `app.py`: Added
pipe.to("cpu")andtorch.cuda.empty_cache()after each inference call to release VRAM before the ZeroGPU context drops
2025 — Runtime Fix
- `app.py`: Added
_patch_diffusers_clip_compat()startup function that monkey-patchesdiffusers.loaders.single_file_utils.create_diffusers_clip_model_from_ldmat runtime to guard against theAttributeError: 'CLIPTextModel' object has no attribute 'text_model'crash caused bytransformers>=4.44flatteningCLIPTextModel—diffusers<=0.38.0still hard-codes the old attribute path
