Diffusers documentation

Bria Fibo Edit

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Bria Fibo Edit

Fibo Edit는 8B 파라미터의 이미지-투-이미지 모델로, 소스 이미지와 페어링된 JSON 입력을 기반으로 작동하여 결정적이고 반복 가능한 편집 워크플로를 가능하게 하는 구조화된 제어의 새로운 패러다임을 도입합니다. 세밀한 정밀도를 위한 네이티브 마스킹을 갖추고 있어, 단순한 프롬프트 기반 확산을 넘어 프로덕션 환경에 최적화된 명시적이고 해석 가능한 제어를 제공합니다. 경량 아키텍처는 심층적인 커스터마이징을 위해 설계되어, 연구자가 도메인별 작업에 특화된 “Edit” 모델을 구축할 수 있도록 지원하면서 최상급의 미적 품질을 제공합니다.

자세한 내용은 Bria Fibo Edit Hugging Face 페이지를 참고하세요. 디스틸된 체크포인트는 Fibo-Edit-1.5-turbo에서 사용할 수 있습니다.

사용

모델이 게이트가 설정되어 있으므로, diffusers와 함께 사용하기 전에 먼저 Bria Fibo Edit Hugging Face 페이지로 이동하여 양식을 작성하고 게이트를 수락해야 합니다. 접근 권한이 부여된 후에는 시스템이 게이트 수락을 인식할 수 있도록 로그인해야 합니다.

아래 명령을 사용하여 로그인하세요:

hf auth login

BriaFiboEditPipeline

클래스 diffusers.BriaFiboEditPipeline

< >

( transformer: BriaFiboTransformer2DModelscheduler: typing.Union[diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler, diffusers.schedulers.scheduling_utils.KarrasDiffusionSchedulers]vae: AutoencoderKLWantext_encoder: SmolLM3ForCausalLMtokenizer: AutoTokenizer )

매개변수

  • transformer (BriaFiboTransformer2DModel) — 2D 확산 모델링을 위한 transformer 모델입니다.
  • scheduler (FlowMatchEulerDiscreteScheduler 또는 KarrasDiffusionSchedulers) — transformer와 함께 인코딩된 latents의 노이즈를 제거하는 데 사용할 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 이미지를 인코딩 및 디코딩하는 Variational Auto-Encoder입니다.
  • text_encoder (SmolLM3ForCausalLM) — 입력 프롬프트를 처리하는 텍스트 인코더.
  • tokenizer (AutoTokenizer) — text_encoder의 입력 텍스트 프롬프트를 처리하는 데 사용되는 토크나이저.

__call__

< >

( prompt: typing.Union[str, typing.List[str]] = Noneimage: typing.Union[PIL.Image.Image, typing.List[PIL.Image.Image], NoneType] = Nonemask: typing.Union[torch.FloatTensor, PIL.Image.Image, typing.List[PIL.Image.Image], typing.List[torch.FloatTensor], numpy.ndarray, typing.List[numpy.ndarray], NoneType] = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 30timesteps: typing.List[int] = Noneseed: int | None = Noneguidance_scale: float = 5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: str = 'pil'return_dict: bool = Truejoint_attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = Nonecallback_on_step_end_tensor_inputs: typing.List[str] = ['latents']max_sequence_length: int = 3000do_patching = False_auto_resize: bool = True ) → ~pipelines.flux.BriaFiboPipelineOutput or tuple

