Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,19 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 9 |
context = autocast if device == "cuda" else nullcontext
|
| 10 |
dtype = torch.float16 if device == "cuda" else torch.float32
|
| 11 |
|
| 12 |
-
|
| 13 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=dtype)
|
| 14 |
pipe = pipe.to(device)
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def infer(prompt, n_samples, steps, scale):
|
| 19 |
|
|
@@ -107,17 +115,17 @@ block = gr.Blocks(css=css)
|
|
| 107 |
|
| 108 |
examples = [
|
| 109 |
[
|
| 110 |
-
'
|
| 111 |
2,
|
| 112 |
7.5,
|
| 113 |
],
|
| 114 |
[
|
| 115 |
-
'
|
| 116 |
2,
|
| 117 |
7.5,
|
| 118 |
],
|
| 119 |
[
|
| 120 |
-
'
|
| 121 |
2,
|
| 122 |
7,
|
| 123 |
],
|
|
@@ -131,9 +139,13 @@ with block:
|
|
| 131 |
<img class="logo" src="https://lambdalabs.com/hubfs/logos/lambda-logo.svg" alt="Lambda Logo"
|
| 132 |
style="margin: auto; max-width: 7rem;">
|
| 133 |
<h1 style="font-weight: 900; font-size: 3rem;">
|
| 134 |
-
|
| 135 |
</h1>
|
| 136 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
</div>
|
| 138 |
"""
|
| 139 |
)
|
|
@@ -162,7 +174,7 @@ with block:
|
|
| 162 |
|
| 163 |
with gr.Row(elem_id="advanced-options"):
|
| 164 |
samples = gr.Slider(label="Images", minimum=1, maximum=4, value=2, step=1)
|
| 165 |
-
steps = gr.Slider(label="Steps", minimum=5, maximum=50, value=
|
| 166 |
scale = gr.Slider(
|
| 167 |
label="Guidance Scale", minimum=0, maximum=50, value=7.5, step=0.1
|
| 168 |
)
|
|
@@ -181,8 +193,9 @@ with block:
|
|
| 181 |
</p>
|
| 182 |
</div>
|
| 183 |
<div class="acknowledgments">
|
| 184 |
-
<p> Put in a text prompt and generate your own
|
| 185 |
<p>If you want to find out how we made this model read about it in <a href="https://lambdalabs.com/blog/how-to-fine-tune-stable-diffusion-how-we-made-the-text-to-pokemon-model-at-lambda/">this blog post</a>.
|
|
|
|
| 186 |
<p>Trained by Eole Cervenka at <a href="https://lambdalabs.com/">Lambda Labs</a>.</p>
|
| 187 |
</div>
|
| 188 |
"""
|
|
|
|
| 9 |
context = autocast if device == "cuda" else nullcontext
|
| 10 |
dtype = torch.float16 if device == "cuda" else torch.float32
|
| 11 |
|
| 12 |
+
pipe = StableDiffusionPipeline.from_pretrained("lambdalabs/sd-naruto-diffusers", torch_dtype=dtype)
|
|
|
|
| 13 |
pipe = pipe.to(device)
|
| 14 |
|
| 15 |
|
| 16 |
+
# Sometimes the nsfw checker is confused by the Naruto images, you can disable
|
| 17 |
+
# it at your own risk here
|
| 18 |
+
# disable_safety = True
|
| 19 |
+
|
| 20 |
+
# if disable_safety:
|
| 21 |
+
# def null_safety(images, **kwargs):
|
| 22 |
+
# return images, False
|
| 23 |
+
# pipe.safety_checker = null_safety
|
| 24 |
+
|
| 25 |
|
| 26 |
def infer(prompt, n_samples, steps, scale):
|
| 27 |
|
|
|
|
| 115 |
|
| 116 |
examples = [
|
| 117 |
[
|
| 118 |
+
'Yoda',
|
| 119 |
2,
|
| 120 |
7.5,
|
| 121 |
],
|
| 122 |
[
|
| 123 |
+
'Abraham Lincoln',
|
| 124 |
2,
|
| 125 |
7.5,
|
| 126 |
],
|
| 127 |
[
|
| 128 |
+
'George Washington',
|
| 129 |
2,
|
| 130 |
7,
|
| 131 |
],
|
|
|
|
| 139 |
<img class="logo" src="https://lambdalabs.com/hubfs/logos/lambda-logo.svg" alt="Lambda Logo"
|
| 140 |
style="margin: auto; max-width: 7rem;">
|
| 141 |
<h1 style="font-weight: 900; font-size: 3rem;">
|
| 142 |
+
Naruto text to image
|
| 143 |
</h1>
|
| 144 |
</div>
|
| 145 |
+
<p style="margin-bottom: 10px; font-size: 94%">
|
| 146 |
+
Generate new Naruto anime character from a text description,
|
| 147 |
+
<a href="https://lambdalabs.com/blog/how-to-fine-tune-stable-diffusion-how-we-made-the-text-to-pokemon-model-at-lambda/">created by Lambda Labs</a>.
|
| 148 |
+
</p>
|
| 149 |
</div>
|
| 150 |
"""
|
| 151 |
)
|
|
|
|
| 174 |
|
| 175 |
with gr.Row(elem_id="advanced-options"):
|
| 176 |
samples = gr.Slider(label="Images", minimum=1, maximum=4, value=2, step=1)
|
| 177 |
+
steps = gr.Slider(label="Steps", minimum=5, maximum=50, value=25, step=5)
|
| 178 |
scale = gr.Slider(
|
| 179 |
label="Guidance Scale", minimum=0, maximum=50, value=7.5, step=0.1
|
| 180 |
)
|
|
|
|
| 193 |
</p>
|
| 194 |
</div>
|
| 195 |
<div class="acknowledgments">
|
| 196 |
+
<p> Put in a text prompt and generate your own Naruto anime character, no "prompt engineering" required!
|
| 197 |
<p>If you want to find out how we made this model read about it in <a href="https://lambdalabs.com/blog/how-to-fine-tune-stable-diffusion-how-we-made-the-text-to-pokemon-model-at-lambda/">this blog post</a>.
|
| 198 |
+
<p>And if you want to train your own Stable Diffusion variants, see our <a href="https://github.com/LambdaLabsML/examples/tree/main/stable-diffusion-finetuning">Examples Repo</a>!
|
| 199 |
<p>Trained by Eole Cervenka at <a href="https://lambdalabs.com/">Lambda Labs</a>.</p>
|
| 200 |
</div>
|
| 201 |
"""
|