tight-inversion commited on
Commit
3c1e8f4
·
1 Parent(s): c8ff942

Add spaces zero-gpu support

Browse files
Files changed (2) hide show
  1. app.py +7 -5
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import torch
3
  import random
@@ -55,6 +56,7 @@ pipe_inversion, pipe_inference = get_pipes(cfg, image_encoder=image_encoder, dev
55
  # pipe_inversion.cfg = cfg
56
  # pipe_inference.cfg = cfg
57
 
 
58
  def edit_demo(source_image, source_prompt, edit_prompt, ipa_scale, guidance_scale, sharpening_factor, use_negative_prompt):
59
  """
60
  Given a source image, a source prompt and an edit prompt, this function:
@@ -196,17 +198,17 @@ demo = gr.Interface(
196
  gr.Image(type="pil", label="Source Image"),
197
  gr.Textbox(lines=2, placeholder="Enter source prompt here", label="Source Prompt"),
198
  gr.Textbox(lines=2, placeholder="Enter edit prompt here", label="Edit Prompt"),
199
- gr.Slider(minimum=0.1, maximum=1.0, step=0.05, value=0.4, label="IPA Scale"),
200
- gr.Slider(minimum=1.0, maximum=20.0, step=0.1, value=7.5, label="Guidance Scale for Editing"),
201
- gr.Slider(minimum=1.0, maximum=3.0, step=0.1, value=1.5, label="Sharpening Factor"),
202
- gr.Checkbox(label="Use negative prompt", value=False),
203
  ],
204
  outputs=gr.Image(type="pil", label="Edited Image"),
205
  title="Tight Inversion SDXL Demo",
206
  description=(
207
  "Upload an image, provide a source prompt (for inversion) and an edit prompt, "
208
  "set the IPA scale (for both inversion and editing), the guidance scale for editing "
209
- "(inversion guidance scale is fixed to 1), and the guidance scale sharpening factor (editing only), "
210
  "then view the edited image. You can start with the provided examples."
211
  ),
212
  examples=[
 
1
+ import spaces
2
  import gradio as gr
3
  import torch
4
  import random
 
56
  # pipe_inversion.cfg = cfg
57
  # pipe_inference.cfg = cfg
58
 
59
+ @spaces.GPU
60
  def edit_demo(source_image, source_prompt, edit_prompt, ipa_scale, guidance_scale, sharpening_factor, use_negative_prompt):
61
  """
62
  Given a source image, a source prompt and an edit prompt, this function:
 
198
  gr.Image(type="pil", label="Source Image"),
199
  gr.Textbox(lines=2, placeholder="Enter source prompt here", label="Source Prompt"),
200
  gr.Textbox(lines=2, placeholder="Enter edit prompt here", label="Edit Prompt"),
201
+ gr.Slider(minimum=0.1, maximum=1.0, step=0.05, value=0.4, label="IPA Scale", info="Adjust to balance faithfulness and editability"),
202
+ gr.Slider(minimum=1.0, maximum=20.0, step=0.1, value=7.5, label="Guidance Scale", info="Adjust to control the strength of the edit"),
203
+ gr.Slider(minimum=1.0, maximum=3.0, step=0.1, value=1.5, label="Sharpening Factor", info="Makes CFG effects more localized"),
204
+ gr.Checkbox(label="Use negative prompt", value=False, info="Use the source prompt as a negative prompt for editing"),
205
  ],
206
  outputs=gr.Image(type="pil", label="Edited Image"),
207
  title="Tight Inversion SDXL Demo",
208
  description=(
209
  "Upload an image, provide a source prompt (for inversion) and an edit prompt, "
210
  "set the IPA scale (for both inversion and editing), the guidance scale for editing "
211
+ "and the guidance scale sharpening factor, "
212
  "then view the edited image. You can start with the provided examples."
213
  ),
214
  examples=[
requirements.txt CHANGED
@@ -3,4 +3,5 @@ diffusers[torch]==0.32.0
3
  transformers==4.46.2
4
  Pillow
5
  gradio>=5.17.0
6
- matplotlib
 
 
3
  transformers==4.46.2
4
  Pillow
5
  gradio>=5.17.0
6
+ matplotlib
7
+ spaces