This repository is designed to be used as a HuggingFace Hub package for a RunPod GPU server.
RunPod server
-> download this HuggingFace repo
-> load pipeline.py
-> run rembg + Canny + ControlNet + SDXL + LoRA + quantization
-> expose the result through an API
HuggingFace stores the LoRA weights and pipeline code. The actual inference runs on RunPod.
Requirements
pip install -r requirements.txt
Download from HuggingFace and run locally/on RunPod
Use runpod_handler.py as the serverless entrypoint. The handler expects a base64-encoded image:
json
1{2"input":{3"image":"<base64 png or jpeg>",4"num_inference_steps":50,5"guidance_scale":7.5,6"controlnet_conditioning_scale":0.8,7"strength":0.75,8"quantize":true,9"n_colors":3210}11}
The response returns a base64-encoded PNG:
json
1{2"image":"<base64 png>",3"rembg_ok":true4}
Pipeline breakdown
Step
Tool
Role
Background removal
rembg
Isolates the subject on white background
Edge detection
OpenCV Canny (low=80, high=180)
Extracts silhouette for ControlNet
Shape preservation
diffusers/controlnet-canny-sdxl-1.0
Locks the original shape during generation
Style transfer
This LoRA
Applies pixel art style
Note: rembg and ControlNet are not included in this file. They are separate open-source tools loaded at inference time.
Tips
Works best on stuffed animals and character-shaped objects with clear silhouettes
If background removal fails, the pipeline automatically falls back to the original image
For more pixel-art-like results, apply color quantization after generation: