MohamedRashad commited on
Commit
5d7365b
·
1 Parent(s): d997e94

Move device initialization for FLUX pipeline and VAE to CPU, add CUDA support in generate_item_image function

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -20,9 +20,8 @@ from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_imag
20
 
21
  llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
22
 
23
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
24
- pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
25
- good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16).to(device)
26
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
27
 
28
  def generate_t2i_prompt(item_name):
@@ -57,6 +56,7 @@ Focus on the item itself, ensuring it is fully described, and specify a plain, w
57
  @spaces.GPU(duration=75)
58
  def generate_item_image(object_t2i_prompt):
59
  trial_id = ""
 
60
  for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
61
  prompt=object_t2i_prompt,
62
  guidance_scale=3.5,
 
20
 
21
  llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
22
 
23
+ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
24
+ good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16)
 
25
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
26
 
27
  def generate_t2i_prompt(item_name):
 
56
  @spaces.GPU(duration=75)
57
  def generate_item_image(object_t2i_prompt):
58
  trial_id = ""
59
+ pipe.cuda()
60
  for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
61
  prompt=object_t2i_prompt,
62
  guidance_scale=3.5,