免费开源的吉卜力风格图像神器,小模型掀起大浪潮!效果毫不逊色于GPT-4o!

自从 GPT-4o 上线图像生成能力后,引发了一大波创作浪潮,其中吉卜力风格图像深受欢迎,一时爆火!

但 GPT-4o 虽强,也确实存在一定限制。最直接的就是生成次数有限、版权问题、图像生成排队等等。

不过现在有一款开源替代方案:EasyControl Ghibli 横空出世,这款轻量级模型不仅完全免费,还能在 Hugging Face 上直接体验。

它以高效控制和高质量输出挑战 GPT-4o,将你的照片瞬间变为吉卜力风格的治愈画面。

基于 Diffusion Transformer(DiT)打造,不仅免费,还以惊艳的效果和零门槛操作赢得了网友们的青睐。

项目介绍

EasyControl Ghibli 是 EasyControl 框架下的一个分支项目,是一款专注于将照片转化为吉卜力风格图像的AI模型。

它基于 FLUX.1-dev 的 DiT 架构,通过轻量级 LoRA 模块实现高效控制,现已在 Hugging Face 平台上线。

完全免费、零门槛,访问 HF 在线网页即可直接使用。网友戏称它是"以爱发电"的典范,小团队用巧思做出了大效果。

主要特点

  • 高还原吉卜力风格:柔光、暖调、空灵感,图像仿佛宫崎骏亲绘。

  • 轻量 LoRA:即插即用,快速部署,不占资源。

  • 灵活分辨率支持:位置感知训练,多场景、多尺寸轻松适配。

  • 合成速度快:因果注意机制 + KV 缓存技术,响应迅速,适合批量创作。

  • 版权安全:训练数据仅使用100张亚洲人脸 + GPT-4生成图,规避版权问题的同时保障风格精准。

  • 开源零门槛:无需下载或编程,直接在 Hugging Face 网页使用。

快速使用

EasyControl Ghibli 提供在线体验和本地部署两种方式。

在线体验,只需要能够访问 Hugging Face 即可(需魔法)。

在线Demo:huggingface.co/spaces/jame...

打开在线地址后,上传需要转换为吉卜力风格的照片,然后编写吉卜力风格提示词即可开始生成。

吉卜力风格提示词(官方推荐):Ghibli Studio style, Charming hand-drawn anime-style illustration

本地部署,需要有Python 3.10以上环境,及CUDA支持(也就是有英伟达显卡)。

ini 复制代码
# Create a new conda environment
conda create -n easycontrol python=3.10
conda activate easycontrol

# Install other dependencies
pip install -r requirements.txt

下载最新的支持吉卜力风格的模型。

ini 复制代码
from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="Xiaojiu-Z/EasyControl", filename="models/Ghibli.safetensors", local_dir="./")

吉卜力图片生成,Python调用代码:

ini 复制代码
import spaces
import os
import json
import time
import torch
from PIL import Image
from tqdm import tqdm
import gradio as gr

from safetensors.torch import save_file
from src.pipeline import FluxPipeline
from src.transformer_flux import FluxTransformer2DModel
from src.lora_helper import set_single_lora, set_multi_lora, unset_lora

# Initialize the image processor
base_path = "black-forest-labs/FLUX.1-dev"    
lora_base_path = "./checkpoints/models"


pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16)
transformer = FluxTransformer2DModel.from_pretrained(base_path, subfolder="transformer", torch_dtype=torch.bfloat16)
pipe.transformer = transformer
pipe.to("cuda")

def clear_cache(transformer):
    for name, attn_processor in transformer.attn_processors.items():
        attn_processor.bank_kv.clear()

# Define the Gradio interface
@spaces.GPU()
def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type):
    # Set the control type
    if control_type == "Ghibli":
        lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
    set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)
    
    # Process the image
    spatial_imgs = [spatial_img] if spatial_img else []
    image = pipe(
        prompt,
        height=int(height),
        width=int(width),
        guidance_scale=3.5,
        num_inference_steps=25,
        max_sequence_length=512,
        generator=torch.Generator("cpu").manual_seed(seed), 
        subject_images=[],
        spatial_images=spatial_imgs,
        cond_size=512,
    ).images[0]
    clear_cache(pipe.transformer)
    return image

