Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ if torch.cuda.is_available():
|
|
| 11 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
| 12 |
pipe.enable_xformers_memory_efficient_attention()
|
| 13 |
pipe = pipe.to(device)
|
| 14 |
-
else:
|
| 15 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
|
| 16 |
pipe = pipe.to(device)
|
| 17 |
|
|
@@ -19,7 +19,6 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
| 19 |
MAX_IMAGE_SIZE = 1024
|
| 20 |
|
| 21 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
| 22 |
-
|
| 23 |
if randomize_seed:
|
| 24 |
seed = random.randint(0, MAX_SEED)
|
| 25 |
|
|
@@ -38,15 +37,21 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 38 |
return image
|
| 39 |
|
| 40 |
examples = [
|
| 41 |
-
"
|
| 42 |
-
"
|
| 43 |
-
"
|
|
|
|
|
|
|
| 44 |
]
|
| 45 |
|
| 46 |
css="""
|
| 47 |
#col-container {
|
| 48 |
margin: 0 auto;
|
| 49 |
max-width: 520px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
"""
|
| 52 |
|
|
@@ -59,7 +64,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 59 |
|
| 60 |
with gr.Column(elem_id="col-container"):
|
| 61 |
gr.Markdown(f"""
|
| 62 |
-
#
|
|
|
|
| 63 |
Currently running on {power_device}.
|
| 64 |
""")
|
| 65 |
|
|
@@ -136,6 +142,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 136 |
examples = examples,
|
| 137 |
inputs = [prompt]
|
| 138 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
run_button.click(
|
| 141 |
fn = infer,
|
|
@@ -143,4 +155,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 143 |
outputs = [result]
|
| 144 |
)
|
| 145 |
|
| 146 |
-
demo.queue().launch()
|
|
|
|
| 11 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
| 12 |
pipe.enable_xformers_memory_efficient_attention()
|
| 13 |
pipe = pipe.to(device)
|
| 14 |
+
else:
|
| 15 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
|
| 16 |
pipe = pipe.to(device)
|
| 17 |
|
|
|
|
| 19 |
MAX_IMAGE_SIZE = 1024
|
| 20 |
|
| 21 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
|
|
|
| 22 |
if randomize_seed:
|
| 23 |
seed = random.randint(0, MAX_SEED)
|
| 24 |
|
|
|
|
| 37 |
return image
|
| 38 |
|
| 39 |
examples = [
|
| 40 |
+
"๐ Sunset over the Atlas Mountains",
|
| 41 |
+
"๐ฐ Kasbah with traditional Berber architecture",
|
| 42 |
+
"๐ Flying carpet in space",
|
| 43 |
+
"๐ฆ Unicorn riding a camel in the Sahara Desert",
|
| 44 |
+
"๐ Moroccan souk floating in the sky",
|
| 45 |
]
|
| 46 |
|
| 47 |
css="""
|
| 48 |
#col-container {
|
| 49 |
margin: 0 auto;
|
| 50 |
max-width: 520px;
|
| 51 |
+
color: white;
|
| 52 |
+
}
|
| 53 |
+
body {
|
| 54 |
+
background-color: #003366;
|
| 55 |
}
|
| 56 |
"""
|
| 57 |
|
|
|
|
| 64 |
|
| 65 |
with gr.Column(elem_id="col-container"):
|
| 66 |
gr.Markdown(f"""
|
| 67 |
+
# bibou.jpeg
|
| 68 |
+
Generate Moroccan folkloric music, inspired by Moroccan and Amazigh arts. ๐จ๐ถ
|
| 69 |
Currently running on {power_device}.
|
| 70 |
""")
|
| 71 |
|
|
|
|
| 142 |
examples = examples,
|
| 143 |
inputs = [prompt]
|
| 144 |
)
|
| 145 |
+
|
| 146 |
+
gr.Markdown("""
|
| 147 |
+
<div style="text-align: center;">
|
| 148 |
+
Built with โค๏ธ by <a href="https://www.linkedin.com/in/halimbahae/" target="_blank">Bahae Eddine HALIM</a>
|
| 149 |
+
</div>
|
| 150 |
+
""")
|
| 151 |
|
| 152 |
run_button.click(
|
| 153 |
fn = infer,
|
|
|
|
| 155 |
outputs = [result]
|
| 156 |
)
|
| 157 |
|
| 158 |
+
demo.queue().launch()
|