jiayueru commited on
Commit
3cf5640
β€’
1 Parent(s): 7e07857
Files changed (5) hide show
  1. .gitignore +2 -1
  2. README.md +1 -1
  3. app.py +2 -0
  4. requirements.txt +1 -1
  5. src/demo/demo.py +8 -0
.gitignore CHANGED
@@ -4,4 +4,5 @@ __pycache__/
4
  */__pycache__/
5
  models/
6
  plt/
7
- exp/
 
 
4
  */__pycache__/
5
  models/
6
  plt/
7
+ exp/
8
+ test_app.py
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: DesignEdit
3
- emoji: ⚑
4
  colorFrom: pink
5
  colorTo: pink
6
  sdk: gradio
 
1
  ---
2
  title: DesignEdit
3
+ emoji: 🌿🌼🌿
4
  colorFrom: pink
5
  colorTo: pink
6
  sdk: gradio
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import subprocess
3
  import shlex
4
  from src.demo.model import DesignEdit
 
5
 
6
  os.makedirs('models', exist_ok=True)
7
  subprocess.run(shlex.split('wget https://huggingface.co/Adapter/DragonDiffusion/resolve/main/model/efficient_sam_vits.pt -O models/efficient_sam_vits.pt'))
@@ -52,6 +53,7 @@ with gr.Blocks(css='style.css') as demo:
52
  create_demo_layer(model.run_layer)
53
  with gr.TabItem('πŸ”§ Mask Preparation: Draw or Sketch'):
54
  create_demo_mask_box(model.run_mask)
 
55
  demo.queue(concurrency_count=3, max_size=20)
56
  demo.launch(server_name="0.0.0.0")
57
 
 
2
  import subprocess
3
  import shlex
4
  from src.demo.model import DesignEdit
5
+ import spaces
6
 
7
  os.makedirs('models', exist_ok=True)
8
  subprocess.run(shlex.split('wget https://huggingface.co/Adapter/DragonDiffusion/resolve/main/model/efficient_sam_vits.pt -O models/efficient_sam_vits.pt'))
 
53
  create_demo_layer(model.run_layer)
54
  with gr.TabItem('πŸ”§ Mask Preparation: Draw or Sketch'):
55
  create_demo_mask_box(model.run_mask)
56
+
57
  demo.queue(concurrency_count=3, max_size=20)
58
  demo.launch(server_name="0.0.0.0")
59
 
requirements.txt CHANGED
@@ -9,7 +9,7 @@ torch==2.0.1
9
  torchvision==0.15.2
10
  tqdm==4.65.0
11
  transformers==4.35.0
12
- gradio==3.50.2
13
  basicsr==1.4.2
14
  accelerate==0.21.0
15
  invisible-watermark
 
9
  torchvision==0.15.2
10
  tqdm==4.65.0
11
  transformers==4.35.0
12
+ gradio==4.0.0
13
  basicsr==1.4.2
14
  accelerate==0.21.0
15
  invisible-watermark
src/demo/demo.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  import numpy as np
3
  from src.demo.utils import get_point, store_img, get_point_move, store_img_move, clear_points, upload_image_move, segment_with_points, segment_with_points_paste, fun_clear, paste_with_mask_and_offset
 
 
4
 
5
  examples_remove = [
6
  [
@@ -165,6 +167,7 @@ examples_layer = [
165
  ]
166
 
167
  # 01
 
168
  def create_demo_remove(runner=None):
169
  DESCRIPTION = """
170
  # Object Removal
@@ -273,6 +276,7 @@ def create_demo_remove(runner=None):
273
 
274
 
275
  # 02:
 
276
  def create_demo_zooming(runner=None):
277
  DESCRIPTION = """
278
  # Zooming Out
@@ -342,6 +346,7 @@ def create_demo_zooming(runner=None):
342
  outputs=[original_image, width_scale, height_scale, output, new_image, new_mask])
343
  return demo
344
  # 03
 
345
  def create_demo_panning(runner=None):
346
  DESCRIPTION = """
347
  # Camera Panning
@@ -410,6 +415,7 @@ def create_demo_panning(runner=None):
410
  outputs=[original_image, w_direction, w_scale, h_direction, h_scale, new_image, new_mask, output])
411
  return demo
412
  # 04:
 
413
  def create_position_size(label=None):
414
  image = gr.Image(source='upload', label=label, interactive=True, type="numpy")
415
  with gr.Row():
@@ -442,6 +448,7 @@ def create_position_size(label=None):
442
  h_flip = gr.Radio(["down/up", "None"], value="None", label="Vertical Flip")
443
  return image, dx, dy, resize_scale, w_flip, h_flip
444
  # 05:
 
445
  def create_demo_layer(runner=None):
446
  DESCRIPTION = """
447
  # 🚩 Multi-Layered Editing 🚩
@@ -555,6 +562,7 @@ def create_demo_layer(runner=None):
555
  return demo
556
 
557
  # 06:
 
558
  def create_demo_mask_box(runner=None):
559
  DESCRIPTION = """
560
  # πŸ”§ Mask Preparation
 
1
  import gradio as gr
2
  import numpy as np
3
  from src.demo.utils import get_point, store_img, get_point_move, store_img_move, clear_points, upload_image_move, segment_with_points, segment_with_points_paste, fun_clear, paste_with_mask_and_offset
4
+ import spaces
5
+
6
 
7
  examples_remove = [
8
  [
 
167
  ]
168
 
169
  # 01
170
+ @spaces.GPU
171
  def create_demo_remove(runner=None):
172
  DESCRIPTION = """
173
  # Object Removal
 
276
 
277
 
278
  # 02:
279
+ @spaces.GPU
280
  def create_demo_zooming(runner=None):
281
  DESCRIPTION = """
282
  # Zooming Out
 
346
  outputs=[original_image, width_scale, height_scale, output, new_image, new_mask])
347
  return demo
348
  # 03
349
+ @spaces.GPU
350
  def create_demo_panning(runner=None):
351
  DESCRIPTION = """
352
  # Camera Panning
 
415
  outputs=[original_image, w_direction, w_scale, h_direction, h_scale, new_image, new_mask, output])
416
  return demo
417
  # 04:
418
+ @spaces.GPU
419
  def create_position_size(label=None):
420
  image = gr.Image(source='upload', label=label, interactive=True, type="numpy")
421
  with gr.Row():
 
448
  h_flip = gr.Radio(["down/up", "None"], value="None", label="Vertical Flip")
449
  return image, dx, dy, resize_scale, w_flip, h_flip
450
  # 05:
451
+ @spaces.GPU
452
  def create_demo_layer(runner=None):
453
  DESCRIPTION = """
454
  # 🚩 Multi-Layered Editing 🚩
 
562
  return demo
563
 
564
  # 06:
565
+ @spaces.GPU
566
  def create_demo_mask_box(runner=None):
567
  DESCRIPTION = """
568
  # πŸ”§ Mask Preparation