Scriptyfa / app.py
Ridam7777u's picture
Upload 5 files
be416b0 verified
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()