Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
-
from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
import spaces
|
| 6 |
from PIL import Image
|
|
@@ -39,6 +39,7 @@ vae = AutoencoderKL.from_pretrained(
|
|
| 39 |
if torch.cuda.is_available():
|
| 40 |
pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to("cuda")
|
| 41 |
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
# Function
|
|
@@ -49,7 +50,8 @@ def generate_image(
|
|
| 49 |
width=1024,
|
| 50 |
height=1024,
|
| 51 |
scale=1.5,
|
| 52 |
-
steps=30
|
|
|
|
| 53 |
|
| 54 |
prompt = str(translator.translate(prompt, 'English'))
|
| 55 |
|
|
@@ -62,8 +64,8 @@ def generate_image(
|
|
| 62 |
height=height,
|
| 63 |
guidance_scale=scale,
|
| 64 |
num_inference_steps=steps,
|
|
|
|
| 65 |
)
|
| 66 |
-
print(image.images[0])
|
| 67 |
return image.images[0]
|
| 68 |
|
| 69 |
|
|
@@ -85,7 +87,7 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 85 |
gr.HTML("<p><center><a href='https://huggingface.co/Corcelio/openvision'>OpenVision</a> text-to-image generation</center><br><center>Multi-Languages. Midjourney Aesthetic for All Your Images</center></p>")
|
| 86 |
with gr.Group():
|
| 87 |
with gr.Row():
|
| 88 |
-
prompt = gr.Textbox(label='Enter Your Prompt', scale=6)
|
| 89 |
submit = gr.Button(scale=1, variant='primary')
|
| 90 |
img = gr.Image(label='OpenVision Generated Image')
|
| 91 |
with gr.Accordion("Advanced Options", open=False):
|
|
@@ -108,19 +110,26 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 108 |
)
|
| 109 |
with gr.Row():
|
| 110 |
scale = gr.Slider(
|
| 111 |
-
label="Guidance
|
| 112 |
-
minimum=
|
| 113 |
-
maximum=
|
| 114 |
step=0.1,
|
| 115 |
-
value=
|
| 116 |
)
|
| 117 |
steps = gr.Slider(
|
| 118 |
label="Steps",
|
| 119 |
minimum=1,
|
| 120 |
maximum=50,
|
| 121 |
step=1,
|
| 122 |
-
value=
|
| 123 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
gr.Examples(
|
| 125 |
examples=examples,
|
| 126 |
inputs=prompt,
|
|
@@ -130,11 +139,11 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 130 |
)
|
| 131 |
|
| 132 |
prompt.submit(fn=generate_image,
|
| 133 |
-
inputs=[prompt, negative, width, height, scale, steps],
|
| 134 |
outputs=img,
|
| 135 |
)
|
| 136 |
submit.click(fn=generate_image,
|
| 137 |
-
inputs=[prompt, negative, width, height, scale, steps],
|
| 138 |
outputs=img,
|
| 139 |
)
|
| 140 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from diffusers import StableDiffusionXLPipeline, AutoencoderKL, KDPM2AncestralDiscreteScheduler
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
import spaces
|
| 6 |
from PIL import Image
|
|
|
|
| 39 |
if torch.cuda.is_available():
|
| 40 |
pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to("cuda")
|
| 41 |
|
| 42 |
+
pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 43 |
|
| 44 |
|
| 45 |
# Function
|
|
|
|
| 50 |
width=1024,
|
| 51 |
height=1024,
|
| 52 |
scale=1.5,
|
| 53 |
+
steps=30,
|
| 54 |
+
clip=3):
|
| 55 |
|
| 56 |
prompt = str(translator.translate(prompt, 'English'))
|
| 57 |
|
|
|
|
| 64 |
height=height,
|
| 65 |
guidance_scale=scale,
|
| 66 |
num_inference_steps=steps,
|
| 67 |
+
clip_skip=clip,
|
| 68 |
)
|
|
|
|
| 69 |
return image.images[0]
|
| 70 |
|
| 71 |
|
|
|
|
| 87 |
gr.HTML("<p><center><a href='https://huggingface.co/Corcelio/openvision'>OpenVision</a> text-to-image generation</center><br><center>Multi-Languages. Midjourney Aesthetic for All Your Images</center></p>")
|
| 88 |
with gr.Group():
|
| 89 |
with gr.Row():
|
| 90 |
+
prompt = gr.Textbox(label='Enter Your Prompt', value="best quality, HD, aesthetic", scale=6)
|
| 91 |
submit = gr.Button(scale=1, variant='primary')
|
| 92 |
img = gr.Image(label='OpenVision Generated Image')
|
| 93 |
with gr.Accordion("Advanced Options", open=False):
|
|
|
|
| 110 |
)
|
| 111 |
with gr.Row():
|
| 112 |
scale = gr.Slider(
|
| 113 |
+
label="Guidance",
|
| 114 |
+
minimum=3.5,
|
| 115 |
+
maximum=7,
|
| 116 |
step=0.1,
|
| 117 |
+
value=7,
|
| 118 |
)
|
| 119 |
steps = gr.Slider(
|
| 120 |
label="Steps",
|
| 121 |
minimum=1,
|
| 122 |
maximum=50,
|
| 123 |
step=1,
|
| 124 |
+
value=50,
|
| 125 |
+
)
|
| 126 |
+
clip = gr.Slider(
|
| 127 |
+
label="Clip Skip",
|
| 128 |
+
minimum=1,
|
| 129 |
+
maximum=10,
|
| 130 |
+
step=1,
|
| 131 |
+
value=3,
|
| 132 |
+
)
|
| 133 |
gr.Examples(
|
| 134 |
examples=examples,
|
| 135 |
inputs=prompt,
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
prompt.submit(fn=generate_image,
|
| 142 |
+
inputs=[prompt, negative, width, height, scale, steps, clip],
|
| 143 |
outputs=img,
|
| 144 |
)
|
| 145 |
submit.click(fn=generate_image,
|
| 146 |
+
inputs=[prompt, negative, width, height, scale, steps, clip],
|
| 147 |
outputs=img,
|
| 148 |
)
|
| 149 |
|