Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -105,7 +105,7 @@ def slider_release(index, image, mask_np_list_updated, mask_label_list):
|
|
105 |
new_image = transparent_paste_with_mask(image, segmentation, mask_np, transparency = TRANSPARENCY)
|
106 |
return new_image, mask_label
|
107 |
def image_change():
|
108 |
-
return gr.Slider(value = 0, minimum=0, maximum=1, step=1, visible=False),gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
109 |
|
110 |
def save_as_orig_mask(mask_np_list_updated, mask_label_list, input_folder="example_tmp"):
|
111 |
print(mask_np_list_updated)
|
@@ -177,7 +177,7 @@ with gr.Blocks() as demo:
|
|
177 |
|
178 |
with gr.Column():
|
179 |
result_info0 = gr.Text(label="Response")
|
180 |
-
segment_button = gr.Button("Run segmentation")
|
181 |
flag = gr.State(False)
|
182 |
|
183 |
# mask_np_list_updated.value = copy.deepcopy(mask_np_list.value) #!!
|
@@ -211,7 +211,7 @@ with gr.Blocks() as demo:
|
|
211 |
train_batch_size = gr.Number(value="20", label="Batch size", interactive= True )
|
212 |
gradient_accumulation_steps=gr.Number(value="2", label="Gradient accumulation", interactive= True )
|
213 |
|
214 |
-
add_button = gr.Button("Run optimization")
|
215 |
def run_optimization_wrapper (
|
216 |
mask_np_list,
|
217 |
mask_label_list,
|
@@ -241,11 +241,11 @@ with gr.Blocks() as demo:
|
|
241 |
)
|
242 |
run_optimization()
|
243 |
gr.Info("Optimization Finished! Move to the next step.")
|
244 |
-
return "Optimization finished! Move to the next step.",gr.Button("Run Editing (Check log for progress.)",interactive = True)
|
245 |
except Exception as e:
|
246 |
print(e)
|
247 |
gr.Error("e")
|
248 |
-
return "Error: use a smaller batch size or try latter.",gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
249 |
|
250 |
|
251 |
|
@@ -268,7 +268,7 @@ with gr.Blocks() as demo:
|
|
268 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
269 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
270 |
|
271 |
-
add_button2 = gr.Button("Run Editing (Check log for progress.)",interactive = False)
|
272 |
def run_edit_text_wrapper(
|
273 |
mask_np_list,
|
274 |
mask_label_list,
|
|
|
105 |
new_image = transparent_paste_with_mask(image, segmentation, mask_np, transparency = TRANSPARENCY)
|
106 |
return new_image, mask_label
|
107 |
def image_change():
|
108 |
+
return gr.Slider(value = 0, minimum=0, maximum=1, step=1, visible=False),gr.Button("Step 3. Run Editing (Check log for progress.)",interactive = False)
|
109 |
|
110 |
def save_as_orig_mask(mask_np_list_updated, mask_label_list, input_folder="example_tmp"):
|
111 |
print(mask_np_list_updated)
|
|
|
177 |
|
178 |
with gr.Column():
|
179 |
result_info0 = gr.Text(label="Response")
|
180 |
+
segment_button = gr.Button("Step 1. Run segmentation")
|
181 |
flag = gr.State(False)
|
182 |
|
183 |
# mask_np_list_updated.value = copy.deepcopy(mask_np_list.value) #!!
|
|
|
211 |
train_batch_size = gr.Number(value="20", label="Batch size", interactive= True )
|
212 |
gradient_accumulation_steps=gr.Number(value="2", label="Gradient accumulation", interactive= True )
|
213 |
|
214 |
+
add_button = gr.Button("Step 2. Run optimization")
|
215 |
def run_optimization_wrapper (
|
216 |
mask_np_list,
|
217 |
mask_label_list,
|
|
|
241 |
)
|
242 |
run_optimization()
|
243 |
gr.Info("Optimization Finished! Move to the next step.")
|
244 |
+
return "Optimization finished! Move to the next step.",gr.Button("Step 3. Run Editing (Check log for progress.)",interactive = True)
|
245 |
except Exception as e:
|
246 |
print(e)
|
247 |
gr.Error("e")
|
248 |
+
return "Error: use a smaller batch size or try latter.",gr.Button("Step 3. Run Editing (Check log for progress.)",interactive = False)
|
249 |
|
250 |
|
251 |
|
|
|
268 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
269 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
270 |
|
271 |
+
add_button2 = gr.Button("Step 3. Run Editing (Check log for progress.)",interactive = False)
|
272 |
def run_edit_text_wrapper(
|
273 |
mask_np_list,
|
274 |
mask_label_list,
|