jiayueru commited on
Commit
37ee4a4
1 Parent(s): e7c9085

update code

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +10 -0
  2. .vscode/launch.json +17 -0
  3. README.md +4 -4
  4. app.py +61 -0
  5. examples/layer/01_horse/00.jpg +0 -0
  6. examples/layer/01_horse/mask0.jpg +0 -0
  7. examples/layer/02_baby/00.jpg +0 -0
  8. examples/layer/02_baby/mask0.jpg +0 -0
  9. examples/layer/02_baby/mask1.jpg +0 -0
  10. examples/layer/02_baby/mask2.jpg +0 -0
  11. examples/layer/03_text/00.jpg +0 -0
  12. examples/layer/03_text/01.jpg +0 -0
  13. examples/layer/03_text/mask0.jpg +0 -0
  14. examples/layer/03_text/mask1.jpg +0 -0
  15. examples/layer/04_cross/0.jpg +0 -0
  16. examples/layer/04_cross/1.jpg +0 -0
  17. examples/layer/04_cross/2.jpg +0 -0
  18. examples/layer/04_cross/3.jpg +0 -0
  19. examples/layer/04_cross/mask0.jpg +0 -0
  20. examples/layer/04_cross/mask1.jpg +0 -0
  21. examples/layer/04_cross/mask2.jpg +0 -0
  22. examples/layer/04_cross/mask3.jpg +0 -0
  23. examples/moving/01_ball/0.jpg +0 -0
  24. examples/moving/01_ball/mask0.jpg +0 -0
  25. examples/moving/02_bell/0.jpg +0 -0
  26. examples/moving/02_bell/mask0.jpg +0 -0
  27. examples/pan/01.jpg +0 -0
  28. examples/pan/02.jpg +0 -0
  29. examples/pan/03.jpg +0 -0
  30. examples/pan/04.jpg +0 -0
  31. examples/pan/05.jpg +0 -0
  32. examples/pan/06.jpg +0 -0
  33. examples/remove/01_moto/0.jpg +0 -0
  34. examples/remove/01_moto/mask0.jpg +0 -0
  35. examples/remove/01_moto/mask1.jpg +0 -0
  36. examples/remove/02_ring/0.jpg +0 -0
  37. examples/remove/02_ring/mask0.jpg +0 -0
  38. examples/remove/02_ring/mask1.jpg +0 -0
  39. examples/remove/02_ring/mask2.jpg +0 -0
  40. examples/remove/03_ball/0.jpg +0 -0
  41. examples/remove/03_ball/mask0.jpg +0 -0
  42. examples/remove/03_ball/mask1.jpg +0 -0
  43. examples/remove/04_pikachu/0.jpg +0 -0
  44. examples/remove/04_pikachu/mask0.jpg +0 -0
  45. examples/remove/04_pikachu/mask1.jpg +0 -0
  46. examples/remove/04_pikachu/mask2.jpg +0 -0
  47. examples/remove/05_betty/0.jpg +0 -0
  48. examples/remove/05_betty/mask0.jpg +0 -0
  49. examples/zoom/01.jpg +0 -0
  50. examples/zoom/02.jpg +0 -0
.gitignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ img/
2
+ logfile/
3
+ __pycache__/
4
+ */__pycache__/
5
+ models/
6
+ plt/
7
+ docs/
8
+ exp/
9
+ examples/mask/
10
+ examples/mask_box/
.vscode/launch.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Demo",
9
+ "type": "debugpy",
10
+ "request": "launch",
11
+ "program": "/home/jyr/demo/DesignEdit/app.py",
12
+ "console": "integratedTerminal",
13
+ "python": "/home/jyr/.conda/envs/new_design/bin/python",
14
+
15
+ }
16
+ ]
17
+ }
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
  title: DesignEdit
3
- emoji: 🏆
4
- colorFrom: pink
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.25.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
  title: DesignEdit
