Skywork / UniPic2-SD3.5M-Kontext-GRPO-2B

huggingface.co
Total runs: 18
24-hour runs: 0
7-day runs: 6
30-day runs: 1
Model's Last Updated: September 08 2025
any-to-any

Introduction of UniPic2-SD3.5M-Kontext-GRPO-2B

Model Details of UniPic2-SD3.5M-Kontext-GRPO-2B

🌌 UniPic2-SD3.5M-Kontext-GRPO-2B
Skywork Logo

GitHub Repo GitHub Stars GitHub Forks

📖 Introduction

UniPic2-SD3.5M-Kontext-GRPO-2B is a post-trained grpo version T2I model built on the UniPic2-SD3.5M-Kontext-2B, with enhanced text rendering. It excels at text-to-image generation and image editing, delivering high quality at fast speeds, and runs smoothly on a single 16 GB consumer GPU.

Model Teaser
📊 Benchmarks
Model eval
🧠 Usage
1. Clone the Repository
git clone https://github.com/SkyworkAI/UniPic
cd UniPic-2
2. Set Up the Environment
conda create -n unipic python=3.10
conda activate unipic
pip install -r requirements.txt
3.Text-to-Image Generation
import torch
from PIL import Image
from unipicv2.pipeline_stable_diffusion_3_kontext import StableDiffusion3KontextPipeline
from unipicv2.transformer_sd3_kontext import SD3Transformer2DKontextModel
from diffusers import FlowMatchEulerDiscreteScheduler, AutoencoderKL, BitsAndBytesConfig
from transformers import CLIPTextModelWithProjection, CLIPTokenizer, T5EncoderModel, T5TokenizerFast

# Load model components
pretrained_model_name_or_path = "/mnt/datasets_vlm/chris/hf_ckpt/Unipic2-t2i"
# int4 is recommended for inference:lower VRAM with no quality loss  {"int4", "fp16"} 
quant = "int4"  

# BitsAndBytes config
bnb4 = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_use_double_quant=True,         
    bnb_4bit_quant_type="nf4",              
    bnb_4bit_compute_dtype=torch.bfloat16, 
)
bnb8 = BitsAndBytesConfig(load_in_8bit=True)

if quant == "int4":
    transformer = SD3Transformer2DKontextModel.from_pretrained(
        pretrained_model_name_or_path, subfolder="transformer",
        quantization_config=bnb4, device_map="auto", low_cpu_mem_usage=True
    ).cuda()
    text_qconf = bnb8
    vae_dtype = torch.float16
else:  # fp16
    transformer = SD3Transformer2DKontextModel.from_pretrained(
        pretrained_model_name_or_path, subfolder="transformer",
        torch_dtype=torch.float16, device_map="auto", low_cpu_mem_usage=True
    ).cuda()
    text_qconf = None
    vae_dtype = torch.float16

vae = AutoencoderKL.from_pretrained(
    pretrained_model_name_or_path, subfolder="vae",
    torch_dtype=vae_dtype, device_map="auto", low_cpu_mem_usage=True
)

# Load text encoders
text_encoder = CLIPTextModelWithProjection.from_pretrained(
    pretrained_model_name_or_path, subfolder="text_encoder",
    quantization_config=text_qconf, torch_dtype=None, device_map="auto", low_cpu_mem_usage=True
)
tokenizer = CLIPTokenizer.from_pretrained(pretrained_model_name_or_path, subfolder="tokenizer")

text_encoder_2 = CLIPTextModelWithProjection.from_pretrained(
    pretrained_model_name_or_path, subfolder="text_encoder_2",
    quantization_config=text_qconf, torch_dtype=None, device_map="auto", low_cpu_mem_usage=True
)
tokenizer_2 = CLIPTokenizer.from_pretrained(pretrained_model_name_or_path, subfolder="tokenizer_2")

text_encoder_3 = T5EncoderModel.from_pretrained(
    pretrained_model_name_or_path, subfolder="text_encoder_3",
    quantization_config=text_qconf, torch_dtype=None, device_map="auto", low_cpu_mem_usage=True
)
tokenizer_3 = T5TokenizerFast.from_pretrained(pretrained_model_name_or_path, subfolder="tokenizer_3")

scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(
    pretrained_model_name_or_path, subfolder="scheduler"
)

# Create pipeline
pipeline = StableDiffusion3KontextPipeline(
    transformer=transformer, vae=vae,
    text_encoder=text_encoder, tokenizer=tokenizer,
    text_encoder_2=text_encoder_2, tokenizer_2=tokenizer_2,
    text_encoder_3=text_encoder_3, tokenizer_3=tokenizer_3,
    scheduler=scheduler)

# Generate image
image = pipeline(
    prompt='a pig with wings and a top hat flying over a happy futuristic scifi city',
    negative_prompt='',
    height=512, width=384,
    num_inference_steps=50,
    guidance_scale=3.5,
    generator=torch.Generator(device=transformer.device).manual_seed(42)
).images[0]

