Spaces:
Runtime error
Runtime error
changed the styling
Browse files- app.py +48 -13
- index.html +37 -3
app.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 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 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
-
model_repo_id = "stabilityai/sdxl-turbo"
|
| 11 |
|
| 12 |
if torch.cuda.is_available():
|
| 13 |
torch_dtype = torch.float16
|
|
@@ -20,8 +18,6 @@ pipe = pipe.to(device)
|
|
| 20 |
MAX_SEED = np.iinfo(np.int32).max
|
| 21 |
MAX_IMAGE_SIZE = 1024
|
| 22 |
|
| 23 |
-
|
| 24 |
-
# @spaces.GPU #[uncomment to use ZeroGPU]
|
| 25 |
def infer(
|
| 26 |
prompt,
|
| 27 |
negative_prompt,
|
|
@@ -50,7 +46,6 @@ def infer(
|
|
| 50 |
|
| 51 |
return image, seed
|
| 52 |
|
| 53 |
-
|
| 54 |
examples = [
|
| 55 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 56 |
"An astronaut riding a green horse",
|
|
@@ -58,15 +53,54 @@ examples = [
|
|
| 58 |
]
|
| 59 |
|
| 60 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("
|
| 70 |
|
| 71 |
with gr.Row():
|
| 72 |
prompt = gr.Text(
|
|
@@ -95,6 +129,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 95 |
maximum=MAX_SEED,
|
| 96 |
step=1,
|
| 97 |
value=0,
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
|
@@ -105,7 +140,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 105 |
minimum=256,
|
| 106 |
maximum=MAX_IMAGE_SIZE,
|
| 107 |
step=32,
|
| 108 |
-
value=1024,
|
| 109 |
)
|
| 110 |
|
| 111 |
height = gr.Slider(
|
|
@@ -113,7 +148,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 113 |
minimum=256,
|
| 114 |
maximum=MAX_IMAGE_SIZE,
|
| 115 |
step=32,
|
| 116 |
-
value=1024,
|
| 117 |
)
|
| 118 |
|
| 119 |
with gr.Row():
|
|
@@ -122,7 +157,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 122 |
minimum=0.0,
|
| 123 |
maximum=10.0,
|
| 124 |
step=0.1,
|
| 125 |
-
value=0.0,
|
| 126 |
)
|
| 127 |
|
| 128 |
num_inference_steps = gr.Slider(
|
|
@@ -130,10 +165,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 130 |
minimum=1,
|
| 131 |
maximum=50,
|
| 132 |
step=1,
|
| 133 |
-
value=2,
|
| 134 |
)
|
| 135 |
|
| 136 |
gr.Examples(examples=examples, inputs=[prompt])
|
|
|
|
| 137 |
gr.on(
|
| 138 |
triggers=[run_button.click, prompt.submit],
|
| 139 |
fn=infer,
|
|
@@ -151,5 +187,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 151 |
)
|
| 152 |
|
| 153 |
if __name__ == "__main__":
|
| 154 |
-
demo.launch()
|
| 155 |
-
## Added a comment
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import random
|
|
|
|
|
|
|
| 4 |
from diffusers import DiffusionPipeline
|
| 5 |
import torch
|
| 6 |
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
+
model_repo_id = "stabilityai/sdxl-turbo"
|
| 9 |
|
| 10 |
if torch.cuda.is_available():
|
| 11 |
torch_dtype = torch.float16
|
|
|
|
| 18 |
MAX_SEED = np.iinfo(np.int32).max
|
| 19 |
MAX_IMAGE_SIZE = 1024
|
| 20 |
|
|
|
|
|
|
|
| 21 |
def infer(
|
| 22 |
prompt,
|
| 23 |
negative_prompt,
|
|
|
|
| 46 |
|
| 47 |
return image, seed
|
| 48 |
|
|
|
|
| 49 |
examples = [
|
| 50 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 51 |
"An astronaut riding a green horse",
|
|
|
|
| 53 |
]
|
| 54 |
|
| 55 |
css = """
|
| 56 |
+
body {
|
| 57 |
+
font-family: Arial, sans-serif;
|
| 58 |
+
background-color: #f4f4f9;
|
| 59 |
+
margin: 0;
|
| 60 |
+
padding: 0;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
#col-container {
|
| 64 |
margin: 0 auto;
|
| 65 |
max-width: 640px;
|
| 66 |
+
padding: 20px;
|
| 67 |
+
background-color: white;
|
| 68 |
+
border-radius: 8px;
|
| 69 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
h1 {
|
| 73 |
+
color: #333;
|
| 74 |
+
text-align: center;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
button {
|
| 78 |
+
background-color: #4CAF50;
|
| 79 |
+
color: white;
|
| 80 |
+
border: none;
|
| 81 |
+
padding: 10px 20px;
|
| 82 |
+
border-radius: 5px;
|
| 83 |
+
cursor: pointer;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
button:hover {
|
| 87 |
+
background-color: #45a049;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.slider {
|
| 91 |
+
margin: 10px 0;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.gr-image {
|
| 95 |
+
margin-top: 20px;
|
| 96 |
+
border: 1px solid #ddd;
|
| 97 |
+
border-radius: 5px;
|
| 98 |
}
|
| 99 |
"""
|
| 100 |
|
| 101 |
with gr.Blocks(css=css) as demo:
|
| 102 |
with gr.Column(elem_id="col-container"):
|
| 103 |
+
gr.Markdown("<h1>Pixel Phraser</h1>")
|
| 104 |
|
| 105 |
with gr.Row():
|
| 106 |
prompt = gr.Text(
|
|
|
|
| 129 |
maximum=MAX_SEED,
|
| 130 |
step=1,
|
| 131 |
value=0,
|
| 132 |
+
interactive=True,
|
| 133 |
)
|
| 134 |
|
| 135 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
|
|
|
| 140 |
minimum=256,
|
| 141 |
maximum=MAX_IMAGE_SIZE,
|
| 142 |
step=32,
|
| 143 |
+
value=1024,
|
| 144 |
)
|
| 145 |
|
| 146 |
height = gr.Slider(
|
|
|
|
| 148 |
minimum=256,
|
| 149 |
maximum=MAX_IMAGE_SIZE,
|
| 150 |
step=32,
|
| 151 |
+
value=1024,
|
| 152 |
)
|
| 153 |
|
| 154 |
with gr.Row():
|
|
|
|
| 157 |
minimum=0.0,
|
| 158 |
maximum=10.0,
|
| 159 |
step=0.1,
|
| 160 |
+
value=0.0,
|
| 161 |
)
|
| 162 |
|
| 163 |
num_inference_steps = gr.Slider(
|
|
|
|
| 165 |
minimum=1,
|
| 166 |
maximum=50,
|
| 167 |
step=1,
|
| 168 |
+
value=2,
|
| 169 |
)
|
| 170 |
|
| 171 |
gr.Examples(examples=examples, inputs=[prompt])
|
| 172 |
+
|
| 173 |
gr.on(
|
| 174 |
triggers=[run_button.click, prompt.submit],
|
| 175 |
fn=infer,
|
|
|
|
| 187 |
)
|
| 188 |
|
| 189 |
if __name__ == "__main__":
|
| 190 |
+
demo.launch()
|
|
|
index.html
CHANGED
|
@@ -5,26 +5,60 @@
|
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<meta name="description" content="Embedded content from Pixel Phraser">
|
| 8 |
-
<title>
|
| 9 |
<style>
|
| 10 |
body {
|
| 11 |
margin: 0;
|
| 12 |
padding: 0;
|
| 13 |
height: 100vh;
|
| 14 |
/* Full height */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
iframe {
|
| 18 |
width: 100%;
|
| 19 |
height: 100%;
|
| 20 |
-
/* Full height */
|
| 21 |
border: none;
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
</style>
|
| 24 |
</head>
|
| 25 |
|
| 26 |
<body>
|
| 27 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
</body>
|
| 29 |
|
| 30 |
</html>
|
|
|
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<meta name="description" content="Embedded content from Pixel Phraser">
|
| 8 |
+
<title>Pixel Phraser - Create Engaging Visual Content</title> <!-- Updated title -->
|
| 9 |
<style>
|
| 10 |
body {
|
| 11 |
margin: 0;
|
| 12 |
padding: 0;
|
| 13 |
height: 100vh;
|
| 14 |
/* Full height */
|
| 15 |
+
overflow: hidden;
|
| 16 |
+
/* Prevent scrolling on the body */
|
| 17 |
+
display: flex;
|
| 18 |
+
flex-direction: column;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
header {
|
| 22 |
+
background-color: #333;
|
| 23 |
+
/* Change to your desired header color */
|
| 24 |
+
color: white;
|
| 25 |
+
/* Text color */
|
| 26 |
+
padding: 10px 20px;
|
| 27 |
+
/* Adjust padding as needed */
|
| 28 |
+
text-align: center;
|
| 29 |
+
/* Center the text */
|
| 30 |
+
position: fixed;
|
| 31 |
+
/* Fix the header to the top */
|
| 32 |
+
width: 100%;
|
| 33 |
+
/* Full width */
|
| 34 |
+
z-index: 10;
|
| 35 |
+
/* Make sure it appears above other content */
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.iframe-container {
|
| 39 |
+
flex: 1;
|
| 40 |
+
/* Take up remaining space */
|
| 41 |
+
margin-top: 50px;
|
| 42 |
+
/* Adjust margin for header height */
|
| 43 |
}
|
| 44 |
|
| 45 |
iframe {
|
| 46 |
width: 100%;
|
| 47 |
height: 100%;
|
|
|
|
| 48 |
border: none;
|
| 49 |
+
overflow: hidden;
|
| 50 |
+
/* Prevent scrolling inside the iframe */
|
| 51 |
}
|
| 52 |
</style>
|
| 53 |
</head>
|
| 54 |
|
| 55 |
<body>
|
| 56 |
+
<header>
|
| 57 |
+
<h1>Pixel Phraser</h1> <!-- Title of the page -->
|
| 58 |
+
</header>
|
| 59 |
+
<div class="iframe-container">
|
| 60 |
+
<iframe src="https://fsadeek-pixelphraser.hf.space" title="Pixel Phraser" scrolling="no"></iframe>
|
| 61 |
+
</div>
|
| 62 |
</body>
|
| 63 |
|
| 64 |
</html>
|