hysts HF staff commited on
Commit
0a359f0
1 Parent(s): 0d5d967
.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
+ *.png filter=lfs diff=lfs merge=lfs -text
37
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.pre-commit-config.yaml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.4.0
4
+ hooks:
5
+ - id: check-executables-have-shebangs
6
+ - id: check-json
7
+ - id: check-merge-conflict
8
+ - id: check-shebang-scripts-are-executable
9
+ - id: check-toml
10
+ - id: check-yaml
11
+ - id: end-of-file-fixer
12
+ - id: mixed-line-ending
13
+ args: ["--fix=lf"]
14
+ - id: requirements-txt-fixer
15
+ - id: trailing-whitespace
16
+ - repo: https://github.com/myint/docformatter
17
+ rev: v1.7.5
18
+ hooks:
19
+ - id: docformatter
20
+ args: ["--in-place"]
21
+ - repo: https://github.com/pycqa/isort
22
+ rev: 5.12.0
23
+ hooks:
24
+ - id: isort
25
+ args: ["--profile", "black"]
26
+ - repo: https://github.com/pre-commit/mirrors-mypy
27
+ rev: v1.5.1
28
+ hooks:
29
+ - id: mypy
30
+ args: ["--ignore-missing-imports"]
31
+ additional_dependencies: ["types-python-slugify", "types-requests", "types-PyYAML"]
32
+ - repo: https://github.com/psf/black
33
+ rev: 23.9.1
34
+ hooks:
35
+ - id: black
36
+ language_version: python3.10
37
+ args: ["--line-length", "119"]
38
+ - repo: https://github.com/kynan/nbstripout
39
+ rev: 0.6.1
40
+ hooks:
41
+ - id: nbstripout
42
+ args: ["--extra-keys", "metadata.interpreter metadata.kernelspec cell.metadata.pycharm"]
43
+ - repo: https://github.com/nbQA-dev/nbQA
44
+ rev: 1.7.0
45
+ hooks:
46
+ - id: nbqa-black
47
+ - id: nbqa-pyupgrade
48
+ args: ["--py37-plus"]
49
+ - id: nbqa-isort
50
+ args: ["--float-to-top"]
.vscode/settings.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[python]": {
3
+ "editor.defaultFormatter": "ms-python.black-formatter",
4
+ "editor.formatOnType": true,
5
+ "editor.codeActionsOnSave": {
6
+ "source.organizeImports": true
7
+ }
8
+ },
9
+ "black-formatter.args": [
10
+ "--line-length=119"
11
+ ],
12
+ "isort.args": ["--profile", "black"],
13
+ "flake8.args": [
14
+ "--max-line-length=119"
15
+ ],
16
+ "ruff.args": [
17
+ "--line-length=119"
18
+ ],
19
+ "editor.formatOnSave": true,
20
+ "files.insertFinalNewline": true
21
+ }
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 hysts
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: BLIP Diffusion
3
  emoji: 🔥
4
  colorFrom: yellow
5
  colorTo: indigo
@@ -7,6 +7,7 @@ sdk: gradio
7
  sdk_version: 3.44.4
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: BLIP-Diffusion
3
  emoji: 🔥
4
  colorFrom: yellow
5
  colorTo: indigo
 
7
  sdk_version: 3.44.4
8
  app_file: app.py
9
  pinned: false
