Views
No views yet

1pipe = DiffusionPipeline.from_pretrained(
2 "JiaxinGe/Diffusers-BAGEL",
3 custom_pipeline="JiaxinGe/Diffusers-BAGEL",
4 torch_dtype=torch.bfloat16,
5 trust_remote_code=True
6)
7pipe = pipe.to("cuda:0")
8# (1) text→image
9prompt = "A female cosplayer portraying an ethereal fairy or elf, wearing a flowing dress made of delicate fabrics in soft, mystical colors like emerald green and silver. She has pointed ears, a gentle, enchanting expression, and her outfit is adorned with sparkling jewels and intricate patterns. The background is a magical forest with glowing plants, mystical creatures, and a serene atmosphere."
10out = pipe(text=prompt)
11print(out)
12out['images'][0].save("bagel_text2img.png")
13
14# 2) text→image with “think”
15out = pipe(
16 text="a car made of small cars",
17 think=True
18)
19print(out['text'])
20out['images'][0].save("bagel_text2img_think.png")
21
22# 3) image editing
23from PIL import Image
24img = Image.open("~/Bagel/test_images/women.jpg")
25out = pipe(
26 image=img,
27 text="She boards a modern subway, quietly reading a folded newspaper…"
28)
29out['images'][0].save("bagel_img_edit.png")
30
31# 4) image editing + think
32img = Image.open("~/Bagel/test_images/octupusy.jpg")
33out = pipe(
34 image=img,
35 text="Could you display the sculpture that takes after this design?",
36 think=True
37)
38print(out['text'])
39out['images'][0].save("bagel_img_edit_think.png")
40
41# 4) image understanding
42meme = Image.open("~/Bagel/test_images/meme.jpg")
43out = pipe(
44 image=meme,
45 text="Can someone explain what’s funny about this meme?",
46 understanding_output=True
47)
48print(out['text'])cfg_text_scale: text guidance strength (typical: 4.0–8.0)cfg_image_scale: image guidance strength (1.0–2.0)cfg_interval: fraction of steps to apply CFG (e.g. 0.4–1.0)num_timesteps: total denoising steps (e.g. 50)timestep_shift: offset of denoising schedulecfg_renorm_min / cfg_renorm_type: renormalization settings for CFG