akhaliq HF Staff commited on
Commit
db18219
·
verified ·
1 Parent(s): 06c8872

Update Gradio app with multiple files

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -29,11 +29,11 @@ pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509",
29
  torch_dtype=dtype,
30
  device_map='cuda'),torch_dtype=dtype).to(device)
31
 
32
- pipe.load_lora_weights("autoweeb/Qwen-Image-Edit-2509-Photo-to-Anime",
33
- weight_name="Qwen-Image-Edit-2509-Photo-to-Anime_000001000.safetensors",
34
- adapter_name="anime")
35
- pipe.set_adapters(["anime"], adapter_weights=[1.])
36
- pipe.fuse_lora(adapter_names=["anime"], lora_scale=1.0)
37
  pipe.unload_lora_weights()
38
 
39
  pipe.transformer.__class__ = QwenImageTransformer2DModel
@@ -46,6 +46,7 @@ MAX_SEED = np.iinfo(np.int32).max
46
  @spaces.GPU
47
  def convert_to_anime(
48
  image,
 
49
  seed,
50
  randomize_seed,
51
  true_guidance_scale,
@@ -54,7 +55,8 @@ def convert_to_anime(
54
  width,
55
  progress=gr.Progress(track_tqdm=True)
56
  ):
57
- prompt = "Convert this photo to anime style"
 
58
 
59
  if randomize_seed:
60
  seed = random.randint(0, MAX_SEED)
@@ -177,10 +179,10 @@ def update_dimensions_on_upload(image):
177
 
178
  with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
179
  with gr.Column(elem_id="col-container"):
180
- gr.Markdown("# 🎨 Photo to Anime", elem_id="title")
181
  gr.Markdown(
182
  """
183
- Transform your photos into beautiful anime-style images
184
  <br>
185
  <div style='text-align: center; margin-top: 1rem;'>
186
  <a href='https://huggingface.co/spaces/akhaliq/anycoder' target='_blank' style='color: #0071e3; text-decoration: none; font-weight: 500;'>Built with anycoder</a>
@@ -197,6 +199,13 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
197
  elem_classes="image-container"
198
  )
199
 
 
 
 
 
 
 
 
200
  with gr.Accordion("⚙️ Advanced Settings", open=False):
201
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
202
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
@@ -215,7 +224,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
215
  )
216
 
217
  inputs = [
218
- image, seed, randomize_seed, true_guidance_scale,
219
  num_inference_steps, height, width
220
  ]
221
  outputs = [result, seed]
 
29
  torch_dtype=dtype,
30
  device_map='cuda'),torch_dtype=dtype).to(device)
31
 
32
+ pipe.load_lora_weights("eigen-ai-labs/eigen-banana-qwen-image-edit",
33
+ weight_name="eigen-banana-qwen-image-edit-fp16-lora.safetensors",
34
+ adapter_name="eigen-banana")
35
+ pipe.set_adapters(["eigen-banana"], adapter_weights=[1.])
36
+ pipe.fuse_lora(adapter_names=["eigen-banana"], lora_scale=1.0)
37
  pipe.unload_lora_weights()
38
 
39
  pipe.transformer.__class__ = QwenImageTransformer2DModel
 
46
  @spaces.GPU
47
  def convert_to_anime(
48
  image,
49
+ prompt,
50
  seed,
51
  randomize_seed,
52
  true_guidance_scale,
 
55
  width,
56
  progress=gr.Progress(track_tqdm=True)
57
  ):
58
+ if not prompt or prompt.strip() == "":
59
+ prompt = "Convert this photo to anime style"
60
 
61
  if randomize_seed:
62
  seed = random.randint(0, MAX_SEED)
 
179
 
180
  with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
181
  with gr.Column(elem_id="col-container"):
182
+ gr.Markdown("# 🍌 Eigen-Banana-Qwen-Image-Edit: Fast Image Editing with Qwen-Image-Edit LoRA", elem_id="title")
183
  gr.Markdown(
184
  """
185
+ Fast image editing powered by Qwen-Image-Edit with Eigen-Banana LoRA
186
  <br>
187
  <div style='text-align: center; margin-top: 1rem;'>
188
  <a href='https://huggingface.co/spaces/akhaliq/anycoder' target='_blank' style='color: #0071e3; text-decoration: none; font-weight: 500;'>Built with anycoder</a>
 
199
  elem_classes="image-container"
200
  )
201
 
202
+ prompt = gr.Textbox(
203
+ label="Prompt",
204
+ placeholder="Enter your editing instruction (e.g., 'Convert this photo to anime style')",
205
+ lines=2,
206
+ value="Convert this photo to anime style"
207
+ )
208
+
209
  with gr.Accordion("⚙️ Advanced Settings", open=False):
210
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
211
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
 
224
  )
225
 
226
  inputs = [
227
+ image, prompt, seed, randomize_seed, true_guidance_scale,
228
  num_inference_steps, height, width
229
  ]
230
  outputs = [result, seed]