Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
10 |
scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
|
11 |
pipeline = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True, scheduler=scheduler).to(device)
|
12 |
|
13 |
-
def run(image, src_style, src_prompt, prompts, shared_score_shift, shared_score_scale, guidance_scale, num_inference_steps, large, seed):
|
14 |
prompts = prompts.splitlines()
|
15 |
dim, d = (1024, 128) if large else (512, 64)
|
16 |
image = image.resize((dim, dim))
|
@@ -40,9 +40,10 @@ def run(image, src_style, src_prompt, prompts, shared_score_shift, shared_score_
|
|
40 |
return images_a
|
41 |
|
42 |
with gr.Blocks() as demo:
|
43 |
-
gr.Markdown('''# Welcome to
|
44 |
-
Here you can generate images with a style from a reference image using [transfer style from sdxl](https://huggingface.co/docs/diffusers/main/en/using-diffusers/sdxl). Add a reference picture, describe the style and add prompts to generate images in that style. It's the most interesting with your own art!
|
45 |
-
|
|
|
46 |
with gr.Row():
|
47 |
image_input = gr.Image(label="Reference image", type="pil")
|
48 |
with gr.Row():
|
@@ -51,12 +52,11 @@ with gr.Blocks() as demo:
|
|
51 |
prompts_input = gr.Textbox(label="Prompts to generate images (separate with new lines)", lines=5)
|
52 |
with gr.Accordion(label="Advanced Settings"):
|
53 |
with gr.Row():
|
54 |
-
shared_score_shift_input = gr.Slider(value=1.
|
55 |
-
shared_score_scale_input = gr.Slider(value=
|
56 |
guidance_scale_input = gr.Slider(value=10.0, label="guidance_scale", minimum=5.0, maximum=20.0, step=1)
|
57 |
num_inference_steps_input = gr.Slider(value=12, label="num_inference_steps", minimum=1, maximum=12, step=1)
|
58 |
-
|
59 |
-
seed_input = gr.Slider(value=0, label="seed (0 for random)", minimum=0, maximum=1000000, step=42)
|
60 |
with gr.Row():
|
61 |
run_button = gr.Button("Generate Images")
|
62 |
with gr.Row():
|
@@ -64,7 +64,7 @@ with gr.Blocks() as demo:
|
|
64 |
|
65 |
run_button.click(
|
66 |
run,
|
67 |
-
inputs=[image_input, style_input, image_desc_input, prompts_input, shared_score_shift_input, shared_score_scale_input, guidance_scale_input, num_inference_steps_input,
|
68 |
outputs=output_gallery
|
69 |
)
|
70 |
|
|
|
10 |
scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
|
11 |
pipeline = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True, scheduler=scheduler).to(device)
|
12 |
|
13 |
+
def run(image, src_style, src_prompt, prompts, shared_score_shift, shared_score_scale, guidance_scale, num_inference_steps, large=True, seed):
|
14 |
prompts = prompts.splitlines()
|
15 |
dim, d = (1024, 128) if large else (512, 64)
|
16 |
image = image.resize((dim, dim))
|
|
|
40 |
return images_a
|
41 |
|
42 |
with gr.Blocks() as demo:
|
43 |
+
gr.Markdown('''# Welcome to🌟Tonic's🤵🏻Style📐Align
|
44 |
+
Here you can generate images with a style from a reference image using [transfer style from sdxl](https://huggingface.co/docs/diffusers/main/en/using-diffusers/sdxl). Add a reference picture, describe the style and add prompts to generate images in that style. It's the most interesting with your own art! You can also use [stabilityai/stable-diffusion-xl-base-1.0] by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/Tonic1/TonicsStyleAlign?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>
|
45 |
+
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/nXx5wbX9) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)
|
46 |
+
''')
|
47 |
with gr.Row():
|
48 |
image_input = gr.Image(label="Reference image", type="pil")
|
49 |
with gr.Row():
|
|
|
52 |
prompts_input = gr.Textbox(label="Prompts to generate images (separate with new lines)", lines=5)
|
53 |
with gr.Accordion(label="Advanced Settings"):
|
54 |
with gr.Row():
|
55 |
+
shared_score_shift_input = gr.Slider(value=1.5, label="shared_score_shift", minimum=1.0, maximum=2.0, step=0.05)
|
56 |
+
shared_score_scale_input = gr.Slider(value=0.5, label="shared_score_scale", minimum=0.0, maximum=1.0, step=0.05)
|
57 |
guidance_scale_input = gr.Slider(value=10.0, label="guidance_scale", minimum=5.0, maximum=20.0, step=1)
|
58 |
num_inference_steps_input = gr.Slider(value=12, label="num_inference_steps", minimum=1, maximum=12, step=1)
|
59 |
+
seed_input = gr.Slider(value=0, label="seed", minimum=0, maximum=1000000, step=42)
|
|
|
60 |
with gr.Row():
|
61 |
run_button = gr.Button("Generate Images")
|
62 |
with gr.Row():
|
|
|
64 |
|
65 |
run_button.click(
|
66 |
run,
|
67 |
+
inputs=[image_input, style_input, image_desc_input, prompts_input, shared_score_shift_input, shared_score_scale_input, guidance_scale_input, num_inference_steps_input, seed_input],
|
68 |
outputs=output_gallery
|
69 |
)
|
70 |
|