jd-opensource/JoyAI-Image-Edit-Diffusers
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

JoyAI-Image-Edit
唤醒空间智能,实现统一的多模态理解与生成

报告 PDF 项目 Hugging Face  ModelScope  演示  许可证

🐶 JoyAI-Image-Edit

JoyAI-Image-Edit 是一款专注于指令引导图像编辑的多模态基础模型。它凭借强大的空间理解能力(包括场景解析、关系定位和指令分解),实现精确且可控的编辑,可将复杂修改准确应用于指定区域。

🚀 快速开始

环境要求:Python >= 3.10,支持 CUDA 的 GPU

安装

注意:JoyImageEditPipeline 将在 diffusers 的下一个官方版本(>0.38.0)中包含。在此之前,请按上述方法从源码安装。

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

使用 Diffusers 运行

import torch
from PIL import Image

from diffusers import JoyImageEditPipeline

pipeline = JoyImageEditPipeline.from_pretrained("jdopensource/JoyAI-Image-Edit-Diffusers")
pipeline.to(torch.bfloat16)
pipeline.to("cuda")
pipeline.set_progress_bar_config(disable=None)
print("pipeline loaded")

img_path = "./test_images/input.png"
prompt = "Remove the construction structure from the top of the crane."
image = Image.open(img_path).convert("RGB")

inputs = {
    "image": image,
    "prompt": prompt,
    "generator": torch.manual_seed(0),
    "num_inference_steps": 40,
    "guidance_scale": 4.0,
}

print("run pipeline...")

with torch.inference_mode():
    output = pipeline(**inputs)
    image = output.images[0]
    image.save("joyai_image_edit_output.png")
    print("image saved.")

更多用法

空间编辑参考

JoyAI-Image 支持三种空间编辑提示模式:物体移动、物体旋转和相机控制。为获得最稳定的效果,建议尽可能严格遵循以下提示模板。

1. 物体移动

当您希望将目标物体移动到指定区域时,使用此模式。

提示模板:

Move the <object> into the red box and finally remove the red box.

规则:

  • 将 <object> 替换为待移动目标对象的清晰描述。
  • 红色方框 表示图像中的目标位置。
  • 短语 "finally remove the red box" 意为引导方框不应出现在最终编辑结果中。

示例:

Move the board into the red box and finally remove the red box.

2. 物体旋转

当你希望将物体旋转至特定标准视角时,可使用此模式。

提示词模板:

Rotate the <object> to show the <view> side view.

支持的 <view> 值:

  • front
  • right
  • left
  • rear
  • front right
  • front left
  • rear right
  • rear left

规则:

  • 用待旋转对象的清晰描述替换 <object>。
  • 用上述支持的方向之一替换 <view>。
  • 本指令旨在改变对象朝向,同时尽可能保持对象本身及周围场景的一致性。

示例:

Rotate the dog to show the left side view.

3. 相机控制

当你希望仅更改相机视角而保持3D场景本身不变时,请使用此模式。

提示词模板:

Move the camera.
- Camera rotation: Yaw {y_rotation}°, Pitch {p_rotation}°.
- Camera zoom: in/out/unchanged.
- Keep the 3D scene static; only change the viewpoint.

规则:

  • {y_rotation} 指定偏航旋转角度(以度为单位)。

  • {p_rotation} 指定俯仰旋转角度(以度为单位)。

  • 相机缩放 必须是以下选项之一:

    • in(放大)
    • out(缩小)
    • unchanged(不变)
  • 最后一行至关重要:它明确告知模型保留 3D 场景内容和几何结构,仅调整相机视角。

示例:

Move the camera.
- Camera rotation: Yaw 0.0°, Pitch -15.0°.
- Camera zoom: unchanged.
- Keep the 3D scene static; only change the viewpoint.

许可协议

JoyAI-Image 基于 Apache 2.0 许可协议授权。

☎️ 我们正在招聘!

我们正积极招聘研究科学家、AI 基础设施工程师和实习生,加入我们共同构建下一代生成式基础模型并将其应用于实际场景。如果您感兴趣,请将简历发送至:huanghaoyang.ocean@jd.com