Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
import modin.pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
-
from diffusers import DiffusionPipeline
|
| 6 |
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
|
@@ -13,20 +13,24 @@ if torch.cuda.is_available():
|
|
| 13 |
pipe.enable_xformers_memory_efficient_attention()
|
| 14 |
pipe = pipe.to(device)
|
| 15 |
torch.cuda.empty_cache()
|
| 16 |
-
else:
|
| 17 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
|
| 18 |
pipe = pipe.to(device)
|
| 19 |
-
|
| 20 |
-
def genie
|
| 21 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
| 22 |
int_image = pipe(prompt=prompt, generator=generator, num_inference_steps=steps, guidance_scale=0.0).images[0]
|
| 23 |
return int_image
|
| 24 |
-
|
| 25 |
-
gr.Interface(
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
],
|
| 29 |
-
outputs=
|
| 30 |
-
title="Stable Diffusion Turbo CPU or GPU",
|
| 31 |
-
description="SDXL Turbo CPU or GPU. Currently running on CPU. <br><br><b>WARNING: This model is capable of producing NSFW (Softcore) images.</b>",
|
| 32 |
-
article
|
|
|
|
|
|
| 2 |
import torch
|
| 3 |
import modin.pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
+
from diffusers import DiffusionPipeline
|
| 6 |
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
|
|
|
| 13 |
pipe.enable_xformers_memory_efficient_attention()
|
| 14 |
pipe = pipe.to(device)
|
| 15 |
torch.cuda.empty_cache()
|
| 16 |
+
else:
|
| 17 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
|
| 18 |
pipe = pipe.to(device)
|
| 19 |
+
|
| 20 |
+
def genie(prompt, steps, seed):
|
| 21 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
| 22 |
int_image = pipe(prompt=prompt, generator=generator, num_inference_steps=steps, guidance_scale=0.0).images[0]
|
| 23 |
return int_image
|
| 24 |
+
|
| 25 |
+
gr.Interface(
|
| 26 |
+
fn=genie,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Textbox(label="What you want the AI to generate. 77 Token Limit."),
|
| 29 |
+
gr.Slider(1, maximum=5, value=2, step=1, label="Number of Iterations"),
|
| 30 |
+
gr.Slider(minimum=0, step=1, maximum=999999999999999999, randomize=True),
|
| 31 |
],
|
| 32 |
+
outputs="image",
|
| 33 |
+
title="Stable Diffusion Turbo CPU or GPU",
|
| 34 |
+
description="SDXL Turbo CPU or GPU. Currently running on CPU. <br><br><b>WARNING: This model is capable of producing NSFW (Softcore) images.</b>",
|
| 35 |
+
article="Created by [Your Name]."
|
| 36 |
+
).launch(debug=True, max_threads=80)
|