Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -107,7 +107,7 @@ def slider_release(index, image, mask_np_list_updated, mask_label_list):
|
|
107 |
new_image = transparent_paste_with_mask(image, segmentation, mask_np, transparency = TRANSPARENCY)
|
108 |
return new_image, mask_label
|
109 |
def image_change():
|
110 |
-
return gr.Slider(value = 0, minimum=0, maximum=1, step=1, visible=False)
|
111 |
|
112 |
def save_as_orig_mask(mask_np_list_updated, mask_label_list, input_folder="example_tmp"):
|
113 |
print(mask_np_list_updated)
|
@@ -194,7 +194,7 @@ with gr.Blocks() as demo:
|
|
194 |
outputs= [canvas, label]
|
195 |
)
|
196 |
|
197 |
-
|
198 |
|
199 |
with gr.Tab(label="2 Optimization"):
|
200 |
with gr.Row():
|
@@ -244,30 +244,15 @@ with gr.Blocks() as demo:
|
|
244 |
)
|
245 |
run_optimization()
|
246 |
print('finish')
|
247 |
-
return "Optimization finished! Move to the next step."
|
248 |
except:
|
249 |
-
return "CUDA out of memory, use a smaller batch size or try another picture."
|
250 |
|
251 |
|
252 |
def immediate_update():
|
253 |
return gr.Button("Run Optimization (Check log for progress.).", interactive=True)
|
254 |
-
|
255 |
-
add_button.click(
|
256 |
-
inputs = [
|
257 |
-
mask_np_list,
|
258 |
-
mask_label_list,
|
259 |
-
image_loaded,
|
260 |
-
opt_flag,
|
261 |
-
num_tokens,
|
262 |
-
embedding_learning_rate ,
|
263 |
-
max_emb_train_steps ,
|
264 |
-
diffusion_model_learning_rate ,
|
265 |
-
max_diffusion_train_steps,
|
266 |
-
train_batch_size,
|
267 |
-
gradient_accumulation_steps
|
268 |
-
],
|
269 |
-
outputs = [result_info], api_name=False, concurrency_limit=45)
|
270 |
-
add_button.click(fn=immediate_update, inputs=[], outputs=[add_button])
|
271 |
#add_button.update()
|
272 |
def change_text():
|
273 |
return gr.Textbox("Optimization Finished! Move to the next step.", interactive = False)
|
@@ -292,7 +277,7 @@ with gr.Blocks() as demo:
|
|
292 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
293 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
294 |
|
295 |
-
|
296 |
def run_edit_text_wrapper(
|
297 |
mask_np_list,
|
298 |
mask_label_list,
|
@@ -324,8 +309,26 @@ with gr.Blocks() as demo:
|
|
324 |
)
|
325 |
run_edit_text()
|
326 |
return load_pil_img()
|
327 |
-
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
inputs = [ mask_np_list,
|
330 |
mask_label_list,
|
331 |
image_loaded,num_tokens_global,
|
@@ -336,8 +339,7 @@ with gr.Blocks() as demo:
|
|
336 |
tgt_prompt ,
|
337 |
slider2
|
338 |
],
|
339 |
-
outputs = [canvas_text_edit],queue=True
|
340 |
-
)
|
341 |
|
342 |
slider.change(
|
343 |
lambda x: x,
|
|
|
107 |
new_image = transparent_paste_with_mask(image, segmentation, mask_np, transparency = TRANSPARENCY)
|
108 |
return new_image, mask_label
|
109 |
def image_change():
|
110 |
+
return gr.Slider(value = 0, minimum=0, maximum=1, step=1, visible=False),gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
111 |
|
112 |
def save_as_orig_mask(mask_np_list_updated, mask_label_list, input_folder="example_tmp"):
|
113 |
print(mask_np_list_updated)
|
|
|
194 |
outputs= [canvas, label]
|
195 |
)
|
196 |
|
197 |
+
|
198 |
|
199 |
with gr.Tab(label="2 Optimization"):
|
200 |
with gr.Row():
|
|
|
244 |
)
|
245 |
run_optimization()
|
246 |
print('finish')
|
247 |
+
return "Optimization finished! Move to the next step.",gr.Button("Run Editing (Check log for progress.)",interactive = True)
|
248 |
except:
|
249 |
+
return "CUDA out of memory, use a smaller batch size or try another picture.",gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
250 |
|
251 |
|
252 |
def immediate_update():
|
253 |
return gr.Button("Run Optimization (Check log for progress.).", interactive=True)
|
254 |
+
|
255 |
+
#add_button.click(fn=immediate_update, inputs=[], outputs=[add_button])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
#add_button.update()
|
257 |
def change_text():
|
258 |
return gr.Textbox("Optimization Finished! Move to the next step.", interactive = False)
|
|
|
277 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
278 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
279 |
|
280 |
+
add_button2 = gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
281 |
def run_edit_text_wrapper(
|
282 |
mask_np_list,
|
283 |
mask_label_list,
|
|
|
309 |
)
|
310 |
run_edit_text()
|
311 |
return load_pil_img()
|
312 |
+
|
313 |
+
|
314 |
+
canvas.upload(image_change, inputs=[], outputs=[slider,add_button2])
|
315 |
+
add_button.click(run_optimization_wrapper,
|
316 |
+
inputs = [
|
317 |
+
mask_np_list,
|
318 |
+
mask_label_list,
|
319 |
+
image_loaded,
|
320 |
+
opt_flag,
|
321 |
+
num_tokens,
|
322 |
+
embedding_learning_rate ,
|
323 |
+
max_emb_train_steps ,
|
324 |
+
diffusion_model_learning_rate ,
|
325 |
+
max_diffusion_train_steps,
|
326 |
+
train_batch_size,
|
327 |
+
gradient_accumulation_steps
|
328 |
+
],
|
329 |
+
outputs = [result_info,add_button2], api_name=False, concurrency_limit=45)
|
330 |
+
|
331 |
+
add_button2.click(run_edit_text_wrapper,
|
332 |
inputs = [ mask_np_list,
|
333 |
mask_label_list,
|
334 |
image_loaded,num_tokens_global,
|
|
|
339 |
tgt_prompt ,
|
340 |
slider2
|
341 |
],
|
342 |
+
outputs = [canvas_text_edit],queue=True)
|
|
|
343 |
|
344 |
slider.change(
|
345 |
lambda x: x,
|