ameerazam08 commited on
Commit
e02c582
·
verified ·
1 Parent(s): 6e8f43a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -8,23 +8,24 @@ import huggingface_hub
8
  huggingface_hub.login(os.getenv('HF_TOKEN_FLUX2'))
9
  # Load default image from assets as an example
10
  default_image = Image.open("assets/1.png")
11
-
12
- @spaces.GPU()
13
- def generate_image(model_path, image, height, width, prompt, guidance_scale, num_steps, lora_name):
14
- # Load the model
15
- pipeline = FluxPipeline.from_pretrained(
16
- model_path,
17
  torch_dtype=torch.bfloat16,
18
  ).to('cuda')
19
 
 
 
 
 
 
20
  # Load and fuse base LoRA weights
21
- pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name="pretrain.safetensors")
22
- pipeline.fuse_lora()
23
- pipeline.unload_lora_weights()
24
 
25
  # Load selected LoRA effect if not using the pretrained base model
26
- if lora_name != 'pretrained':
27
- pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name=f"{lora_name}.safetensors")
28
 
29
  # Prepare the input image
30
  condition_image = image.resize((height, width)).convert("RGB")
@@ -46,7 +47,6 @@ def generate_image(model_path, image, height, width, prompt, guidance_scale, num
46
  iface = gr.Interface(
47
  fn=generate_image,
48
  inputs=[
49
- gr.Textbox(label="Model Path", value="black-forest-labs/FLUX.1-dev"),
50
  gr.Image(label="Input Image", type="pil", value=default_image),
51
  gr.Slider(label="Height", value=768, minimum=256, maximum=1024, step=64),
52
  gr.Slider(label="Width", value=512, minimum=256, maximum=1024, step=64),
 
8
  huggingface_hub.login(os.getenv('HF_TOKEN_FLUX2'))
9
  # Load default image from assets as an example
10
  default_image = Image.open("assets/1.png")
11
+ pipeline = FluxPipeline.from_pretrained(
12
+ "black-forest-labs/FLUX.1-dev",
 
 
 
 
13
  torch_dtype=torch.bfloat16,
14
  ).to('cuda')
15
 
16
+
17
+ @spaces.GPU()
18
+ def generate_image(image, height, width, prompt, guidance_scale, num_steps, lora_name):
19
+ # Load the model
20
+
21
  # Load and fuse base LoRA weights
22
+ # pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name="pretrain.safetensors")
23
+ # pipeline.fuse_lora()
24
+ # pipeline.unload_lora_weights()
25
 
26
  # Load selected LoRA effect if not using the pretrained base model
27
+ pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name=f"{lora_name}.safetensors")
28
+ pipeline.fuse_lora()
29
 
30
  # Prepare the input image
31
  condition_image = image.resize((height, width)).convert("RGB")
 
47
  iface = gr.Interface(
48
  fn=generate_image,
49
  inputs=[
 
50
  gr.Image(label="Input Image", type="pil", value=default_image),
51
  gr.Slider(label="Height", value=768, minimum=256, maximum=1024, step=64),
52
  gr.Slider(label="Width", value=512, minimum=256, maximum=1024, step=64),