Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ height = int(os.getenv("IMAGE_HEIGHT", "512"))
|
|
44 |
num_images = int(os.getenv("NUM_IMAGES", "1"))
|
45 |
guidance_scale = float(os.getenv("GUIDANCE_SCALE", "1.0"))
|
46 |
|
47 |
-
pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile = False, ov_config = {"CACHE_DIR":""})
|
48 |
pipe.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images)
|
49 |
pipe.compile()
|
50 |
|
@@ -54,7 +54,7 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
54 |
return seed
|
55 |
|
56 |
def save_image(img, profile: gr.OAuthProfile | None, metadata: dict):
|
57 |
-
unique_name = str(uuid.uuid4()) + '.png'
|
58 |
img.save(unique_name)
|
59 |
gr_user_history.save_image(label=metadata["prompt"], image=img, profile=profile, metadata=metadata)
|
60 |
return unique_name
|
@@ -67,6 +67,7 @@ def save_images(image_array, profile: gr.OAuthProfile | None, metadata: dict):
|
|
67 |
|
68 |
def generate(
|
69 |
prompt: str,
|
|
|
70 |
seed: int = 0,
|
71 |
num_inference_steps: int = 4,
|
72 |
randomize_seed: bool = False,
|
@@ -84,6 +85,7 @@ def generate(
|
|
84 |
start_time = time.time()
|
85 |
result = pipe(
|
86 |
prompt=prompt,
|
|
|
87 |
width=width,
|
88 |
height=height,
|
89 |
guidance_scale=guidance_scale,
|
@@ -102,7 +104,6 @@ examples = [
|
|
102 |
"(masterpiece, best quality, highres), anime art style, pixiv, 1girl, solo, supernova, abstract, abstract background, (bloom, swirling lights, light particles), fire, galaxy, floating, romanticized, blush, looking at viewer, dark red hair, long hair, blue eyes, straight hair, cat ears, medium breasts, mature female, white sweater",
|
103 |
]
|
104 |
|
105 |
-
|
106 |
with gr.Blocks(css="style.css") as demo:
|
107 |
gr.Markdown(DESCRIPTION)
|
108 |
gr.DuplicateButton(
|
@@ -116,7 +117,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
116 |
label="Prompt",
|
117 |
show_label=False,
|
118 |
max_lines=1,
|
119 |
-
|
120 |
container=False,
|
121 |
)
|
122 |
run_button = gr.Button("Run", scale=0)
|
@@ -124,6 +125,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
124 |
label="Generated images", show_label=False, elem_id="gallery", grid=[2]
|
125 |
)
|
126 |
with gr.Accordion("Advanced options", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
seed = gr.Slider(
|
128 |
label="Seed",
|
129 |
minimum=0,
|
@@ -161,6 +168,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
161 |
fn=generate,
|
162 |
inputs=[
|
163 |
prompt,
|
|
|
164 |
seed,
|
165 |
num_inference_steps,
|
166 |
randomize_seed
|
@@ -172,4 +180,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
172 |
if __name__ == "__main__":
|
173 |
demo.queue(api_open=False)
|
174 |
# demo.queue(max_size=20).launch()
|
175 |
-
demo.launch()
|
|
|
44 |
num_images = int(os.getenv("NUM_IMAGES", "1"))
|
45 |
guidance_scale = float(os.getenv("GUIDANCE_SCALE", "1.0"))
|
46 |
|
47 |
+
pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile = False, ov_config = {"CACHE_DIR":"cache"})
|
48 |
pipe.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images)
|
49 |
pipe.compile()
|
50 |
|
|
|
54 |
return seed
|
55 |
|
56 |
def save_image(img, profile: gr.OAuthProfile | None, metadata: dict):
|
57 |
+
unique_name = "out/" + str(uuid.uuid4()) + '.png'
|
58 |
img.save(unique_name)
|
59 |
gr_user_history.save_image(label=metadata["prompt"], image=img, profile=profile, metadata=metadata)
|
60 |
return unique_name
|
|
|
67 |
|
68 |
def generate(
|
69 |
prompt: str,
|
70 |
+
negative_prompt: str,
|
71 |
seed: int = 0,
|
72 |
num_inference_steps: int = 4,
|
73 |
randomize_seed: bool = False,
|
|
|
85 |
start_time = time.time()
|
86 |
result = pipe(
|
87 |
prompt=prompt,
|
88 |
+
negative_prompt=negative_prompt,
|
89 |
width=width,
|
90 |
height=height,
|
91 |
guidance_scale=guidance_scale,
|
|
|
104 |
"(masterpiece, best quality, highres), anime art style, pixiv, 1girl, solo, supernova, abstract, abstract background, (bloom, swirling lights, light particles), fire, galaxy, floating, romanticized, blush, looking at viewer, dark red hair, long hair, blue eyes, straight hair, cat ears, medium breasts, mature female, white sweater",
|
105 |
]
|
106 |
|
|
|
107 |
with gr.Blocks(css="style.css") as demo:
|
108 |
gr.Markdown(DESCRIPTION)
|
109 |
gr.DuplicateButton(
|
|
|
117 |
label="Prompt",
|
118 |
show_label=False,
|
119 |
max_lines=1,
|
120 |
+
value="(masterpiece, best quality, highres), anime art style, pixiv, 1girl, solo",
|
121 |
container=False,
|
122 |
)
|
123 |
run_button = gr.Button("Run", scale=0)
|
|
|
125 |
label="Generated images", show_label=False, elem_id="gallery", grid=[2]
|
126 |
)
|
127 |
with gr.Accordion("Advanced options", open=False):
|
128 |
+
with gr.Row():
|
129 |
+
negative_prompt = gr.Text(
|
130 |
+
label="Negative Prompt",
|
131 |
+
max_lines=1,
|
132 |
+
value="(worst quality, low quality, lowres), zombie, comic, sketch, blurry, interlocked fingers",
|
133 |
+
)
|
134 |
seed = gr.Slider(
|
135 |
label="Seed",
|
136 |
minimum=0,
|
|
|
168 |
fn=generate,
|
169 |
inputs=[
|
170 |
prompt,
|
171 |
+
negative_prompt,
|
172 |
seed,
|
173 |
num_inference_steps,
|
174 |
randomize_seed
|
|
|
180 |
if __name__ == "__main__":
|
181 |
demo.queue(api_open=False)
|
182 |
# demo.queue(max_size=20).launch()
|
183 |
+
demo.launch()
|