image.save("text2image.png")
print(f"Image saved to text2image.png (quant={quant})")
4. Image Editing
# Load and preprocess image
def fix_longer_edge(x, image_size, factor=32):
    w, h = x.size
    if w >= h:
        target_w = image_size
        target_h = h * (target_w / w)
        target_h = round(target_h / factor) * factor
    else:
        target_h = image_size
        target_w = w * (target_h / h)
        target_w = round(target_w / factor) * factor
    x = x.resize(size=(target_w, target_h))
    return x

image = Image.open("text2image.png")
image = fix_longer_edge(image, image_size=512)

negative_prompt = "blurry, low quality, low resolution, distorted, deformed, broken content, missing parts, damaged details, artifacts, glitch, noise, pixelated, grainy, compression artifacts, bad composition, wrong proportion, incomplete editing, unfinished, unedited areas."

# Edit image
edited_image = pipeline(
    image=image,
    prompt="remove the pig's hat",
    negative_prompt=negative_prompt,
    height=image.height, width=image.width,
    num_inference_steps=50,
    guidance_scale=3.5,
    generator=torch.Generator(device=transformer.device).manual_seed(42)
).images[0]

edited_image.save("edited_img.png")
print(f"Edited Image saved to edited_img.png (quant={quant})")
📄 License

This model is released under the MIT License.

Citation

If you use Skywork-UniPic in your research, please cite:

@misc{wang2025skyworkunipicunifiedautoregressive,
      title={Skywork UniPic: Unified Autoregressive Modeling for Visual Understanding and Generation}, 
      author={Peiyu Wang and Yi Peng and Yimeng Gan and Liang Hu and Tianyidan Xie and Xiaokun Wang and Yichen Wei and Chuanxin Tang and Bo Zhu and Changshi Li and Hongyang Wei and Eric Li and Xuchen Song and Yang Liu and Yahui Zhou},
      year={2025},
      eprint={2508.03320},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2508.03320}, 
}

Runs of Skywork UniPic2-SD3.5M-Kontext-GRPO-2B on huggingface.co

18
Total runs
0
24-hour runs
0
3-day runs
6
7-day runs
1
30-day runs

More Information About UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co Model

More UniPic2-SD3.5M-Kontext-GRPO-2B license Visit here:

https://choosealicense.com/licenses/mit

UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co

UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co is an AI model on huggingface.co that provides UniPic2-SD3.5M-Kontext-GRPO-2B's model effect (), which can be used instantly with this Skywork UniPic2-SD3.5M-Kontext-GRPO-2B model. huggingface.co supports a free trial of the UniPic2-SD3.5M-Kontext-GRPO-2B model, and also provides paid use of the UniPic2-SD3.5M-Kontext-GRPO-2B. Support call UniPic2-SD3.5M-Kontext-GRPO-2B model through api, including Node.js, Python, http.

UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co Url

https://huggingface.co/Skywork/UniPic2-SD3.5M-Kontext-GRPO-2B

Skywork UniPic2-SD3.5M-Kontext-GRPO-2B online free

UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co is an online trial and call api platform, which integrates UniPic2-SD3.5M-Kontext-GRPO-2B's modeling effects, including api services, and provides a free online trial of UniPic2-SD3.5M-Kontext-GRPO-2B, you can try UniPic2-SD3.5M-Kontext-GRPO-2B online for free by clicking the link below.

Skywork UniPic2-SD3.5M-Kontext-GRPO-2B online free url in huggingface.co:

https://huggingface.co/Skywork/UniPic2-SD3.5M-Kontext-GRPO-2B

UniPic2-SD3.5M-Kontext-GRPO-2B install

UniPic2-SD3.5M-Kontext-GRPO-2B is an open source model from GitHub that offers a free installation service, and any user can find UniPic2-SD3.5M-Kontext-GRPO-2B on GitHub to install. At the same time, huggingface.co provides the effect of UniPic2-SD3.5M-Kontext-GRPO-2B install, users can directly use UniPic2-SD3.5M-Kontext-GRPO-2B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

UniPic2-SD3.5M-Kontext-GRPO-2B install url in huggingface.co:

https://huggingface.co/Skywork/UniPic2-SD3.5M-Kontext-GRPO-2B

Url of UniPic2-SD3.5M-Kontext-GRPO-2B

UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co Url

Provider of UniPic2-SD3.5M-Kontext-GRPO-2B huggingface.co

Skywork
ORGANIZATIONS

Other API from Skywork

huggingface.co

Total runs: 86
Run Growth: 54
Growth Rate: 62.79%
Updated:April 08 2025
huggingface.co

Total runs: 59
Run Growth: 1
Growth Rate: 1.69%
Updated:January 28 2026
huggingface.co

Total runs: 56
Run Growth: -27
Growth Rate: -50.00%
Updated:June 26 2025
huggingface.co

Total runs: 47
Run Growth: 14
Growth Rate: 29.79%
Updated:February 07 2026
huggingface.co

Total runs: 45
Run Growth: -16
Growth Rate: -35.56%
Updated:June 13 2025
huggingface.co

Total runs: 35
Run Growth: -5
Growth Rate: -14.29%
Updated:March 04 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:December 03 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:September 02 2025