akhaliq HF Staff commited on
Commit
43aa8c5
·
verified ·
1 Parent(s): c3dc2f1

Update Gradio app with multiple files

Browse files
Files changed (1) hide show
  1. app.py +13 -13
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
@@ -44,7 +44,7 @@ optimize_pipeline_(pipe, image=[Image.new("RGB", (1024, 1024)), Image.new("RGB",
44
  MAX_SEED = np.iinfo(np.int32).max
45
 
46
  @spaces.GPU
47
- def convert_to_anime(
48
  image,
49
  seed,
50
  randomize_seed,
@@ -54,7 +54,7 @@ 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 +177,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>
@@ -192,7 +192,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
192
  with gr.Row():
193
  with gr.Column(scale=1):
194
  image = gr.Image(
195
- label="Upload Photo",
196
  type="pil",
197
  elem_classes="image-container"
198
  )
@@ -205,11 +205,11 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
205
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024, visible=False)
206
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024, visible=False)
207
 
208
- convert_btn = gr.Button("Convert to Anime", variant="primary", elem_id="convert-btn", size="lg")
209
 
210
  with gr.Column(scale=1):
211
  result = gr.Image(
212
- label="Anime Result",
213
  interactive=False,
214
  elem_classes="image-container"
215
  )
@@ -222,7 +222,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
222
 
223
  # Convert button click
224
  convert_btn.click(
225
- fn=convert_to_anime,
226
  inputs=inputs,
227
  outputs=outputs
228
  )
 
29
  torch_dtype=dtype,
30
  device_map='cuda'),torch_dtype=dtype).to(device)
31
 
32
+ pipe.load_lora_weights("tarn59/extract_texture_qwen_image_edit_2509",
33
+ weight_name="extract_texture_qwen_image_edit_2509.safetensors",
34
+ adapter_name="texture")
35
+ pipe.set_adapters(["texture"], adapter_weights=[1.])
36
+ pipe.fuse_lora(adapter_names=["texture"], lora_scale=1.0)
37
  pipe.unload_lora_weights()
38
 
39
  pipe.transformer.__class__ = QwenImageTransformer2DModel
 
44
  MAX_SEED = np.iinfo(np.int32).max
45
 
46
  @spaces.GPU
47
+ def extract_texture(
48
  image,
49
  seed,
50
  randomize_seed,
 
54
  width,
55
  progress=gr.Progress(track_tqdm=True)
56
  ):
57
+ prompt = "Extract texture from this image"
58
 
59
  if randomize_seed:
60
  seed = random.randint(0, MAX_SEED)
 
177
 
178
  with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
179
  with gr.Column(elem_id="col-container"):
180
+ gr.Markdown("# 🎨 Texture Extraction", elem_id="title")
181
  gr.Markdown(
182
  """
183
+ Extract texture from your 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>
 
192
  with gr.Row():
193
  with gr.Column(scale=1):
194
  image = gr.Image(
195
+ label="Input Image",
196
  type="pil",
197
  elem_classes="image-container"
198
  )
 
205
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024, visible=False)
206
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024, visible=False)
207
 
208
+ convert_btn = gr.Button("Extract Texture", variant="primary", elem_id="convert-btn", size="lg")
209
 
210
  with gr.Column(scale=1):
211
  result = gr.Image(
212
+ label="Extracted Texture",
213
  interactive=False,
214
  elem_classes="image-container"
215
  )
 
222
 
223
  # Convert button click
224
  convert_btn.click(
225
+ fn=extract_texture,
226
  inputs=inputs,
227
  outputs=outputs
228
  )