Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from models import generate_image | |
| import spaces | |
| with gr.Blocks(title="AI Text-to-Image Generator", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(""" | |
| # AI Text-to-Image Generator | |
| [Built with anycoder](https://huggingface.co/spaces/akhaliq/anycoder) | |
| Generate images from text prompts using FLUX (fast generation). | |
| """) | |
| with gr.Row(): | |
| prompt = gr.Textbox( | |
| label="Prompt", | |
| placeholder="A beautiful sunset over mountains...", | |
| lines=2 | |
| ) | |
| negative_prompt = gr.Textbox( | |
| label="Negative Prompt (optional)", | |
| placeholder="blurry, low quality, distorted", | |
| lines=2 | |
| ) | |
| with gr.Row(): | |
| steps = gr.Slider( | |
| label="Inference Steps", | |
| minimum=1, | |
| maximum=50, | |
| value=20, | |
| step=1 | |
| ) | |
| guidance_scale = gr.Slider( | |
| label="Guidance Scale", | |
| minimum=1.0, | |
| maximum=20.0, | |
| value=7.5, | |
| step=0.5 | |
| ) | |
| generate_btn = gr.Button("Generate Image", variant="primary") | |
| output_image = gr.Image(label="Generated Image") | |
| generate_btn.click( | |
| fn=generate_image, | |
| inputs=[prompt, negative_prompt, steps, guidance_scale], | |
| outputs=output_image | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |