From b9371dadfca2a0f8b9f68336b5da2bff0dd14984 Mon Sep 17 00:00:00 2001 From: Adam Oswald Date: Tue, 15 Nov 2022 09:53:11 -0500 Subject: [PATCH] Add files via upload --- Sus.py | 436 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ py.py | 61 ++++++++ 2 files changed, 497 insertions(+) create mode 100644 Sus.py create mode 100644 py.py diff --git a/Sus.py b/Sus.py new file mode 100644 index 0000000..435a0b1 --- /dev/null +++ b/Sus.py @@ -0,0 +1,436 @@ +examples = ["a in style", "a style mecha robot", "a piano being played by ", "Candid photo of , high resolution photo, trending on artstation, interior design"] + +block = gr.Blocks(css=css) + +examples = [ + [ + 'Goku' + ], + [ + 'Mikasa Ackerman' + ], + [ + 'Saber' + ], +] + +with block as demo: + gr.HTML( + """ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Image Generation Test +

+
+

+ Test My Concept +

+
+
+
+

Finetuned Diffusion

+
+

+ Demo for multiple fine-tuned Stable Diffusion models, trained on different styles:
+ Arcane, Archer, Elden Ring, Spiderverse, Modern Disney, Waifu, Pokemon, Fuyuko Waifu, Pony, Hergé (Tintin), Robo, Cyberpunk Anime + any other custom Diffusers 🧨 SD model hosted on HuggingFace 🤗. +

+

Don't want to wait in queue? Open In Colab

+ Running on {device} +

+
+
+

LICENSE

+ The model is licensed with a CreativeML Open RAIL-M license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please read the license

+

Biases and content acknowledgment

+ Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the LAION-5B dataset, which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the model card

+
+ """ + ) + +with gr.Blocks(css=css) as demo: + + gr.Markdown(''' + 👇 Buy me a coffee if you like ♥ this project~ 👇 Running this server costs me $100 per week, any help would be much appreciated! + [![Buy me a coffee](https://badgen.net/badge/icon/Buy%20Me%20A%20Coffee?icon=buymeacoffee&label)](https://www.buymeacoffee.com/dgspitzer) + ''') + with gr.Row(): + + with gr.Column(): + model = gr.Dropdown(label="Model", choices=models, value=models[0]) + prompt = gr.Textbox(label="Prompt", placeholder="{} is added automatically".format(prompt_prefixes[current_model]), elem_id="input-prompt") + guidance = gr.Slider(label="Guidance scale", value=7.5, maximum=15) + steps = gr.Slider(label="Steps", value=27, maximum=100, minimum=2) + run = gr.Button(value="Run") + gr.Markdown(f"Running on: {device}") + with gr.Column(): + image_out = gr.Image(height=512, type="filepath", elem_id="output-img") + + with gr.Column(elem_id="col-container"): + with gr.Group(elem_id="share-btn-container"): + community_icon = gr.HTML(community_icon_html, visible=False) + loading_icon = gr.HTML(loading_icon_html, visible=False) + share_button = gr.Button("Share to community", elem_id="share-btn", visible=False) + + model.change(on_model_change, inputs=model, outputs=[]) + run.click(inference, inputs=[prompt, guidance, steps], outputs=[image_out, share_button, community_icon, loading_icon, prompt]) + + share_button.click(None, [], [], _js=share_js) + + gr.Examples([ + ["portrait of anime girl", 7.5, 27], + ["a beautiful perfect face girl, Anime fine details portrait of school girl in front of modern tokyo city landscape on the background deep bokeh, anime masterpiece by studio ghibli, 8k, sharp high quality anime, artstation", 7.5, 27], + ["cyberpunk city landscape with fancy car", 7.5, 27], + ["portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", 7.5, 27], + ["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", 7.5, 27], + ], [prompt, guidance, steps], image_out, inference_example, cache_examples=torch.cuda.is_available()) + gr.Markdown(''' + Models and Space by [@DGSpitzer](https://huggingface.co/DGSpitzer)❤️
+ [![Twitter Follow](https://img.shields.io/twitter/follow/DGSpitzer?label=%40DGSpitzer&style=social)](https://twitter.com/DGSpitzer) + ![visitors](https://visitor-badge.glitch.me/badge?page_id=dgspitzer_DGS_Diffusion_Space) + + ![Model Views](https://visitor-badge.glitch.me/badge?page_id=Cyberpunk_Anime_Diffusion) + + ''') + +with gr.Blocks(css=css) as demo: + state = gr.Variable({ + 'selected': -1 + }) + state = {} + def update_state(i): + global checkbox_states + if(checkbox_states[i]): + checkbox_states[i] = False + state[i] = False + else: + state[i] = True + checkbox_states[i] = True + + with gr.Row().style(mobile_collapse=False, equal_height=True): + + text = gr.Textbox( + label="Enter your prompt", show_label=False, max_lines=1 + ).style( + border=(True, False, True, True), + rounded=(True, False, False, True), + container=False, + ) + btn = gr.Button("Run").style( + margin=False, + rounded=(False, True, True, False), + ) + + gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="generated_id").style( + grid=[2], height="auto" + ) + + ex = gr.Examples(examples=examples, fn=infer, inputs=[text], outputs=gallery, cache_examples=True) + ex.dataset.headers = [""] + + text.submit(infer, inputs=[text], outputs=gallery) + btn.click(infer, inputs=[text], outputs=gallery) + + with gr.Row(): + with gr.Column(): + gr.Markdown(f"### Navigate the top 100 Textual-Inversion community trained concepts. Use 600+ from [The Library](https://huggingface.co/sd-concepts-library)") + with gr.Row(): + image_blocks = [] + #for i, model in enumerate(models): + with gr.Box().style(border=None): + gr.HTML(assembleHTML(models)) + #title_block(model["token"], model["id"]) + #image_blocks.append(image_block(model["images"], model["concept_type"])) + with gr.Column(): + with gr.Box(): + with gr.Row(elem_id="prompt_area").style(mobile_collapse=False, equal_height=True): + text = gr.Textbox( + label="Enter your prompt", placeholder="Enter your prompt", show_label=False, max_lines=1, elem_id="prompt_input" + ).style( + border=(True, False, True, True), + rounded=(True, False, False, True), + container=False, + full_width=False, + ) + btn = gr.Button("Run",elem_id="run_btn").style( + margin=False, + rounded=(False, True, True, False), + full_width=False, + ) + with gr.Row().style(): + infer_outputs = gr.Gallery(show_label=False, elem_id="generated-gallery").style(grid=[2], height="512px") + with gr.Row(): + gr.HTML("

Prompting may not work as you are used to. objects may need the concept added at the end, styles may work better at the beginning. You can navigate on lexica.art to get inspired on prompts

") + with gr.Row(): + gr.Examples(examples=examples, fn=infer_examples, inputs=[text], outputs=infer_outputs, cache_examples=True) + with gr.Group(elem_id="share-btn-container"): + community_icon = gr.HTML(community_icon_html, visible=False) + loading_icon = gr.HTML(loading_icon_html, visible=False) + share_button = gr.Button("Share to community", elem_id="share-btn", visible=False) + checkbox_states = {} + inputs = [text] + btn.click( + infer, + inputs=inputs, + outputs=[infer_outputs, community_icon, loading_icon, share_button] + ) + share_button.click( + None, + [], + [], + _js=share_js,) + with gr.Blocks(css=css) as demo: + + with gr.Row(): + + with gr.Group(): + model_name = gr.Dropdown(label="Model", choices=[m.name for m in models], value=current_model.name) + custom_model_path = gr.Textbox(label="Custom model path", placeholder="Path to model, e.g. nitrosocke/Arcane-Diffusion", visible=False, interactive=True) + + with gr.Row(): + prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2,placeholder="Enter prompt. Style applied automatically").style(container=False) + generate = gr.Button(value="Generate").style(rounded=(False, True, True, False)) + + + image_out = gr.Image(height=512) + # gallery = gr.Gallery( + # label="Generated images", show_label=False, elem_id="gallery" + # ).style(grid=[1], height="auto") + + with gr.Tab("Options"): + with gr.Group(): + neg_prompt = gr.Textbox(label="Negative prompt", placeholder="What to exclude from the image") + + # n_images = gr.Slider(label="Images", value=1, minimum=1, maximum=4, step=1) + + with gr.Row(): + guidance = gr.Slider(label="Guidance scale", value=7.5, maximum=15) + steps = gr.Slider(label="Steps", value=50, minimum=2, maximum=100, step=1) + + with gr.Row(): + width = gr.Slider(label="Width", value=512, minimum=64, maximum=1024, step=8) + height = gr.Slider(label="Height", value=512, minimum=64, maximum=1024, step=8) + + seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1) + + with gr.Tab("Image to image"): + with gr.Group(): + image = gr.Image(label="Image", height=256, tool="editor", type="pil") + strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5) + + model_name.change(lambda x: gr.update(visible = x == models[0].name), inputs=model_name, outputs=custom_model_path) + custom_model_path.change(custom_model_changed, inputs=custom_model_path) + # n_images.change(lambda n: gr.Gallery().style(grid=[2 if n > 1 else 1], height="auto"), inputs=n_images, outputs=gallery) + + inputs = [model_name, prompt, guidance, steps, width, height, seed, image, strength, neg_prompt] + prompt.submit(inference, inputs=inputs, outputs=image_out) + generate.click(inference, inputs=inputs, outputs=image_out) + + ex = gr.Examples([ + [models[1].name, "jason bateman disassembling the demon core", 7.5, 50], + [models[4].name, "portrait of dwayne johnson", 7.0, 75], + [models[5].name, "portrait of a beautiful alyx vance half life", 10, 50], + [models[6].name, "Aloy from Horizon: Zero Dawn, half body portrait, smooth, detailed armor, beautiful face, illustration", 7.0, 45], + [models[5].name, "fantasy portrait painting, digital art", 4.0, 30], + ], [model_name, prompt, guidance, steps, seed], image_out, inference, cache_examples=not is_colab and torch.cuda.is_available()) + # ex.dataset.headers = [""] + + gr.Markdown(''' + Models by [@nitrosocke](https://huggingface.co/nitrosocke), [@Helixngc7293](https://twitter.com/DGSpitzer) and others. ❤️
+ Space by: [![Twitter Follow](https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social)](https://twitter.com/hahahahohohe) + + ![visitors](https://visitor-badge.glitch.me/badge?page_id=anzorq.finetuned_diffusion) + ''') + block = gr.Blocks(css=css) + +examples = [ + [ + 'A high tech solarpunk utopia in the Amazon rainforest', +# 4, +# 45, +# 7.5, +# 1024, + ], + [ + 'A pikachu fine dining with a view to the Eiffel Tower', +# 4, +# 45, +# 7, +# 1024, + ], + [ + 'A mecha robot in a favela in expressionist style', +# 4, +# 45, +# 7, +# 1024, + ], + [ + 'an insect robot preparing a delicious meal', +# 4, +# 45, +# 7, +# 1024, + ], + [ + "A small cabin on top of a snowy mountain in the style of Disney, artstation", +# 4, +# 45, +# 7, +# 1024, + ], +] + + +with block: + + with gr.Group(): + with gr.Box(): + with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True): + text = gr.Textbox( + label="Enter your prompt", + show_label=False, + max_lines=1, + placeholder="Enter your prompt", + elem_id="prompt-text-input", + ).style( + border=(True, False, True, True), + rounded=(True, False, False, True), + container=False, + ) + btn = gr.Button("Generate image").style( + margin=False, + rounded=(False, True, True, False), + full_width=False, + ) + + gallery = gr.Gallery( + label="Generated images", show_label=False, elem_id="gallery" + ).style(grid=[2], height="auto") + + with gr.Group(elem_id="container-advanced-btns"): + advanced_button = gr.Button("Advanced options", elem_id="advanced-btn") + with gr.Group(elem_id="share-btn-container"): + community_icon = gr.HTML(community_icon_html) + loading_icon = gr.HTML(loading_icon_html) + share_button = gr.Button("Share to community", elem_id="share-btn") + + with gr.Row(elem_id="advanced-options"): + gr.Markdown("Advanced settings are temporarily unavailable") + samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1) + steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=45, step=1) + scale = gr.Slider( + label="Guidance Scale", minimum=0, maximum=50, value=7.5, step=0.1 + ) + seed = gr.Slider( + label="Seed", + minimum=0, + maximum=2147483647, + step=1, + randomize=True, + ) + + ex = gr.Examples(examples=examples, fn=infer, inputs=text, outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False) + ex.dataset.headers = [""] + + text.submit(infer, inputs=text, outputs=[gallery], postprocess=False) + btn.click(infer, inputs=text, outputs=[gallery], postprocess=False) + + advanced_button.click( + None, + [], + text, + _js=""" + () => { + const options = document.querySelector("body > gradio-app").querySelector("#advanced-options"); + options.style.display = ["none", ""].includes(options.style.display) ? "flex" : "none"; + }""", + ) + share_button.click( + None, + [], + [], + _js=share_js, + ) + + with gr.Row(): + with gr.Column(): + input_img = gr.Image(type="filepath", elem_id="input-img") + with gr.Row(): + see_prompts = gr.Button("Feed in your image!") + + with gr.Column(): + img2text_output = gr.Textbox( + label="Generated text prompt", + lines=4, + elem_id="translated" + ) + with gr.Row(): + diffuse_btn = gr.Button(value="Diffuse it!") + with gr.Column(elem_id="generated-gallery"): + sd_output = gr.Gallery().style(grid=2, height="auto") + with gr.Group(elem_id="share-btn-container"): + community_icon = gr.HTML(community_icon_html, visible=False) + loading_icon = gr.HTML(loading_icon_html, visible=False) + share_button = gr.Button("Share to community", elem_id="share-btn", visible=False) + + see_prompts.click(get_prompts, + inputs = input_img, + outputs = [ + img2text_output + ]) + diffuse_btn.click(get_images, + inputs = [ + img2text_output + ], + outputs = [sd_output, community_icon, loading_icon, share_button] + ) + share_button.click(None, [], [], _js=share_js) + +if not is_colab: + demo.queue(concurrency_count=4) +demo.launch(debug=is_colab, share=is_colab) +demo.queue(max_size=25).launch() +demo.queue() +demo.launch() diff --git a/py.py b/py.py new file mode 100644 index 0000000..3d1b066 --- /dev/null +++ b/py.py @@ -0,0 +1,61 @@ + gr.HTML( + """ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Image Generation Test +

+
+

+ Test My Concept +

+
+
+

LICENSE

+ The model is licensed with a CreativeML Open RAIL-M license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please read the license

+

Biases and content acknowledgment

+ Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the LAION-5B dataset, which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the model card

+
+ """ + )