jiuface commited on
Commit
2008ad3
1 Parent(s): a715048

add lora configs as gradio parameters

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +25 -3
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: FLUX.1 [Inpainting]
3
  emoji: 🎨
4
  colorFrom: yellow
5
  colorTo: pink
 
1
  ---
2
+ title: FLUX.1 [Inpainting with lora]
3
  emoji: 🎨
4
  colorFrom: yellow
5
  colorTo: pink
app.py CHANGED
@@ -22,8 +22,8 @@ IMAGE_SIZE = 1024
22
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
  trigger_word = "a_photo_of_TOK"
25
- lora_path = "jiuface/boy-001"
26
- lora_weights = "flux_train_replicate.safetensors"
27
  lora_scale = 0.9
28
 
29
  login(token=HF_TOKEN)
@@ -97,6 +97,8 @@ def resize_image_dimensions(
97
  @spaces.GPU(duration=100)
98
  def process(
99
  input_image_editor: dict,
 
 
100
  input_text: str,
101
  seed_slicer: int,
102
  randomize_seed_checkbox: bool,
@@ -123,6 +125,7 @@ def process(
123
  width, height = resize_image_dimensions(original_resolution_wh=image.size)
124
  resized_image = image.resize((width, height), Image.LANCZOS)
125
  resized_mask = mask.resize((width, height), Image.LANCZOS)
 
126
  with calculateDuration("load lora"):
127
  pipe.load_lora_weights(lora_path, weight_name=lora_weights)
128
 
@@ -157,15 +160,32 @@ with gr.Blocks() as demo:
157
  image_mode='RGB',
158
  layers=False,
159
  brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  with gr.Row():
162
  input_text_component = gr.Text(
163
  label="Prompt",
164
- show_label=False,
165
  max_lines=1,
166
  placeholder="Enter your prompt",
167
  container=False,
168
  )
 
169
  submit_button_component = gr.Button(
170
  value='Submit', variant='primary', scale=0)
171
 
@@ -213,6 +233,8 @@ with gr.Blocks() as demo:
213
  fn=process,
214
  inputs=[
215
  input_image_editor_component,
 
 
216
  input_text_component,
217
  seed_slicer_component,
218
  randomize_seed_checkbox_component,
 
22
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
  trigger_word = "a_photo_of_TOK"
25
+ # lora_path = "jiuface/boy-001"
26
+ # lora_weights = "flux_train_replicate.safetensors"
27
  lora_scale = 0.9
28
 
29
  login(token=HF_TOKEN)
 
97
  @spaces.GPU(duration=100)
98
  def process(
99
  input_image_editor: dict,
100
+ lora_path: str,
101
+ lora_weights: str,
102
  input_text: str,
103
  seed_slicer: int,
104
  randomize_seed_checkbox: bool,
 
125
  width, height = resize_image_dimensions(original_resolution_wh=image.size)
126
  resized_image = image.resize((width, height), Image.LANCZOS)
127
  resized_mask = mask.resize((width, height), Image.LANCZOS)
128
+
129
  with calculateDuration("load lora"):
130
  pipe.load_lora_weights(lora_path, weight_name=lora_weights)
131
 
 
160
  image_mode='RGB',
161
  layers=False,
162
  brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"))
163
+
164
+ with gr.Accordion("Lora Settings", open=True):
165
+ lora_path = gr.Text(
166
+ label="Lora path",
167
+ show_label=True,
168
+ max_lines=1,
169
+ placeholder="Enter your lora path",
170
+ container=False,
171
+ )
172
+ lora_weights = gr.Text(
173
+ label="Lora weights",
174
+ show_label=True,
175
+ max_lines=1,
176
+ placeholder="Enter your lora weights",
177
+ container=False,
178
+ )
179
 
180
  with gr.Row():
181
  input_text_component = gr.Text(
182
  label="Prompt",
183
+ show_label=True,
184
  max_lines=1,
185
  placeholder="Enter your prompt",
186
  container=False,
187
  )
188
+
189
  submit_button_component = gr.Button(
190
  value='Submit', variant='primary', scale=0)
191
 
 
233
  fn=process,
234
  inputs=[
235
  input_image_editor_component,
236
+ lora_path,
237
+ lora_weights,
238
  input_text_component,
239
  seed_slicer_component,
240
  randomize_seed_checkbox_component,