Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,11 @@ 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-
|
11 |
|
12 |
if torch.cuda.is_available():
|
13 |
torch_dtype = torch.float16
|
@@ -20,8 +19,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,11 +47,10 @@ def infer(
|
|
50 |
|
51 |
return image, seed
|
52 |
|
53 |
-
|
54 |
examples = [
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"A
|
58 |
]
|
59 |
|
60 |
css = """
|
@@ -66,7 +62,7 @@ css = """
|
|
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(
|
@@ -105,7 +101,7 @@ with gr.Blocks(css=css) as demo:
|
|
105 |
minimum=256,
|
106 |
maximum=MAX_IMAGE_SIZE,
|
107 |
step=32,
|
108 |
-
value=
|
109 |
)
|
110 |
|
111 |
height = gr.Slider(
|
@@ -113,7 +109,7 @@ with gr.Blocks(css=css) as demo:
|
|
113 |
minimum=256,
|
114 |
maximum=MAX_IMAGE_SIZE,
|
115 |
step=32,
|
116 |
-
value=
|
117 |
)
|
118 |
|
119 |
with gr.Row():
|
@@ -122,7 +118,7 @@ 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(
|
@@ -130,7 +126,7 @@ with gr.Blocks(css=css) as demo:
|
|
130 |
minimum=1,
|
131 |
maximum=50,
|
132 |
step=1,
|
133 |
-
value=
|
134 |
)
|
135 |
|
136 |
gr.Examples(examples=examples, inputs=[prompt])
|
@@ -151,4 +147,4 @@ with gr.Blocks(css=css) as demo:
|
|
151 |
)
|
152 |
|
153 |
if __name__ == "__main__":
|
154 |
-
demo.launch()
|
|
|
2 |
import numpy as np
|
3 |
import random
|
4 |
|
|
|
5 |
from diffusers import DiffusionPipeline
|
6 |
import torch
|
7 |
|
8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
9 |
+
model_repo_id = "stabilityai/sdxl-emoji" # Updated to use the sdxl-emoji model
|
10 |
|
11 |
if torch.cuda.is_available():
|
12 |
torch_dtype = torch.float16
|
|
|
19 |
MAX_SEED = np.iinfo(np.int32).max
|
20 |
MAX_IMAGE_SIZE = 1024
|
21 |
|
|
|
|
|
22 |
def infer(
|
23 |
prompt,
|
24 |
negative_prompt,
|
|
|
47 |
|
48 |
return image, seed
|
49 |
|
|
|
50 |
examples = [
|
51 |
+
"Smiling face emoji with heart eyes",
|
52 |
+
"Sad face emoji",
|
53 |
+
"A cute cat emoji with a playful expression",
|
54 |
]
|
55 |
|
56 |
css = """
|
|
|
62 |
|
63 |
with gr.Blocks(css=css) as demo:
|
64 |
with gr.Column(elem_id="col-container"):
|
65 |
+
gr.Markdown(" # Emoji Generator with Gradio")
|
66 |
|
67 |
with gr.Row():
|
68 |
prompt = gr.Text(
|
|
|
101 |
minimum=256,
|
102 |
maximum=MAX_IMAGE_SIZE,
|
103 |
step=32,
|
104 |
+
value=512, # Adjusted to a typical emoji size
|
105 |
)
|
106 |
|
107 |
height = gr.Slider(
|
|
|
109 |
minimum=256,
|
110 |
maximum=MAX_IMAGE_SIZE,
|
111 |
step=32,
|
112 |
+
value=512, # Adjusted to a typical emoji size
|
113 |
)
|
114 |
|
115 |
with gr.Row():
|
|
|
118 |
minimum=0.0,
|
119 |
maximum=10.0,
|
120 |
step=0.1,
|
121 |
+
value=7.5, # Adjusted for more focused generation
|
122 |
)
|
123 |
|
124 |
num_inference_steps = gr.Slider(
|
|
|
126 |
minimum=1,
|
127 |
maximum=50,
|
128 |
step=1,
|
129 |
+
value=25, # Adjusted for better quality generation
|
130 |
)
|
131 |
|
132 |
gr.Examples(examples=examples, inputs=[prompt])
|
|
|
147 |
)
|
148 |
|
149 |
if __name__ == "__main__":
|
150 |
+
demo.launch()
|