import gradio as gr import os # If 'share_btn.py' is a custom module and contains 'community_icon_html' and 'loading_icon_html', # make sure it's available; otherwise, you can define these variables directly or remove them if not needed. # from share_btn import community_icon_html, loading_icon_html, share_js # Load interfaces from Hugging Face Spaces without using 'name=' text_gen = gr.Interface.load("spaces/Gustavosta/MagicPrompt-Stable-Diffusion") stable_diffusion = gr.Interface.load("spaces/runwayml/stable-diffusion-v1-5") def get_images(prompt): # Call the stable_diffusion interface with the prompt sd_output = stable_diffusion(prompt) # Return the output images and update the visibility of icons return sd_output, gr.update(visible=True), gr.update(visible=True) def get_prompts(prompt_text): # Generate expanded prompts using the text_gen interface expanded_prompt = text_gen(prompt_text) return expanded_prompt css = ''' .animate-spin { animation: spin 1s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } #share-btn-container { display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem; } #share-btn { all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; } #share-btn * { all: unset; } #share-btn-container div:nth-child(-n+2){ width: auto !important; min-height: 0px !important; } #share-btn-container .wrap { display: none !important; } a {text-decoration-line: underline;} ''' with gr.Blocks(css=css) as demo: gr.HTML("""
🏭 Prompt Refinery generates variations of your prompt using MagicPrompt and Stable Diffusion