CoolFace
Apppublic

ajsbsd/CyberRealistic-Pony

sourceHugging Facecreativeml-openrail-mupdated 3mo agoView on Hugging Face
26likes
App README

![Helped by Gemini](https://gemini.google.com)

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:

PackageVersion
gradio==5.32.0
diffusers>=0.30.0
transformers>=4.40.0
accelerate>=0.33.0
torch>=2.0.0
Pillow>=9.0.0
spaceslatest

Usage

The app is designed to run on HuggingFace Spaces with ZeroGPU. It is not intended for local CPU-only use.

  1. 1.Open the Text to Image tab, enter a prompt and optional negative prompt
  2. 2.Adjust Steps (≤25 recommended to avoid ZeroGPU timeouts), CFG, width, height, and seed
  3. 3.Click Generate — the image and a downloadable PNG with embedded metadata will be returned
  4. 4.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_download and 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.GPU context, then immediately offloaded back to CPU with torch.cuda.empty_cache() after each inference call

Changelog

2025 — Code Quality Fixes

  • —`requirements.txt`: Fixed transformers version operator (<= → >=4.40.0), pinned gradio==5.32.0 to match sdk_version, added missing torch>=2.0.0, torchvision>=0.15.0, and Pillow>=9.0.0 dependencies
  • —`app.py`: Replaced deprecated tempfile.mktemp() with tempfile.NamedTemporaryFile(delete=False) to eliminate TOCTOU race condition
  • —`app.py`: Replaced torch.seed() with torch.randint(0, 2**32 - 1, (1,)).item() to prevent potential overflow in manual_seed()
  • —`app.py`: Added pipe.to("cpu") and torch.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-patches diffusers.loaders.single_file_utils.create_diffusers_clip_model_from_ldm at runtime to guard against the AttributeError: 'CLIPTextModel' object has no attribute 'text_model' crash caused by transformers>=4.44 flattening CLIPTextModel — diffusers<=0.38.0 still hard-codes the old attribute path