xfusion is a Python library specializing in assembling open-source AI models, with a particular focus on models like Stable Diffusion, Flux, and others.
- Enhanced support for models from sources outside Hugging Face.
- Simple and efficient model loading using just a model URL.
- Extension for models.
- Multiple GPUs support.
- Stable Diffusion 1.5/2/3/3.5/XL
- Flux
pip install -q git+https://github.com/CyberVy/xfusion.git
or
curl -fsSL https://github.com/CyberVy/xfusion/raw/refs/heads/main/install.sh | bash
Qucik start with bash
curl -Lso start.py "https://github.com/CyberVy/xfusion/raw/refs/heads/main/start.py"
export CIVITAI_TOKEN=""
export HF_HUB_TOKEN=""
export TG_TOKEN=""
export TG_ID=""
export MODEL_VERSION=""
python start.py
Jupyter Notebook
import os
os.environ["CIVITAI_TOKEN"] = ""
os.environ["HF_HUB_TOKEN"] = ""
os.environ["TG_TOKEN"] = ""
os.environ["TG_ID"] = ""
os.environ["DOWNLOAD_PATH"] = ""
os.environ["MODEL_VERSION"] = ""
import os
from xfusion import load_enhancer
from xfusion import load_stable_diffusion_ui,load_flux_ui
from xfusion.const import GPU_COUNT
telegram_kwargs = {"token":os.environ.get("TG_TOKEN",""),"chat_id":os.environ.get("TG_ID","")}
download_kwargs = {"directory":os.environ.get("DOWNLOAD_PATH","/xfusion_models")}
pipelines = [load_enhancer(None,model_version=os.environ.get("MODEL_VERSION",""),download_kwargs=download_kwargs,telegram_kwargs=telegram_kwargs) for i in range(GPU_COUNT)]
if os.environ.get("MODEL_VERSION","") in ["", "1.5", "2", "3", "3.5", "xl", "sdxl", "pony"]:
server = load_stable_diffusion_ui(pipelines,_globals=globals(),pwa=True)
elif os.environ.get("MODEL_VERSION","") in ["flux"]:
server = load_flux_ui(pipelines,_globals=globals(),pwa=True)
Directly use a pipeline in the backend
Code
from xfusion.enhancement import load_enhancer
import torch
telegram_kwargs = {"token":"","chat_id":""}
download_kwargs = {"directory":"./xfusion_models"}
model = "https://civitai.com/api/download/models/646523?type=Model&format=SafeTensor&size=pruned&fp=fp16"
pipeline = load_enhancer(model,model_version="xl", download_kwargs=download_kwargs, telegram_kwargs=telegram_kwargs).to("cuda")
prompt = """
young white woman with dramatic makeup resembling a melted clown, deep black smokey eyes, smeared red lipstick, and white face paint streaks, wet hair falling over shoulders, dark and intense aesthetic, fashion editorial style, aged around 20 years, inspired by rick genest's zombie boy look, best quality
"""
negative_prompt = """
bad hands, malformed limbs, malformed fingers, bad anatomy, fat fingers, ugly, unreal, cgi, airbrushed, watermark, low resolution
"""
num_inference_steps = 30
guidance_scale = 2
clip_skip = 0
seed = 13743883683399229202
width = None
height = None
images = pipeline(prompt=prompt,negative_prompt=negative_prompt,generator=torch.Generator(pipeline.device).manual_seed(seed),width=width,height=height,num_inference_steps=num_inference_steps,guidance_scale=guidance_scale,clip_skip=clip_skip).images
Xfusion leverages the Diffusers library and is inspired by the incredible work of the open-source community.