10
+ suggested_hardware: t4-small
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+
5
+ import gradio as gr
6
+ import torch
7
+
8
+ from app_stylization import demo as demo_stylization
9
+ from app_zero_shot import demo as demo_zero_shot
10
+
11
+ DESCRIPTION = "# [BLIP-Diffusion](https://github.com/salesforce/LAVIS/tree/main/projects/blip-diffusion)"
12
+
13
+ if not torch.cuda.is_available():
14
+ DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
15
+
16
+ with gr.Blocks(css="style.css") as demo:
17
+ gr.Markdown(DESCRIPTION)
18
+ gr.DuplicateButton(
19
+ value="Duplicate Space for private use",
20
+ elem_id="duplicate-button",
21
+ visible=os.getenv("SHOW_DUPLICATE_BUTTON") == "1",
22
+ )
23
+ with gr.Tabs():
24
+ with gr.Tab(label="Zero-shot Subject-driven Generation"):
25
+ demo_zero_shot.render()
26
+ with gr.Tab(label="Stylization"):
27
+ demo_stylization.render()
28
+
29
+ if __name__ == "__main__":
30
+ demo.queue(max_size=20).launch()
app_stylization.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import gradio as gr
4
+ import PIL.Image
5
+ import spaces
6
+ import torch
7
+ from controlnet_aux import CannyDetector
8
+ from diffusers.pipelines import BlipDiffusionControlNetPipeline
9
+
10
+ from settings import CACHE_EXAMPLES, DEFAULT_NEGATIVE_PROMPT, MAX_INFERENCE_STEPS
11
+ from utils import MAX_SEED, randomize_seed_fn
12
+
13
+ canny_detector = CannyDetector()
14
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
15
+ if torch.cuda.is_available():
16
+ pipe = BlipDiffusionControlNetPipeline.from_pretrained(
17
+ "Salesforce/blipdiffusion-controlnet", torch_dtype=torch.float16
18
+ ).to(device)
19
+ else:
20
+ pipe = None
21
+
22
+
23
+ @spaces.GPU
24
+ def run(
25
+ condition_image: PIL.Image.Image,
26
+ style_image: PIL.Image.Image,
27
+ condition_subject: str,
28
+ style_subject: str,
29
+ prompt: str,
30
+ negative_prompt: str = DEFAULT_NEGATIVE_PROMPT,
31
+ seed: int = 0,
32
+ guidance_scale: float = 7.5,
33
+ num_inference_steps: int = 25,
34
+ ) -> PIL.Image.Image:
35
+ if num_inference_steps > MAX_INFERENCE_STEPS:
36
+ raise gr.Error(f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}")
37
+ condition_image = canny_detector(condition_image, 30, 70, output_type="pil")
38
+ return pipe(
39
+ prompt,
40
+ style_image,
41
+ condition_image,
42
+ style_subject,
43
+ condition_subject,
44
+ generator=torch.Generator(device=device).manual_seed(seed),
45
+ guidance_scale=guidance_scale,
46
+ num_inference_steps=num_inference_steps,
47
+ neg_prompt=negative_prompt,
48
+ height=512,
49
+ width=512,
50
+ ).images[0]
51
+
52
+
53
+ with gr.Blocks() as demo:
54
+ with gr.Row():
55
+ with gr.Column():
56
+ with gr.Box():
57
+ condition_image = gr.Image(label="Condition Image")
58
+ style_image = gr.Image(label="Style Image")
59
+ condition_subject = gr.Textbox(label="Condition Subject")
60
+ style_subject = gr.Textbox(label="Style Subject")
61
+ prompt = gr.Textbox(label="Prompt")
62
+ run_button = gr.Button()
63
+ with gr.Accordion(label="Advanced options", open=False):
64
+ negative_prompt = gr.Textbox(label="Negative Prompt", value=DEFAULT_NEGATIVE_PROMPT)
65
+ seed = gr.Slider(
66
+ label="Seed",
67
+ minimum=0,
68
+ maximum=MAX_SEED,
69
+ step=1,
70
+ value=0,
71
+ )
72
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
73
+ guidance_scale = gr.Slider(
74
+ label="Guidance Scale",
75
+ minimum=0,
76
+ maximum=10,
77
+ step=0.1,
78
+ value=7.5,
79
+ )
80
+ num_inference_steps = gr.Slider(
81
+ label="Number of inference steps",
82
+ minimum=1,
83
+ maximum=MAX_INFERENCE_STEPS,
84
+ step=1,
85
+ value=25,
86
+ )
87
+ with gr.Column():
88
+ result = gr.Image(label="Result")
89
+
90
+ gr.Examples(
91
+ examples=[
92
+ [
93
+ "images/kettle.jpg",
94
+ "images/flower.jpg",
95
+ "teapot",
96
+ "flower",
97
+ "on a marble table",
98
+ ],
99
+ ],
100
+ inputs=[
101
+ condition_image,
102
+ style_image,
103
+ condition_subject,
104
+ style_subject,
105
+ prompt,
106
+ ],
107
+ outputs=result,
108
+ fn=run,
109
+ cache_examples=CACHE_EXAMPLES,
110
+ )
111
+
112
+ inputs = [
113
+ condition_image,
114
+ style_image,
115
+ condition_subject,
116
+ style_subject,
117
+ prompt,
118
+ negative_prompt,
119
+ seed,
120
+ guidance_scale,
121
+ num_inference_steps,
122
+ ]
123
+ condition_subject.submit(
124
+ fn=randomize_seed_fn,
125
+ inputs=[seed, randomize_seed],
126
+ outputs=seed,
127
+ queue=False,
128
+ api_name=False,
129
+ ).then(
130
+ fn=run,
131
+ inputs=inputs,
132
+ outputs=result,
133
+ api_name=False,
134
+ )
135
+ style_subject.submit(
136
+ fn=randomize_seed_fn,
137
+ inputs=[seed, randomize_seed],
138
+ outputs=seed,
139
+ queue=False,
140
+ api_name=False,
141
+ ).then(
142
+ fn=run,
143
+ inputs=inputs,
144
+ outputs=result,
145
+ api_name=False,
146
+ )
147
+ prompt.submit(
148
+ fn=randomize_seed_fn,
149
+ inputs=[seed, randomize_seed],
150
+ outputs=seed,
151
+ queue=False,
152
+ api_name=False,
153
+ ).then(
154
+ fn=run,
155
+ inputs=inputs,
156
+ outputs=result,
157
+ api_name=False,
158
+ )
159
+ negative_prompt.submit(
160
+ fn=randomize_seed_fn,
161
+ inputs=[seed, randomize_seed],
162
+ outputs=seed,
163
+ queue=False,
164
+ api_name=False,
165
+ ).then(
166
+ fn=run,
167
+ inputs=inputs,
168
+ outputs=result,
169
+ api_name=False,
170
+ )
171
+ run_button.click(
172
+ fn=randomize_seed_fn,
173
+ inputs=[seed, randomize_seed],
174
+ outputs=seed,
175
+ queue=False,
176
+ api_name=False,
177
+ ).then(
178
+ fn=run,
179
+ inputs=inputs,
180
+ outputs=result,
181
+ api_name="run-stylization",
182
+ )
183
+
184
+ if __name__ == "__main__":
185
+ demo.queue(max_size=20).launch()
app_zero_shot.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import gradio as gr
4
+ import PIL.Image
5
+ import spaces
6
+ import torch
7
+ from diffusers.pipelines import BlipDiffusionPipeline
8
+
9
+ from settings import CACHE_EXAMPLES, DEFAULT_NEGATIVE_PROMPT, MAX_INFERENCE_STEPS
10
+ from utils import MAX_SEED, randomize_seed_fn
11
+
12
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
13
+ if torch.cuda.is_available():
14
+ pipe = BlipDiffusionPipeline.from_pretrained("Salesforce/blipdiffusion", torch_dtype=torch.float16).to(device)
15
+ else:
16
+ pipe = None
17
+
18
+
19
+ @spaces.GPU
20
+ def run(
21
+ condition_image: PIL.Image.Image,
22
+ condition_subject: str,
23
+ target_subject: str,
24
+ prompt: str,
25
+ negative_prompt: str = DEFAULT_NEGATIVE_PROMPT,
26
+ seed: int = 0,
27
+ guidance_scale: float = 7.5,
28
+ num_inference_steps: int = 25,
29
+ ) -> PIL.Image.Image:
30
+ if num_inference_steps > MAX_INFERENCE_STEPS:
31
+ raise gr.Error(f"Number of inference steps must be less than {MAX_INFERENCE_STEPS}")
32
+ return pipe(
33
+ prompt,
34
+ condition_image,
35
+ condition_subject,
36
+ target_subject,
37
+ generator=torch.Generator(device=device).manual_seed(seed),
38
+ guidance_scale=guidance_scale,
39
+ num_inference_steps=num_inference_steps,
40
+ neg_prompt=negative_prompt,
41
+ height=512,
42
+ width=512,
43
+ ).images[0]
44
+
45
+
46
+ with gr.Blocks() as demo:
47
+ with gr.Row():
48
+ with gr.Column():
49
+ with gr.Box():
50
+ condition_image = gr.Image(label="Condition Image")
51
+ condition_subject = gr.Textbox(label="Condition Subject")
52
+ target_subject = gr.Textbox(label="Target Subject")
53
+ prompt = gr.Textbox(label="Prompt")
54
+ run_button = gr.Button()
55
+ with gr.Accordion(label="Advanced options", open=False):
56
+ negative_prompt = gr.Textbox(label="Negative Prompt", value=DEFAULT_NEGATIVE_PROMPT)
57
+ seed = gr.Slider(
58
+ label="Seed",
59
+ minimum=0,
60
+ maximum=MAX_SEED,
61
+ step=1,
62
+ value=0,
63
+ )
64
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
65
+ guidance_scale = gr.Slider(
66
+ label="Guidance Scale",
67
+ minimum=0,
68
+ maximum=10,
69
+ step=0.1,
70
+ value=7.5,
71
+ )
72
+ num_inference_steps = gr.Slider(
73
+ label="Number of inference steps",
74
+ minimum=1,
75
+ maximum=MAX_INFERENCE_STEPS,
76
+ step=1,
77
+ value=25,
78
+ )
79
+ with gr.Column():
80
+ result = gr.Image(label="Result")
81
+
82
+ gr.Examples(
83
+ examples=[
84
+ [
85
+ "images/dog.png",
86
+ "dog",
87
+ "dog",
88
+ "swimming underwater",
89
+ ],
90
+ ],
91
+ inputs=[
92
+ condition_image,
93
+ condition_subject,
94
+ target_subject,
95
+ prompt,
96
+ ],
97
+ outputs=result,
98
+ fn=run,
99
+ cache_examples=CACHE_EXAMPLES,
100
+ )
101
+
102
+ inputs = [
103
+ condition_image,
104
+ condition_subject,
105
+ target_subject,
106
+ prompt,
107
+ negative_prompt,
108
+ seed,
109
+ guidance_scale,
110
+ num_inference_steps,
111
+ ]
112
+ condition_subject.submit(
113
+ fn=randomize_seed_fn,
114
+ inputs=[seed, randomize_seed],
115
+ outputs=seed,
116
+ queue=False,
117
+ api_name=False,
118
+ ).then(
119
+ fn=run,
120
+ inputs=inputs,
121
+ outputs=result,
122
+ api_name=False,
123
+ )
124
+ target_subject.submit(
125
+ fn=randomize_seed_fn,
126
+ inputs=[seed, randomize_seed],
127
+ outputs=seed,
128
+ queue=False,
129
+ api_name=False,
130
+ ).then(
131
+ fn=run,
132
+ inputs=inputs,
133
+ outputs=result,
134
+ api_name=False,
135
+ )
136
+ prompt.submit(
137
+ fn=randomize_seed_fn,
138
+ inputs=[seed, randomize_seed],
139
+ outputs=seed,
140
+ queue=False,
141
+ api_name=False,
142
+ ).then(
143
+ fn=run,
144
+ inputs=inputs,
145
+ outputs=result,
146
+ api_name=False,
147
+ )
148
+ negative_prompt.submit(
149
+ fn=randomize_seed_fn,
150
+ inputs=[seed, randomize_seed],
151
+ outputs=seed,
152
+ queue=False,
153
+ api_name=False,
154
+ ).then(
155
+ fn=run,
156
+ inputs=inputs,
157
+ outputs=result,
158
+ api_name=False,
159
+ )
160
+ run_button.click(
161
+ fn=randomize_seed_fn,
162
+ inputs=[seed, randomize_seed],
163
+ outputs=seed,
164
+ queue=False,
165
+ api_name=False,
166
+ ).then(
167
+ fn=run,
168
+ inputs=inputs,
169
+ outputs=result,
170
+ api_name="run-zero-shot",
171
+ )
172
+
173
+ if __name__ == "__main__":
174
+ demo.queue(max_size=20).launch()
images/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022 Salesforce, Inc.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ 3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
images/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # About these images
2
+
3
+ These images were obtained from [this link](https://github.com/salesforce/LAVIS/tree/e4040b13d6120062829ee9625f016f3cd3dd16e6/projects/blip-diffusion/images).
4
+ The original repository is licensed under the BSD-3-Clause license.
images/black-cat.png ADDED

Git LFS Details

  • SHA256: 7fc1587eb3b84f0c5ab53fce415fff1b54e8645dca75aa606e093c096c0cd4cd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.36 MB
images/cat-sofa.png ADDED

Git LFS Details

  • SHA256: 3c56e4b0fc63219ac314b706d49eae3fa9ca78f55ac896e72aea5ff60261eb3f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.05 MB
images/dog.png ADDED

Git LFS Details

  • SHA256: 7016755ad4fcb318adf4ecf1931326915dcd070694dd08c381158c6b697f6d32
  • Pointer size: 132 Bytes
  • Size of remote file: 1.63 MB
images/dog2.png ADDED

Git LFS Details

  • SHA256: bcc1d523d90ea1aaea9d0d4ab92f9bfb21109d14fa477f1359600c9ff7a2ae07
  • Pointer size: 132 Bytes
  • Size of remote file: 2.03 MB
images/flower.jpg ADDED

Git LFS Details

  • SHA256: 158c306ca8aedd9ad32dd119d0152e3331d514e0f20438c5b6e55deea30b567b
  • Pointer size: 130 Bytes
  • Size of remote file: 20.4 kB
images/kettle.jpg ADDED

Git LFS Details

  • SHA256: 67dad2d6088cba54920382b9b8065393fc55b5d9709ae06ab296f54b297c3fb7
  • Pointer size: 130 Bytes
  • Size of remote file: 74.7 kB
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ controlnet_aux==0.0.7
2
+ git+https://github.com/huggingface/diffusers@5b11c5d
3
+ gradio==3.44.4
4
+ Pillow==10.0.1
5
+ spaces==0.14.0
6
+ torch==2.0.0
7
+ torchvision==0.15.1
8
+ transformers==4.33.2
settings.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import os
2
+
3
+ MAX_INFERENCE_STEPS = 50
4
+ DEFAULT_NEGATIVE_PROMPT = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
5
+ CACHE_EXAMPLES = os.getenv("CACHE_EXAMPLES") == "1"
style.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ h1 {
2
+ text-align: center;
3
+ }
4
+
5
+ #duplicate-button {
6
+ margin: auto;
7
+ color: #fff;
8
+ background: #1565c0;
9
+ border-radius: 100vh;
10
+ }
utils.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ import numpy as np
4
+
5
+ MAX_SEED = np.iinfo(np.int32).max
6
+
7
+
8
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
9
+ if randomize_seed:
10
+ seed = random.randint(0, MAX_SEED)
11
+ return seed