매개변수

  • prompt (str 또는 List[str]) — 이미지 생성을 안내하는 프롬프트입니다.
  • image (PIL.Image.Image 또는 List[PIL.Image.Image], 선택 사항) — 이미지 생성을 안내하는 하나 이상의 참조 이미지입니다. 리스트는 여러 참조(배치가 아님)로 해석됩니다: 각 참조는 자체 종횡비로 VAE 인코딩되어 각각의 RoPE 시간 평면 1, 2, … 에 배치됩니다. 정의되지 않은 경우 파이프라인은 처음부터 이미지를 생성합니다.
  • mask (PipelineMaskInput, 선택 사항) — image에서 편집할 영역을 정의하는 선택적 마스크입니다. 마스크로 덮인 픽셀은 재생성되고, 이미지의 나머지 부분은 유지됩니다.
  • height (int, 선택 사항, 기본값은 self.unet.config.sample_size * self.vae_scale_factor) — 생성된 이미지의 픽셀 단위 높이입니다. 최적의 결과를 위해 기본값은 1024로 설정됩니다.
  • width (int, 선택 사항, 기본값은 self.unet.config.sample_size * self.vae_scale_factor) — 생성된 이미지의 픽셀 단위 너비입니다. 최적의 결과를 위해 기본값은 1024로 설정되어 있습니다.
  • num_inference_steps (int, 선택 사항, 기본값 30) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도가 느려집니다.
  • seed (int, 선택 사항) — 생성을 결정적으로 만들기 위해 사용되는 시드입니다.
  • timesteps (List[int], 선택 사항) — timesteps 인수를 지원하는 스케줄러의 set_timesteps 메서드에서 디노이징 과정에 사용할 커스텀 timesteps입니다. 정의되지 않은 경우, num_inference_steps가 전달될 때의 기본 동작이 사용됩니다. 내림차순으로 정렬되어 있어야 합니다.
  • guidance_scale (float, 선택 사항, 기본값 5.0) — Classifier-Free Diffusion Guidance에서 정의한 가이던스 스케일입니다. guidance_scale은 Imagen Paper의 방정식 2의 w로 정의됩니다. guidance_scale > 1로 설정하면 가이던스 스케일이 활성화됩니다. 가이던스 스케일이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다.
  • negative_prompt (str 또는 List[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, guidance_scale이 1보다 작은 경우 무시됩니다).
  • num_images_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수입니다.
  • generator (torch.Generator 또는 List[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch generator 하나 또는 목록
  • latents (torch.FloatTensor, 선택 사항) — 이미지 생성의 입력으로 사용할 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents입니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서가 생성됩니다.
  • output_type (str, 선택 사항, 기본값 "pil") — 이미지 생성의 출력 형식입니다. PIL: PIL.Image.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — 일반 튜플 대신 ~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutput를 반환할지 여부.
  • joint_attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, 선택 사항) — 추론 중 각 디노이징 단계의 끝에서 호출되는 함수입니다. 이 함수는 다음 인수를 받아 호출됩니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (List, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 기본값 3000) — prompt에 사용할 최대 시퀀스 길이입니다.
  • do_patching (bool, 선택 사항, 기본값 False) — patching을 사용할지 여부.
  • _auto_resize (bool, 선택 사항, 기본값 True) — 기본 출력 해상도(첫 번째 참조 이미지에서 가져옴)를 권장 해상도에 맞게 조정할지 여부.

반환값

~pipelines.flux.BriaFiboPipelineOutput 또는 tuple

return_dict가 True이면 ~pipelines.flux.BriaFiboPipelineOutput, 그렇지 않으면 tuple입니다. tuple을 반환할 경우 첫 번째 요소는 생성된 이미지 목록입니다.

생성을 위해 파이프라인을 호출할 때 호출되는 함수.

예:

import torch
from PIL import Image

from diffusers import BriaFiboEditPipeline
from diffusers.modular_pipelines import ModularPipelineBlocks

# This prompt-to-JSON block calls Gemini and needs GEMINI_API_KEY in the environment.
vlm_pipe = ModularPipelineBlocks.from_pretrained("briaai/FIBO-edit-gemini-prompt-to-JSON", trust_remote_code=True)
vlm_pipe = vlm_pipe.init_pipeline()

pipe = BriaFiboEditPipeline.from_pretrained(
    "briaai/Fibo-Edit-1.5-base",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")

image = Image.open("owl.png")
json_prompt = vlm_pipe(image=image, prompt="Make the owl into a cat").values["json_prompt"]

result = pipe(prompt=json_prompt, image=image, num_inference_steps=30, guidance_scale=5)

# Multiple reference images: pass a list. Each reference conditions the edit at its
# own aspect ratio; the output resolution follows the first reference.
owl, forest = Image.open("owl.png"), Image.open("forest.png")
json_prompt = vlm_pipe(
    image=[owl, forest], prompt="Place the owl from the first image in the forest from the second image"
).values["json_prompt"]
result = pipe(
    prompt=json_prompt,
    image=[owl, forest],
    num_inference_steps=30,
    guidance_scale=5,
)

# The distilled Turbo checkpoint edits in 4 steps without classifier-free guidance.
pipe = BriaFiboEditPipeline.from_pretrained("briaai/Fibo-Edit-1.5-turbo", torch_dtype=torch.bfloat16)
pipe.to("cuda")
result = pipe(prompt=json_prompt, image=[owl, forest], num_inference_steps=4, guidance_scale=1)

encode_prompt

< >

( prompt: typing.Union[str, typing.List[str]]device: typing.Optional[torch.device] = Nonenum_images_per_prompt: int = 1guidance_scale: float = 5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonemax_sequence_length: int = 3000lora_scale: bool | None = None )

매개변수

  • prompt (str 또는 List[str], 선택) — 인코딩할 프롬프트
  • device — (torch.device): torch device
  • num_images_per_prompt (int) — 프롬프트당 생성할 이미지 수
  • guidance_scale (float) — Classifier free guidance의 guidance scale입니다.
  • negative_prompt (str 또는 List[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, guidance_scale이 1보다 작은 경우 무시됩니다).

prepare_reference_latents

< >

( image: Imagenum_channels_latents: intdtype: dtypedevice: devicedo_patching: bool = Falsereference_index: int = 1 )

VAE를 사용하여 PIL 참조 이미지를 자체 크기로 인코딩하고, 이를 편집 컨텍스트 토큰 스트림으로 패키징합니다.

Update on GitHub