3
+ emoji: 🌿
4
+ colorFrom: yellow
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 4.24.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import spaces
3
+ import torch
4
+
5
+ import os
6
+ import subprocess
7
+ import shlex
8
+ from src.demo.model import DesignEdit
9
+
10
+ os.makedirs('models', exist_ok=True)
11
+ subprocess.run(shlex.split('wget https://huggingface.co/Adapter/DragonDiffusion/resolve/main/model/efficient_sam_vits.pt -O models/efficient_sam_vits.pt'))
12
+
13
+ from src.demo.demo import *
14
+ import shlex
15
+ import cv2
16
+
17
+ pretrained_model_path = "stabilityai/stable-diffusion-xl-base-1.0"
18
+ model = DesignEdit(pretrained_model_path=pretrained_model_path)
19
+ DESCRIPTION_1 = """<div style="text-align: center; font-size: 80px;">
20
+ <strong class="title is-1">
21
+ <span style="color: green;">🌿D</span>
22
+ <span style="color: orange;">e</span>
23
+ <span style="color: rgb(63, 185, 63);">s</span>
24
+ <span style="color: green;">i</span>
25
+ <span style="color: rgb(200, 85, 23);">g</span>
26
+ <span style="color: green;">n</span>
27
+ <span style="color: orange;">E</span>
28
+ <span style="color: crimson;">d</span>
29
+ <span style="color: darkorange;">i</span>
30
+ <span style="color: green;">t🌿</span>
31
+ </strong>
32
+ </div>
33
+ """
34
+ DESCRIPTION_2 = """ <div style="text-align: center;font-size: 24px;"> <h1> Multi-Layered Latent Decomposition and Fusion for Unified & Accurate Image Editing</h1></div>"""
35
+ DESCRIPTION_3 = """
36
+ <div style="text-align: center; font-size: 24px;">
37
+ <p> Gradio demo for <a href="https://design-edit.github.io/">DesignEdit</a></p>
38
+ </div>
39
+ """
40
+
41
+
42
+ with gr.Blocks(css='style.css') as demo:
43
+ gr.HTML(DESCRIPTION_1)
44
+ gr.HTML(DESCRIPTION_2)
45
+ gr.HTML(DESCRIPTION_3)
46
+ with gr.Tabs():
47
+ with gr.TabItem('1️⃣ Object Removal'):
48
+ create_demo_remove(model.run_remove)
49
+ with gr.TabItem('2️⃣ Zooming Out'):
50
+ create_demo_zooming(model.run_zooming)
51
+ with gr.TabItem('3️⃣ Camera Panning'):
52
+ create_demo_panning(model.run_panning)
53
+ with gr.TabItem('4️⃣ Object Moving, Resizing and Flipping'):
54
+ create_demo_moving(model.run_moving)
55
+ with gr.TabItem('5️⃣ 🚩 Multi-Layered Editing 🚩'):
56
+ create_demo_layer(model.run_layer)
57
+ with gr.TabItem('🔧 Mask Preparation: Draw or Sketch'):
58
+ create_demo_mask_box(model.run_mask)
59
+ demo.queue(max_size=20)
60
+ demo.launch(max_threads=3, server_name="0.0.0.0")
61
+
examples/layer/01_horse/00.jpg ADDED
examples/layer/01_horse/mask0.jpg ADDED
examples/layer/02_baby/00.jpg ADDED
examples/layer/02_baby/mask0.jpg ADDED
examples/layer/02_baby/mask1.jpg ADDED
examples/layer/02_baby/mask2.jpg ADDED
examples/layer/03_text/00.jpg ADDED
examples/layer/03_text/01.jpg ADDED
examples/layer/03_text/mask0.jpg ADDED
examples/layer/03_text/mask1.jpg ADDED
examples/layer/04_cross/0.jpg ADDED
examples/layer/04_cross/1.jpg ADDED
examples/layer/04_cross/2.jpg ADDED
examples/layer/04_cross/3.jpg ADDED
examples/layer/04_cross/mask0.jpg ADDED
examples/layer/04_cross/mask1.jpg ADDED
examples/layer/04_cross/mask2.jpg ADDED
examples/layer/04_cross/mask3.jpg ADDED
examples/moving/01_ball/0.jpg ADDED
examples/moving/01_ball/mask0.jpg ADDED
examples/moving/02_bell/0.jpg ADDED
examples/moving/02_bell/mask0.jpg ADDED
examples/pan/01.jpg ADDED
examples/pan/02.jpg ADDED
examples/pan/03.jpg ADDED
examples/pan/04.jpg ADDED
examples/pan/05.jpg ADDED
examples/pan/06.jpg ADDED
examples/remove/01_moto/0.jpg ADDED
examples/remove/01_moto/mask0.jpg ADDED
examples/remove/01_moto/mask1.jpg ADDED
examples/remove/02_ring/0.jpg ADDED
examples/remove/02_ring/mask0.jpg ADDED
examples/remove/02_ring/mask1.jpg ADDED
examples/remove/02_ring/mask2.jpg ADDED
examples/remove/03_ball/0.jpg ADDED
examples/remove/03_ball/mask0.jpg ADDED
examples/remove/03_ball/mask1.jpg ADDED
examples/remove/04_pikachu/0.jpg ADDED
examples/remove/04_pikachu/mask0.jpg ADDED
examples/remove/04_pikachu/mask1.jpg ADDED
examples/remove/04_pikachu/mask2.jpg ADDED
examples/remove/05_betty/0.jpg ADDED
examples/remove/05_betty/mask0.jpg ADDED
examples/zoom/01.jpg ADDED
examples/zoom/02.jpg ADDED