Qwen-Image-Edit-Pruning

GitHub

Introduction

This open-source project is based on Qwen-Image-Edit and has attempted model pruning, removing 20 layers while retaining the weights of 40 layers, resulting in a model size of 13.6B parameters. The pruned version will continue to be iterated upon. Please stay tuned.

Quick Start

Install the latest version of diffusers and pytorch

pip install torch
pip install git+https://github.com/huggingface/diffusers

Qwen-Image-Edit-Pruning Inference

from diffusers import QwenImageEditPipeline
import os
from PIL import Image
import time
import torch

model_name = "OPPOer/Qwen-Image-Edit-Pruning/Qwen-Image-Edit-13B"

pipe = QwenImageEditPipeline.from_pretrained(model_name, torch_dtype=torch.bfloat16)
pipe = pipe.to('cuda')

output_path = 'outputs'
os.makedirs(output_path, exist_ok=True)
for file_name in os.listdir('examples'):
    prompt = file_name.replace('_in.jpg', '')
    subject_img = Image.open(os.path.join('examples', file_name)).convert('RGB')

    t1 = time.time()
    inputs = {
        "image": subject_img,
        "prompt": prompt,
        "generator": torch.manual_seed(42),
        "true_cfg_scale": 1,
        "num_inference_steps": 4,
    }
    with torch.inference_mode():
        output = pipe(**inputs)
        output_image = output.images[0]
        output_image.save(os.path.join(output_path, f'{prompt}.jpg'))
    print(time.time()-t1)
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for OPPOer/Qwen-Image-Edit-Pruning

Finetuned
(16)
this model

Dataset used to train OPPOer/Qwen-Image-Edit-Pruning