openfree commited on
Commit
d3d700c
ยท
verified ยท
1 Parent(s): e3c44d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -17
app.py CHANGED
@@ -38,16 +38,16 @@ with open('loras.json', 'r') as f:
38
 
39
  # Initialize the base model
40
  dtype = torch.bfloat16
 
41
  device = "cuda" if torch.cuda.is_available() else "cpu"
42
 
43
  # ๊ณตํ†ต FLUX ๋ชจ๋ธ ๋กœ๋“œ
44
  base_model = "black-forest-labs/FLUX.1-dev"
45
- pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype)
46
- pipe.to(device) # ์—ฌ๊ธฐ์„œ ํ•œ ๋ฒˆ๋งŒ device๋กœ ์ด๋™
47
 
48
  # LoRA๋ฅผ ์œ„ํ•œ ์„ค์ •
49
- taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype)
50
- good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype)
51
 
52
  # Image-to-Image ํŒŒ์ดํ”„๋ผ์ธ ์„ค์ •
53
  pipe_i2i = AutoPipelineForImage2Image.from_pretrained(
@@ -59,32 +59,26 @@ pipe_i2i = AutoPipelineForImage2Image.from_pretrained(
59
  text_encoder_2=pipe.text_encoder_2,
60
  tokenizer_2=pipe.tokenizer_2,
61
  torch_dtype=dtype
62
- )
63
 
 
64
  controlnet = FluxControlNetModel.from_pretrained(
65
  "jasperai/Flux.1-dev-Controlnet-Upscaler", torch_dtype=torch.bfloat16
66
- )
67
-
68
- print("Available attributes in FLUX pipeline:", pipe.__dict__.keys())
69
 
70
- # Upscale ํŒŒ์ดํ”„๋ผ์ธ ์„ค์ • (FLUX ๋ชจ๋ธ์˜ ์‹ค์ œ ๊ตฌ์กฐ์— ๋งž๊ฒŒ ์ˆ˜์ •)
71
  pipe_upscale = FluxControlNetPipeline(
72
  vae=pipe.vae,
73
  text_encoder=pipe.text_encoder,
74
- text_encoder_2=pipe.text_encoder_2,
75
  tokenizer=pipe.tokenizer,
76
- tokenizer_2=pipe.tokenizer_2,
77
  transformer=pipe.transformer,
78
  scheduler=pipe.scheduler,
79
  controlnet=controlnet
80
- )
 
 
81
 
82
- # ์ถ”๊ฐ€ ์†์„ฑ ์„ค์ • (์žˆ๋Š” ๊ฒฝ์šฐ์—๋งŒ)
83
- if hasattr(pipe, 'image_processor'):
84
- pipe_upscale.image_processor = pipe.image_processor
85
 
86
- # ๋ชจ๋“  ํŒŒ์ดํ”„๋ผ์ธ์„ device๋กœ ์ด๋™
87
- pipe_upscale.to(device)
88
 
89
 
90
  MAX_SEED = 2**32 - 1
 
38
 
39
  # Initialize the base model
40
  dtype = torch.bfloat16
41
+
42
  device = "cuda" if torch.cuda.is_available() else "cpu"
43
 
44
  # ๊ณตํ†ต FLUX ๋ชจ๋ธ ๋กœ๋“œ
45
  base_model = "black-forest-labs/FLUX.1-dev"
46
+ pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).to(device)
 
47
 
48
  # LoRA๋ฅผ ์œ„ํ•œ ์„ค์ •
49
+ taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
50
+ good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).to(device)
51
 
52
  # Image-to-Image ํŒŒ์ดํ”„๋ผ์ธ ์„ค์ •
53
  pipe_i2i = AutoPipelineForImage2Image.from_pretrained(
 
59
  text_encoder_2=pipe.text_encoder_2,
60
  tokenizer_2=pipe.tokenizer_2,
61
  torch_dtype=dtype
62
+ ).to(device)
63
 
64
+ # Upscale์„ ์œ„ํ•œ ControlNet ์„ค์ •
65
  controlnet = FluxControlNetModel.from_pretrained(
66
  "jasperai/Flux.1-dev-Controlnet-Upscaler", torch_dtype=torch.bfloat16
67
+ ).to(device)
 
 
68
 
69
+ # Upscale ํŒŒ์ดํ”„๋ผ์ธ ์„ค์ • (๊ธฐ์กด pipe ์žฌ์‚ฌ์šฉ)
70
  pipe_upscale = FluxControlNetPipeline(
71
  vae=pipe.vae,
72
  text_encoder=pipe.text_encoder,
 
73
  tokenizer=pipe.tokenizer,
 
74
  transformer=pipe.transformer,
75
  scheduler=pipe.scheduler,
76
  controlnet=controlnet
77
+ ).to(device)
78
+
79
+
80
 
 
 
 
81
 
 
 
82
 
83
 
84
  MAX_SEED = 2**32 - 1