# Define the Gradio interface components
control_types = ["Ghibli"]


# Create the Gradio Blocks interface
with gr.Blocks() as demo:
    gr.Markdown("# Ghibli Studio Control Image Generation with EasyControl")
    gr.Markdown("The model is trained on **only 100 real Asian faces** paired with **GPT-4o-generated Ghibli-style counterparts**, and it preserves facial features while applying the iconic anime aesthetic.")
    gr.Markdown("Generate images using EasyControl with Ghibli control LoRAs.(Due to hardware constraints, only low-resolution images can be generated. For high-resolution (1024+), please set up your own environment.)")
    
    gr.Markdown("**[Attention!!]**:The recommended prompts for using Ghibli Control LoRA should include the trigger words: `Ghibli Studio style, Charming hand-drawn anime-style illustration`")
    gr.Markdown("😊😊If you like this demo, please give us a star (github: [EasyControl](https://github.com/Xiaojiu-z/EasyControl))")

    with gr.Tab("Ghibli Condition Generation"):
        with gr.Row():
            with gr.Column():
                prompt = gr.Textbox(label="Prompt", value="Ghibli Studio style, Charming hand-drawn anime-style illustration")
                spatial_img = gr.Image(label="Ghibli Image", type="pil")  # 上传图像文件
                height = gr.Slider(minimum=256, maximum=1024, step=64, label="Height", value=768)
                width = gr.Slider(minimum=256, maximum=1024, step=64, label="Width", value=768)
                seed = gr.Number(label="Seed", value=42)
                control_type = gr.Dropdown(choices=control_types, label="Control Type")
                single_generate_btn = gr.Button("Generate Image")
            with gr.Column():
                single_output_image = gr.Image(label="Generated Image")


    # Link the buttons to the functions
    single_generate_btn.click(
        single_condition_generate_image,
        inputs=[prompt, spatial_img, height, width, seed, control_type],
        outputs=single_output_image
    )

# Launch the Gradio app
demo.queue().launch()

结果如下:

写在最后

我们这一代人,多少都有被宫崎骏动画治愈过。

从《龙猫》《哈尔的移动城堡》到《千与千寻》,那种柔光、暖意、人与自然和谐共处的世界,是很多人心中理想世界的样子。

而如今,有了 EasyControl Ghibli,我们终于可以把自己的现实一角,搬进那个动画宇宙里。

不论你是为了留念、创作、表白、教学、娱乐......

这款工具都能让你轻松达成,完全免费、无技术门槛、无版权风险、无隐藏费用。

上传你的作品,开启一场治愈的创意之旅吧!

GitHub 项目地址:github.com/Xiaojiu-z/E...

HuggingFace 体验地址:huggingface.co/spaces/jame...

相关推荐
uhakadotcom2 小时前
Guava 简介:让 Java 开发更高效
后端·面试·github
uhakadotcom3 小时前
FastAPI 安全配置指南
后端·面试·github
uhakadotcom3 小时前
快速理解 tiktoken:OpenAI 模型的高效 BPE 分词器
算法·面试·github
uhakadotcom3 小时前
轻松掌握 Griffe:Python 项目的 API 文档和兼容性管理利器
后端·面试·github
uhakadotcom3 小时前
MkDocs 入门指南:快速构建漂亮的静态网站
后端·面试·github
uhakadotcom3 小时前
PydanticAI:简化生成式 AI 应用的开发
后端·面试·github
uhakadotcom3 小时前
OpenAI 代理SDK入门指南
后端·面试·github
我是哪吒3 小时前
分布式微服务系统架构第99集:缓存系统的实战级优化案例
后端·面试·github
uhakadotcom3 小时前
DeBERTa:解析和应用指南
后端·面试·github
uhakadotcom3 小时前
了解LLMLingua:大语言模型的高效推理解决方案
后端·面试·github