Joeythemonster anzorq commited on
Commit
7d758b2
·
0 Parent(s):

Duplicate from anzorq/finetuned_diffusion

Browse files

Co-authored-by: AQ <anzorq@users.noreply.huggingface.co>

Files changed (6) hide show
  1. .gitattributes +33 -0
  2. README.md +14 -0
  3. app.py +309 -0
  4. nsfw.png +0 -0
  5. requirements.txt +16 -0
  6. utils.py +6 -0
.gitattributes ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.npy filter=lfs diff=lfs merge=lfs -text
14
+ *.npz filter=lfs diff=lfs merge=lfs -text
15
+ *.onnx filter=lfs diff=lfs merge=lfs -text
16
+ *.ot filter=lfs diff=lfs merge=lfs -text
17
+ *.parquet filter=lfs diff=lfs merge=lfs -text
18
+ *.pb filter=lfs diff=lfs merge=lfs -text
19
+ *.pickle filter=lfs diff=lfs merge=lfs -text
20
+ *.pkl filter=lfs diff=lfs merge=lfs -text
21
+ *.pt filter=lfs diff=lfs merge=lfs -text
22
+ *.pth filter=lfs diff=lfs merge=lfs -text
23
+ *.rar filter=lfs diff=lfs merge=lfs -text
24
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
25
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
26
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
27
+ *.tflite filter=lfs diff=lfs merge=lfs -text
28
+ *.tgz filter=lfs diff=lfs merge=lfs -text
29
+ *.wasm filter=lfs diff=lfs merge=lfs -text
30
+ *.xz filter=lfs diff=lfs merge=lfs -text
31
+ *.zip filter=lfs diff=lfs merge=lfs -text
32
+ *.zst filter=lfs diff=lfs merge=lfs -text
33
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Finetuned Diffusion
3
+ emoji: 🪄🖼️
4
+ colorFrom: red
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 3.6
8
+ app_file: app.py
9
+ pinned: true
10
+ license: mit
11
+ duplicated_from: anzorq/finetuned_diffusion
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import AutoencoderKL, UNet2DConditionModel, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
2
+ import gradio as gr
3
+ import torch
4
+ from PIL import Image
5
+ import utils
6
+ import datetime
7
+ import time
8
+ import psutil
9
+
10
+ start_time = time.time()
11
+ is_colab = utils.is_google_colab()
12
+
13
+ class Model:
14
+ def __init__(self, name, path="", prefix=""):
15
+ self.name = name
16
+ self.path = path
17
+ self.prefix = prefix
18
+ self.pipe_t2i = None
19
+ self.pipe_i2i = None
20
+
21
+ models = [
22
+ Model("Arcane", "nitrosocke/Arcane-Diffusion", "arcane style "),
23
+ Model("Dreamlike Diffusion 1.0", "dreamlike-art/dreamlike-diffusion-1.0", "dreamlikeart "),
24
+ Model("Archer", "nitrosocke/archer-diffusion", "archer style "),
25
+ Model("Anything V3", "Linaqruf/anything-v3.0", ""),
26
+ Model("Modern Disney", "nitrosocke/mo-di-diffusion", "modern disney style "),
27
+ Model("Classic Disney", "nitrosocke/classic-anim-diffusion", "classic disney style "),
28
+ Model("Loving Vincent (Van Gogh)", "dallinmackay/Van-Gogh-diffusion", "lvngvncnt "),
29
+ Model("Wavyfusion", "wavymulder/wavyfusion", "wa-vy style "),
30
+ Model("Analog Diffusion", "wavymulder/Analog-Diffusion", "analog style "),
31
+ Model("Redshift renderer (Cinema4D)", "nitrosocke/redshift-diffusion", "redshift style "),
32
+ Model("Midjourney v4 style", "prompthero/midjourney-v4-diffusion", "mdjrny-v4 style "),
33
+ Model("Waifu", "hakurei/waifu-diffusion"),
34
+ Model("Cyberpunk Anime", "DGSpitzer/Cyberpunk-Anime-Diffusion", "dgs illustration style "),
35
+ Model("Elden Ring", "nitrosocke/elden-ring-diffusion", "elden ring style "),
36
+ Model("TrinArt v2", "naclbit/trinart_stable_diffusion_v2"),
37
+ Model("Spider-Verse", "nitrosocke/spider-verse-diffusion", "spiderverse style "),
38
+ Model("Balloon Art", "Fictiverse/Stable_Diffusion_BalloonArt_Model", "BalloonArt "),
39
+ Model("Tron Legacy", "dallinmackay/Tron-Legacy-diffusion", "trnlgcy "),
40
+ Model("Pokémon", "lambdalabs/sd-pokemon-diffusers"),
41
+ Model("Pony Diffusion", "AstraliteHeart/pony-diffusion"),
42
+ Model("Robo Diffusion", "nousr/robo-diffusion"),
43
+ ]
44
+
45
+ custom_model = None
46
+ if is_colab:
47
+ models.insert(0, Model("Custom model"))
48
+ custom_model = models[0]
49
+
50
+ last_mode = "txt2img"
51
+ current_model = models[1] if is_colab else models[0]
52
+ current_model_path = current_model.path
53
+
54
+ if is_colab:
55
+ pipe = StableDiffusionPipeline.from_pretrained(
56
+ current_model.path,
57
+ torch_dtype=torch.float16,
58
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
59
+ safety_checker=lambda images, clip_input: (images, False)
60
+ )
61
+
62
+ else:
63
+ pipe = StableDiffusionPipeline.from_pretrained(
64
+ current_model.path,
65
+ torch_dtype=torch.float16,
66
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler")
67
+ )
68
+
69
+ if torch.cuda.is_available():
70
+ pipe = pipe.to("cuda")
71
+ pipe.enable_xformers_memory_efficient_attention()
72
+
73
+ device = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
74
+
75
+ def error_str(error, title="Error"):
76
+ return f"""#### {title}
77
+ {error}""" if error else ""
78
+
79
+ def custom_model_changed(path):
80
+ models[0].path = path
81
+ global current_model
82
+ current_model = models[0]
83
+
84
+ def on_model_change(model_name):
85
+
86
+ prefix = "Enter prompt. \"" + next((m.prefix for m in models if m.name == model_name), None) + "\" is prefixed automatically" if model_name != models[0].name else "Don't forget to use the custom model prefix in the prompt!"
87
+
88
+ return gr.update(visible = model_name == models[0].name), gr.update(placeholder=prefix)
89
+
90
+ def inference(model_name, prompt, guidance, steps, n_images=1, width=512, height=512, seed=0, img=None, strength=0.5, neg_prompt=""):
91
+
92
+ print(psutil.virtual_memory()) # print memory usage
93
+
94
+ global current_model
95
+ for model in models:
96
+ if model.name == model_name:
97
+ current_model = model
98
+ model_path = current_model.path
99
+
100
+ generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
101
+
102
+ try:
103
+ if img is not None:
104
+ return img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator), None
105
+ else:
106
+ return txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator), None
107
+ except Exception as e:
108
+ return None, error_str(e)
109
+
110
+ def txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator):
111
+
112
+ print(f"{datetime.datetime.now()} txt_to_img, model: {current_model.name}")
113
+
114
+ global last_mode
115
+ global pipe
116
+ global current_model_path
117
+ if model_path != current_model_path or last_mode != "txt2img":
118
+ current_model_path = model_path
119
+
120
+ if is_colab or current_model == custom_model:
121
+ pipe = StableDiffusionPipeline.from_pretrained(
122
+ current_model_path,
123
+ torch_dtype=torch.float16,
124
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
125
+ safety_checker=lambda images, clip_input: (images, False)
126
+ )
127
+ else:
128
+ pipe = StableDiffusionPipeline.from_pretrained(
129
+ current_model_path,
130
+ torch_dtype=torch.float16,
131
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler")
132
+ )
133
+ # pipe = pipe.to("cpu")
134
+ # pipe = current_model.pipe_t2i
135
+
136
+ if torch.cuda.is_available():
137
+ pipe = pipe.to("cuda")
138
+ pipe.enable_xformers_memory_efficient_attention()
139
+ last_mode = "txt2img"
140
+
141
+ prompt = current_model.prefix + prompt
142
+ result = pipe(
143
+ prompt,
144
+ negative_prompt = neg_prompt,
145
+ num_images_per_prompt=n_images,
146
+ num_inference_steps = int(steps),
147
+ guidance_scale = guidance,
148
+ width = width,
149
+ height = height,
150
+ generator = generator)
151
+
152
+ return replace_nsfw_images(result)
153
+
154
+ def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator):
155
+
156
+ print(f"{datetime.datetime.now()} img_to_img, model: {model_path}")
157
+
158
+ global last_mode
159
+ global pipe
160
+ global current_model_path
161
+ if model_path != current_model_path or last_mode != "img2img":
162
+ current_model_path = model_path
163
+
164
+ if is_colab or current_model == custom_model:
165
+ pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
166
+ current_model_path,
167
+ torch_dtype=torch.float16,
168
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
169
+ safety_checker=lambda images, clip_input: (images, False)
170
+ )
171
+ else:
172
+ pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
173
+ current_model_path,
174
+ torch_dtype=torch.float16,
175
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler")
176
+ )
177
+ # pipe = pipe.to("cpu")
178
+ # pipe = current_model.pipe_i2i
179
+
180
+ if torch.cuda.is_available():
181
+ pipe = pipe.to("cuda")
182
+ pipe.enable_xformers_memory_efficient_attention()
183
+ last_mode = "img2img"
184
+
185
+ prompt = current_model.prefix + prompt
186
+ ratio = min(height / img.height, width / img.width)
187
+ img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
188
+ result = pipe(
189
+ prompt,
190
+ negative_prompt = neg_prompt,
191
+ num_images_per_prompt=n_images,
192
+ image = img,
193
+ num_inference_steps = int(steps),
194
+ strength = strength,
195
+ guidance_scale = guidance,
196
+ # width = width,
197
+ # height = height,
198
+ generator = generator)
199
+
200
+ return replace_nsfw_images(result)
201
+
202
+ def replace_nsfw_images(results):
203
+
204
+ if is_colab:
205
+ return results.images
206
+
207
+ for i in range(len(results.images)):
208
+ if results.nsfw_content_detected[i]:
209
+ results.images[i] = Image.open("nsfw.png")
210
+ return results.images
211
+
212
+ css = """.finetuned-diffusion-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.finetuned-diffusion-div div h1{font-weight:900;margin-bottom:7px}.finetuned-diffusion-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem}
213
+ """
214
+ with gr.Blocks(css=css) as demo:
215
+ gr.HTML(
216
+ f"""
217
+ <div class="finetuned-diffusion-div">
218
+ <div>
219
+ <h1>Finetuned Diffusion</h1>
220
+ </div>
221
+ <p>
222
+ Demo for multiple fine-tuned Stable Diffusion models, trained on different styles: <br>
223
+ <a href="https://huggingface.co/nitrosocke/Arcane-Diffusion">Arcane</a>, <a href="https://huggingface.co/nitrosocke/archer-diffusion">Archer</a>, <a href="https://huggingface.co/nitrosocke/elden-ring-diffusion">Elden Ring</a>, <a href="https://huggingface.co/nitrosocke/spider-verse-diffusion">Spider-Verse</a>, <a href="https://huggingface.co/nitrosocke/mo-di-diffusion">Modern Disney</a>, <a href="https://huggingface.co/nitrosocke/classic-anim-diffusion">Classic Disney</a>, <a href="https://huggingface.co/dallinmackay/Van-Gogh-diffusion">Loving Vincent (Van Gogh)</a>, <a href="https://huggingface.co/nitrosocke/redshift-diffusion">Redshift renderer (Cinema4D)</a>, <a href="https://huggingface.co/prompthero/midjourney-v4-diffusion">Midjourney v4 style</a>, <a href="https://huggingface.co/hakurei/waifu-diffusion">Waifu</a>, <a href="https://huggingface.co/lambdalabs/sd-pokemon-diffusers">Pokémon</a>, <a href="https://huggingface.co/AstraliteHeart/pony-diffusion">Pony Diffusion</a>, <a href="https://huggingface.co/nousr/robo-diffusion">Robo Diffusion</a>, <a href="https://huggingface.co/DGSpitzer/Cyberpunk-Anime-Diffusion">Cyberpunk Anime</a>, <a href="https://huggingface.co/dallinmackay/Tron-Legacy-diffusion">Tron Legacy</a>, <a href="https://huggingface.co/Fictiverse/Stable_Diffusion_BalloonArt_Model">Balloon Art</a> + in colab notebook you can load any other Diffusers 🧨 SD model hosted on HuggingFace 🤗.
224
+ </p>
225
+ <p>You can skip the queue and load custom models in the colab: <a href="https://colab.research.google.com/gist/qunash/42112fb104509c24fd3aa6d1c11dd6e0/copy-of-fine-tuned-diffusion-gradio.ipynb"><img data-canonical-src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" src="https://camo.githubusercontent.com/84f0493939e0c4de4e6dbe113251b4bfb5353e57134ffd9fcab6b8714514d4d1/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667"></a></p>
226
+ Running on <b>{device}</b>{(" in a <b>Google Colab</b>." if is_colab else "")}
227
+ </p>
228
+ <p>You can also duplicate this space and upgrade to gpu by going to settings:<br>
229
+ <a style="display:inline-block" href="https://huggingface.co/spaces/anzorq/finetuned_diffusion?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></p>
230
+ </div>
231
+ """
232
+ )
233
+ with gr.Row():
234
+
235
+ with gr.Column(scale=55):
236
+ with gr.Group():
237
+ model_name = gr.Dropdown(label="Model", choices=[m.name for m in models], value=current_model.name)
238
+ with gr.Box(visible=False) as custom_model_group:
239
+ custom_model_path = gr.Textbox(label="Custom model path", placeholder="Path to model, e.g. nitrosocke/Arcane-Diffusion", interactive=True)
240
+ gr.HTML("<div><font size='2'>Custom models have to be downloaded first, so give it some time.</font></div>")
241
+
242
+ with gr.Row():
243
+ prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2,placeholder="Enter prompt. Style applied automatically").style(container=False)
244
+ generate = gr.Button(value="Generate").style(rounded=(False, True, True, False))
245
+
246
+
247
+ # image_out = gr.Image(height=512)
248
+ gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
249
+
250
+ error_output = gr.Markdown()
251
+
252
+ with gr.Column(scale=45):
253
+ with gr.Tab("Options"):
254
+ with gr.Group():
255
+ neg_prompt = gr.Textbox(label="Negative prompt", placeholder="What to exclude from the image")
256
+
257
+ n_images = gr.Slider(label="Images", value=1, minimum=1, maximum=4, step=1)
258
+
259
+ with gr.Row():
260
+ guidance = gr.Slider(label="Guidance scale", value=7.5, maximum=15)
261
+ steps = gr.Slider(label="Steps", value=25, minimum=2, maximum=75, step=1)
262
+
263
+ with gr.Row():
264
+ width = gr.Slider(label="Width", value=512, minimum=64, maximum=1024, step=8)
265
+ height = gr.Slider(label="Height", value=512, minimum=64, maximum=1024, step=8)
266
+
267
+ seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
268
+
269
+ with gr.Tab("Image to image"):
270
+ with gr.Group():
271
+ image = gr.Image(label="Image", height=256, tool="editor", type="pil")
272
+ strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
273
+
274
+ if is_colab:
275
+ model_name.change(on_model_change, inputs=model_name, outputs=[custom_model_group, prompt], queue=False)
276
+ custom_model_path.change(custom_model_changed, inputs=custom_model_path, outputs=None)
277
+ # n_images.change(lambda n: gr.Gallery().style(grid=[2 if n > 1 else 1], height="auto"), inputs=n_images, outputs=gallery)
278
+
279
+ inputs = [model_name, prompt, guidance, steps, n_images, width, height, seed, image, strength, neg_prompt]
280
+ outputs = [gallery, error_output]
281
+ prompt.submit(inference, inputs=inputs, outputs=outputs)
282
+ generate.click(inference, inputs=inputs, outputs=outputs)
283
+
284
+ ex = gr.Examples([
285
+ [models[7].name, "tiny cute and adorable kitten adventurer dressed in a warm overcoat with survival gear on a winters day", 7.5, 25],
286
+ [models[4].name, "portrait of dwayne johnson", 7.0, 35],
287
+ [models[5].name, "portrait of a beautiful alyx vance half life", 10, 25],
288
+ [models[6].name, "Aloy from Horizon: Zero Dawn, half body portrait, smooth, detailed armor, beautiful face, illustration", 7.0, 30],
289
+ [models[5].name, "fantasy portrait painting, digital art", 4.0, 20],
290
+ ], inputs=[model_name, prompt, guidance, steps], outputs=outputs, fn=inference, cache_examples=False)
291
+
292
+ gr.HTML("""
293
+ <div style="border-top: 1px solid #303030;">
294
+ <br>
295
+ <p>Models by <a href="https://huggingface.co/nitrosocke">@nitrosocke</a>, <a href="https://twitter.com/haruu1367">@haruu1367</a>, <a href="https://twitter.com/DGSpitzer">@Helixngc7293</a>, <a href="https://twitter.com/dal_mack">@dal_mack</a>, <a href="https://twitter.com/prompthero">@prompthero</a> and others. ❤️</p>
296
+ <p>This space uses the <a href="https://github.com/LuChengTHU/dpm-solver">DPM-Solver++</a> sampler by <a href="https://arxiv.org/abs/2206.00927">Cheng Lu, et al.</a>.</p>
297
+ <p>Space by:<br>
298
+ <a href="https://twitter.com/hahahahohohe"><img src="https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social" alt="Twitter Follow"></a><br>
299
+ <a href="https://github.com/qunash"><img alt="GitHub followers" src="https://img.shields.io/github/followers/qunash?style=social" alt="Github Follow"></a></p><br><br>
300
+ <a href="https://www.buymeacoffee.com/anzorq" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 45px !important;width: 162px !important;" ></a><br><br>
301
+ <p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.finetuned_diffusion" alt="visitors"></p>
302
+ </div>
303
+ """)
304
+
305
+ print(f"Space built in {time.time() - start_time:.2f} seconds")
306
+
307
+ if not is_colab:
308
+ demo.queue(concurrency_count=1)
309
+ demo.launch(debug=is_colab, share=is_colab)
nsfw.png ADDED
requirements.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cu113
2
+ torch
3
+ torchvision==0.13.1+cu113
4
+ #diffusers
5
+ git+https://github.com/huggingface/diffusers.git
6
+ #transformers
7
+ git+https://github.com/huggingface/transformers
8
+ scipy
9
+ ftfy
10
+ psutil
11
+ accelerate==0.12.0
12
+ #OmegaConf
13
+ #pytorch_lightning
14
+ triton==2.0.0.dev20220701
15
+ #https://github.com/apolinario/xformers/releases/download/0.0.3/xformers-0.0.14.dev0-cp38-cp38-linux_x86_64.whl
16
+ https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+4c06c79.d20221205-cp38-cp38-linux_x86_64.whl
utils.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def is_google_colab():
2
+ try:
3
+ import google.colab
4
+ return True
5
+ except:
6
+ return False