import gradio as gr import os from share_btn import community_icon_html, loading_icon_html, share_js text_gen = gr.load(name="spaces/Ashrafb/MagicPrompt-Stable-Diffusiongust") stable_diffusion = gr.load(name="spaces/runwayml/stable-diffusion-v1-5") def get_images(prompt): gallery_dir = stable_diffusion(prompt, fn_index=2) sd_output = [os.path.join(gallery_dir, image) for image in os.listdir(gallery_dir)] return sd_output, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True) def get_prompts(prompt_text): return text_gen(prompt_text) css = ''' .animate-spin { animation: spin 1s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } footer{display:none !important} ''' with gr.Blocks(css=css) as demo: gr.HTML("""
This Space prettifies your prompt using MagicPrompt and then runs it through Stable Diffusion to create aesthetically pleasing images. Simply enter a few concepts and let it improve your prompt. You can then diffuse the prompt.