niulx commited on
Commit
d75d92e
1 Parent(s): 21595c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- os.system("pip install opencv-python")
3
  # os.system("pip uninstall -y gradio")
4
  # os.system("pip install gradio==3.41.0")
5
 
@@ -206,7 +205,6 @@ with gr.Blocks() as demo:
206
 
207
  segment_button = gr.Button("1.1 Run segmentation")
208
 
209
- text_button = gr.Button("Waiting 1.1 to complete",visible = False)
210
 
211
 
212
  flag = gr.State(False)
@@ -226,7 +224,6 @@ with gr.Blocks() as demo:
226
 
227
 
228
 
229
- #canvas.upload(image_change, inputs=[], outputs=[text_button])
230
 
231
 
232
  with gr.Tab(label="2 Optimization"):
@@ -238,11 +235,11 @@ with gr.Blocks() as demo:
238
  gr.Markdown("""<p style="text-align: center; font-size: 20px">Optimization settings (SD)</p>""")
239
  num_tokens = gr.Number(value="5", label="num tokens to represent each object", interactive= True)
240
  num_tokens_global = num_tokens
241
- embedding_learning_rate = gr.Textbox(value="0.0001", label="Embedding optimization: Learning rate", interactive= True )
242
- max_emb_train_steps = gr.Number(value="200", label="embedding optimization: Training steps", interactive= True )
243
 
244
- diffusion_model_learning_rate = gr.Textbox(value="0.00005", label="UNet Optimization: Learning rate", interactive= True )
245
- max_diffusion_train_steps = gr.Number(value="200", label="UNet Optimization: Learning rate: Training steps", interactive= True )
246
 
247
  train_batch_size = gr.Number(value="5", label="Batch size", interactive= True )
248
  gradient_accumulation_steps=gr.Number(value="5", label="Gradient accumulation", interactive= True )
@@ -261,7 +258,7 @@ with gr.Blocks() as demo:
261
  train_batch_size,
262
  gradient_accumulation_steps,
263
  ):
264
- if 1:
265
  run_optimization = partial(
266
  run_main,
267
  mask_np_list=mask_np_list,
@@ -278,8 +275,8 @@ with gr.Blocks() as demo:
278
  run_optimization()
279
  print('finish')
280
  return "Optimization finished!"
281
- #except:
282
- # return "CUDA out of memory, use a smaller batch size or try another picture."
283
 
284
 
285
  def immediate_update():
@@ -378,8 +375,6 @@ with gr.Blocks() as demo:
378
  outputs=[slider2]
379
  )
380
 
381
- #text_button.click(load_image_ui, [false] ,
382
- # [image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider, slider2] )
383
 
384
  segment_button.click(run_segmentation_wrapper,
385
  [canvas] ,
 
1
  import os
 
2
  # os.system("pip uninstall -y gradio")
3
  # os.system("pip install gradio==3.41.0")
4
 
 
205
 
206
  segment_button = gr.Button("1.1 Run segmentation")
207
 
 
208
 
209
 
210
  flag = gr.State(False)
 
224
 
225
 
226
 
 
227
 
228
 
229
  with gr.Tab(label="2 Optimization"):
 
235
  gr.Markdown("""<p style="text-align: center; font-size: 20px">Optimization settings (SD)</p>""")
236
  num_tokens = gr.Number(value="5", label="num tokens to represent each object", interactive= True)
237
  num_tokens_global = num_tokens
238
+ embedding_learning_rate = gr.Textbox(value="0.00005", label="Embedding optimization: Learning rate", interactive= True )
239
+ max_emb_train_steps = gr.Number(value="100", label="embedding optimization: Training steps", interactive= True )
240
 
241
+ diffusion_model_learning_rate = gr.Textbox(value="0.00002", label="UNet Optimization: Learning rate", interactive= True )
242
+ max_diffusion_train_steps = gr.Number(value="100", label="UNet Optimization: Learning rate: Training steps", interactive= True )
243
 
244
  train_batch_size = gr.Number(value="5", label="Batch size", interactive= True )
245
  gradient_accumulation_steps=gr.Number(value="5", label="Gradient accumulation", interactive= True )
 
258
  train_batch_size,
259
  gradient_accumulation_steps,
260
  ):
261
+ try:
262
  run_optimization = partial(
263
  run_main,
264
  mask_np_list=mask_np_list,
 
275
  run_optimization()
276
  print('finish')
277
  return "Optimization finished!"
278
+ except:
279
+ return "CUDA out of memory, use a smaller batch size or try another picture."
280
 
281
 
282
  def immediate_update():
 
375
  outputs=[slider2]
376
  )
377
 
 
 
378
 
379
  segment_button.click(run_segmentation_wrapper,
380
  [canvas] ,