Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import random
|
| 4 |
-
|
| 5 |
-
# import spaces #[uncomment to use ZeroGPU]
|
| 6 |
-
from diffusers import DiffusionPipeline
|
| 7 |
import torch
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
if torch.cuda.is_available():
|
| 13 |
-
torch_dtype = torch.float16
|
| 14 |
-
else:
|
| 15 |
-
torch_dtype = torch.float32
|
| 16 |
-
|
| 17 |
-
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
| 18 |
-
pipe = pipe.to(device)
|
| 19 |
|
| 20 |
MAX_SEED = np.iinfo(np.int32).max
|
| 21 |
-
MAX_IMAGE_SIZE =
|
| 22 |
|
| 23 |
-
|
| 24 |
-
# @spaces.GPU #[uncomment to use ZeroGPU]
|
| 25 |
def infer(
|
| 26 |
prompt,
|
| 27 |
negative_prompt,
|
|
@@ -57,17 +45,8 @@ examples = [
|
|
| 57 |
"A delicious ceviche cheesecake slice",
|
| 58 |
]
|
| 59 |
|
| 60 |
-
|
| 61 |
-
#col-container {
|
| 62 |
-
margin: 0 auto;
|
| 63 |
-
max-width: 640px;
|
| 64 |
-
}
|
| 65 |
-
"""
|
| 66 |
-
|
| 67 |
-
with gr.Blocks(css=css) as demo:
|
| 68 |
with gr.Column(elem_id="col-container"):
|
| 69 |
-
gr.Markdown(" # Text-to-Image Gradio Template")
|
| 70 |
-
|
| 71 |
with gr.Row():
|
| 72 |
prompt = gr.Text(
|
| 73 |
label="Prompt",
|
|
@@ -102,18 +81,18 @@ with gr.Blocks(css=css) as demo:
|
|
| 102 |
with gr.Row():
|
| 103 |
width = gr.Slider(
|
| 104 |
label="Width",
|
| 105 |
-
minimum=
|
| 106 |
maximum=MAX_IMAGE_SIZE,
|
| 107 |
step=32,
|
| 108 |
-
value=
|
| 109 |
)
|
| 110 |
|
| 111 |
height = gr.Slider(
|
| 112 |
label="Height",
|
| 113 |
-
minimum=
|
| 114 |
maximum=MAX_IMAGE_SIZE,
|
| 115 |
step=32,
|
| 116 |
-
value=
|
| 117 |
)
|
| 118 |
|
| 119 |
with gr.Row():
|
|
@@ -122,15 +101,15 @@ with gr.Blocks(css=css) as demo:
|
|
| 122 |
minimum=0.0,
|
| 123 |
maximum=10.0,
|
| 124 |
step=0.1,
|
| 125 |
-
value=
|
| 126 |
)
|
| 127 |
|
| 128 |
num_inference_steps = gr.Slider(
|
| 129 |
label="Number of inference steps",
|
| 130 |
minimum=1,
|
| 131 |
-
maximum=
|
| 132 |
step=1,
|
| 133 |
-
value=
|
| 134 |
)
|
| 135 |
|
| 136 |
gr.Examples(examples=examples, inputs=[prompt])
|
|
@@ -151,4 +130,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 151 |
)
|
| 152 |
|
| 153 |
if __name__ == "__main__":
|
| 154 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import random
|
| 4 |
+
from optimum.intel import OVStableDiffusionXLPipeline
|
|
|
|
|
|
|
| 5 |
import torch
|
| 6 |
|
| 7 |
+
model_id = "None1145/noobai-XL-Vpred-0.65s-openvino"
|
| 8 |
+
pipe = OVStableDiffusionXLPipeline.from_pretrained(model_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
MAX_SEED = np.iinfo(np.int32).max
|
| 11 |
+
MAX_IMAGE_SIZE = 2048
|
| 12 |
|
|
|
|
|
|
|
| 13 |
def infer(
|
| 14 |
prompt,
|
| 15 |
negative_prompt,
|
|
|
|
| 45 |
"A delicious ceviche cheesecake slice",
|
| 46 |
]
|
| 47 |
|
| 48 |
+
with gr.Blocks() as img:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
with gr.Column(elem_id="col-container"):
|
|
|
|
|
|
|
| 50 |
with gr.Row():
|
| 51 |
prompt = gr.Text(
|
| 52 |
label="Prompt",
|
|
|
|
| 81 |
with gr.Row():
|
| 82 |
width = gr.Slider(
|
| 83 |
label="Width",
|
| 84 |
+
minimum=512,
|
| 85 |
maximum=MAX_IMAGE_SIZE,
|
| 86 |
step=32,
|
| 87 |
+
value=832, # Replace with defaults that work for your model
|
| 88 |
)
|
| 89 |
|
| 90 |
height = gr.Slider(
|
| 91 |
label="Height",
|
| 92 |
+
minimum=512,
|
| 93 |
maximum=MAX_IMAGE_SIZE,
|
| 94 |
step=32,
|
| 95 |
+
value=1216, # Replace with defaults that work for your model
|
| 96 |
)
|
| 97 |
|
| 98 |
with gr.Row():
|
|
|
|
| 101 |
minimum=0.0,
|
| 102 |
maximum=10.0,
|
| 103 |
step=0.1,
|
| 104 |
+
value=5.0, # Replace with defaults that work for your model
|
| 105 |
)
|
| 106 |
|
| 107 |
num_inference_steps = gr.Slider(
|
| 108 |
label="Number of inference steps",
|
| 109 |
minimum=1,
|
| 110 |
+
maximum=60,
|
| 111 |
step=1,
|
| 112 |
+
value=28, # Replace with defaults that work for your model
|
| 113 |
)
|
| 114 |
|
| 115 |
gr.Examples(examples=examples, inputs=[prompt])
|
|
|
|
| 130 |
)
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
+
img.launch()
|