Spaces:
Runtime error
Runtime error
import gradio as gr | |
from utils import load_model, generate_image, prompt_presets | |
pipe = load_model() | |
with gr.Blocks(css="style.css") as demo: | |
gr.Markdown("# π Scriptify AI - Ultra Image Generator with ControlNet + Voice") | |
gr.Markdown("Create beautiful, controlled images using AI. Supports voice prompts, styles, and ControlNet!") | |
with gr.Row(): | |
prompt_input = gr.Textbox(placeholder="e.g., cinematic shot of a samurai in rain", label="π Text Prompt", lines=2) | |
voice_input = gr.Audio(source="microphone", type="filepath", label="π€ Or Speak Prompt") | |
with gr.Accordion("π§ Advanced Settings", open=False): | |
with gr.Row(): | |
style_dropdown = gr.Dropdown(choices=list(prompt_presets.keys()), value="None", label="π¨ Style Presets") | |
guidance = gr.Slider(minimum=1, maximum=20, value=7.5, label="ποΈ Guidance Scale") | |
steps = gr.Slider(minimum=10, maximum=50, value=30, label="π§ Inference Steps") | |
with gr.Row(): | |
width = gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="πΌοΈ Width") | |
height = gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="πΌοΈ Height") | |
generate_button = gr.Button("β¨ Generate Image") | |
output_image = gr.Image(type="pil", label="πΌοΈ Result Image") | |
status = gr.Textbox(visible=False) | |
def run(prompt, voice, style, guidance, steps, width, height): | |
import whisper | |
if voice: | |
model = whisper.load_model("base") | |
result = model.transcribe(voice) | |
prompt = result["text"] | |
if style != "None": | |
prompt = f"{prompt}, {prompt_presets[style]}" | |
try: | |
image = generate_image(pipe, prompt, guidance, steps, width, height) | |
return image, "" | |
except Exception as e: | |
return None, f"β οΈ {str(e)}" | |
generate_button.click(fn=run, | |
inputs=[prompt_input, voice_input, style_dropdown, guidance, steps, width, height], | |
outputs=[output_image, status]) | |
demo.launch() |