공개 코드 실행 순서와 해상도 주의점
환경 설정 예시는 다음과 같습니다.
1
2
3
4
5
6
| git clone https://github.com/showlab/PhotoDoodle.git
cd PhotoDoodle
conda create -n doodle python=3.11.10
conda activate doodle
pip install -r requirements.txt
|
추론 코드는 먼저 FLUX.1-dev 기반 FluxPipeline을 bfloat16으로 GPU에 올립니다. 이어 pretrain.safetensors를 불러와 pipeline에 합친 뒤, 실제 스타일 LoRA인 sksmagiceffects.safetensors를 추가합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| from src.pipeline_pe_clone import FluxPipeline
import torch
from PIL import Image
pipeline = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
torch_dtype=torch.bfloat16,
).to("cuda")
pipeline.load_lora_weights(
"nicolaus-huang/PhotoDoodle",
weight_name="pretrain.safetensors"
)
pipeline.fuse_lora()
pipeline.unload_lora_weights()
pipeline.load_lora_weights(
"nicolaus-huang/PhotoDoodle",
weight_name="sksmagiceffects.safetensors"
)
|
원문의 다음 조각에는 해상도 순서가 엇갈릴 수 있는 지점이 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| height = 768
width = 512
condition_image = Image.open("assets/1.png") \
.resize((height, width)).convert("RGB")
result = pipeline(
prompt="add a halo and wings for the cat by sksmagiceffects",
condition_image=condition_image,
height=height,
width=width,
guidance_scale=3.5,
num_inference_steps=20,
max_sequence_length=512,
).images[0]
result.save("output.png")
|
PIL의 resize 튜플은 코드상 첫 값과 둘째 값을 그대로 가로, 세로로 사용하지만, pipeline에는 height와 width를 이름으로 따로 전달합니다. 현재 값으로는 조건 이미지가 768×512로 만들어지고 생성 요청은 높이 768, 너비 512가 됩니다. 조건 이미지와 생성 캔버스의 방향을 맞추려면 이 순서를 실제 파일 크기와 함께 확인해야 합니다.
또한 이 코드는 CUDA GPU와 모델 가중치가 준비됐다는 전제의 핵심 추론 조각입니다. 메모리 요구량, 다운로드 실패, 입력 파일 확인, 여러 이미지 일괄 처리까지 포함한 완전한 애플리케이션은 아닙니다.