hysts HF staff commited on
Commit
130100d
1 Parent(s): 2ddc02c

Add examples

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
37
+ *.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio_cached_examples/
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
app_base.py CHANGED
@@ -1,7 +1,10 @@
1
  #!/usr/bin/env python
2
 
 
 
3
  import gradio as gr
4
  import PIL.Image
 
5
 
6
  from model import ADAPTER_NAMES, Model
7
  from utils import (
@@ -12,6 +15,8 @@ from utils import (
12
  randomize_seed_fn,
13
  )
14
 
 
 
15
 
16
  def create_demo(model: Model) -> gr.Blocks:
17
  def run(
@@ -43,6 +48,61 @@ def create_demo(model: Model) -> gr.Blocks:
43
  apply_preprocess=apply_preprocess,
44
  )
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  with gr.Blocks() as demo:
47
  with gr.Row():
48
  with gr.Column():
@@ -94,6 +154,20 @@ def create_demo(model: Model) -> gr.Blocks:
94
  with gr.Column():
95
  result = gr.Gallery(label="Result", columns=2, height=600, object_fit="scale-down", show_label=False)
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  inputs = [
98
  image,
99
  prompt,
 
1
  #!/usr/bin/env python
2
 
3
+ import os
4
+
5
  import gradio as gr
6
  import PIL.Image
7
+ from diffusers.utils import load_image
8
 
9
  from model import ADAPTER_NAMES, Model
10
  from utils import (
 
15
  randomize_seed_fn,
16
  )
17
 
18
+ CACHE_EXAMPLES = os.environ.get("CACHE_EXAMPLES") == "1"
19
+
20
 
21
  def create_demo(model: Model) -> gr.Blocks:
22
  def run(
 
48
  apply_preprocess=apply_preprocess,
49
  )
50
 
51
+ def process_example(
52
+ image_url: str,
53
+ prompt: str,
54
+ adapter_name: str,
55
+ seed: int,
56
+ apply_preprocess: bool,
57
+ ) -> list[PIL.Image.Image]:
58
+ image = load_image(image_url)
59
+ return run(
60
+ image=image,
61
+ prompt=prompt,
62
+ negative_prompt="",
63
+ adapter_name=adapter_name,
64
+ seed=seed,
65
+ apply_preprocess=apply_preprocess,
66
+ )
67
+
68
+ examples = [
69
+ [
70
+ "assets/org_canny.jpg",
71
+ "Mystical fairy in real, magic, 4k picture, high quality",
72
+ "TencentARC/t2i-adapter-canny-sdxl-1.0",
73
+ 0,
74
+ True,
75
+ ],
76
+ [
77
+ "assets/org_sketch.png",
78
+ "a robot, mount fuji in the background, 4k photo, highly detailed",
79
+ "TencentARC/t2i-adapter-sketch-sdxl-1.0",
80
+ 0,
81
+ True,
82
+ ],
83
+ [
84
+ "assets/org_lin.jpg",
85
+ "Ice dragon roar, 4k photo",
86
+ "TencentARC/t2i-adapter-lineart-sdxl-1.0",
87
+ 0,
88
+ True,
89
+ ],
90
+ [
91
+ "assets/org_mid.jpg",
92
+ "A photo of a room, 4k photo, highly detailed",
93
+ "TencentARC/t2i-adapter-depth-midas-sdxl-1.0",
94
+ 0,
95
+ True,
96
+ ],
97
+ [
98
+ "assets/org_zoe.jpg",
99
+ "A photo of a orchid, 4k photo, highly detailed",
100
+ "TencentARC/t2i-adapter-depth-zoe-sdxl-1.0",
101
+ 0,
102
+ True,
103
+ ],
104
+ ]
105
+
106
  with gr.Blocks() as demo:
107
  with gr.Row():
108
  with gr.Column():
 
154
  with gr.Column():
155
  result = gr.Gallery(label="Result", columns=2, height=600, object_fit="scale-down", show_label=False)
156
 
157
+ gr.Examples(
158
+ examples=examples,
159
+ inputs=[
160
+ image,
161
+ prompt,
162
+ adapter_name,
163
+ seed,
164
+ apply_preprocess,
165
+ ],
166
+ outputs=result,
167
+ fn=process_example,
168
+ cache_examples=CACHE_EXAMPLES,
169
+ )
170
+
171
  inputs = [
172
  image,
173
  prompt,
assets/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ These images were from the following URL:
2
+
3
+ - https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_canny.jpg
4
+ - https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_sketch.png
5
+ - https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_lin.jpg
6
+ - https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_mid.jpg
7
+ - https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_zeo.jpg
assets/org_canny.jpg ADDED

Git LFS Details

  • SHA256: 4abbcfe7d701c9a755fe31ac221a544361757b5bbc7a2d438a7706938197a7ae
  • Pointer size: 130 Bytes
  • Size of remote file: 15.7 kB
assets/org_lin.jpg ADDED

Git LFS Details

  • SHA256: 6b86aca15431b682a5215791cfc25dd35f156e636c2244e98c6f7d8f40cf9cd5
  • Pointer size: 132 Bytes
  • Size of remote file: 3.27 MB
assets/org_mid.jpg ADDED

Git LFS Details

  • SHA256: e738ff380ca60fe2bb29ddfb908e1d478861dba668b7e37ca0ac613e18e05025
  • Pointer size: 131 Bytes
  • Size of remote file: 119 kB
assets/org_sketch.png ADDED

Git LFS Details

  • SHA256: 91afb4bfe7203f154d4c4e9ce271dd9ed7855cebc9a90bc757180295d9e71be5
  • Pointer size: 131 Bytes
  • Size of remote file: 361 kB
assets/org_zoe.jpg ADDED

Git LFS Details

  • SHA256: 5dbb908aa3508b933f9620c76e51b4c20aa394e6a567a4425595c77ac829079d
  • Pointer size: 130 Bytes
  • Size of remote file: 12.4 kB