Spaces:
Runtime error
Runtime error
Upload 5 files
Browse files- README.md +17 -12
- app.py +47 -0
- requirements.txt +8 -0
- style.css +15 -0
- utils.py +27 -0
README.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Scriptify AI - Prompt to Image Generator (Free Hugging Face Space)
|
2 |
+
|
3 |
+
A free, beautiful, and powerful AI app that turns text into high-quality images using Stable Diffusion XL.
|
4 |
+
|
5 |
+
## Features:
|
6 |
+
- Powered by SDXL 1.0
|
7 |
+
- Custom UI with Gradio
|
8 |
+
- Responsive layout
|
9 |
+
- Works on mobile
|
10 |
+
- Free & Unlimited (via Hugging Face)
|
11 |
+
|
12 |
+
## Instructions:
|
13 |
+
1. Upload to Hugging Face Space (select `Gradio` + `Public`)
|
14 |
+
2. Make sure to install all requirements
|
15 |
+
3. Start creating!
|
16 |
+
|
17 |
+
> Made with π by Ridam & ChatGPT (o4)
|
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import load_model, generate_image, prompt_presets
|
3 |
+
|
4 |
+
pipe = load_model()
|
5 |
+
|
6 |
+
with gr.Blocks(css="style.css") as demo:
|
7 |
+
gr.Markdown("# π Scriptify AI - Ultra Image Generator with ControlNet + Voice")
|
8 |
+
gr.Markdown("Create beautiful, controlled images using AI. Supports voice prompts, styles, and ControlNet!")
|
9 |
+
|
10 |
+
with gr.Row():
|
11 |
+
prompt_input = gr.Textbox(placeholder="e.g., cinematic shot of a samurai in rain", label="π Text Prompt", lines=2)
|
12 |
+
voice_input = gr.Audio(source="microphone", type="filepath", label="π€ Or Speak Prompt")
|
13 |
+
|
14 |
+
with gr.Accordion("π§ Advanced Settings", open=False):
|
15 |
+
with gr.Row():
|
16 |
+
style_dropdown = gr.Dropdown(choices=list(prompt_presets.keys()), value="None", label="π¨ Style Presets")
|
17 |
+
guidance = gr.Slider(minimum=1, maximum=20, value=7.5, label="ποΈ Guidance Scale")
|
18 |
+
steps = gr.Slider(minimum=10, maximum=50, value=30, label="π§ Inference Steps")
|
19 |
+
|
20 |
+
with gr.Row():
|
21 |
+
width = gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="πΌοΈ Width")
|
22 |
+
height = gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="πΌοΈ Height")
|
23 |
+
|
24 |
+
generate_button = gr.Button("β¨ Generate Image")
|
25 |
+
output_image = gr.Image(type="pil", label="πΌοΈ Result Image")
|
26 |
+
status = gr.Textbox(visible=False)
|
27 |
+
|
28 |
+
def run(prompt, voice, style, guidance, steps, width, height):
|
29 |
+
import whisper
|
30 |
+
if voice:
|
31 |
+
model = whisper.load_model("base")
|
32 |
+
result = model.transcribe(voice)
|
33 |
+
prompt = result["text"]
|
34 |
+
|
35 |
+
if style != "None":
|
36 |
+
prompt = f"{prompt}, {prompt_presets[style]}"
|
37 |
+
try:
|
38 |
+
image = generate_image(pipe, prompt, guidance, steps, width, height)
|
39 |
+
return image, ""
|
40 |
+
except Exception as e:
|
41 |
+
return None, f"β οΈ {str(e)}"
|
42 |
+
|
43 |
+
generate_button.click(fn=run,
|
44 |
+
inputs=[prompt_input, voice_input, style_dropdown, guidance, steps, width, height],
|
45 |
+
outputs=[output_image, status])
|
46 |
+
|
47 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.24.0
|
2 |
+
torch
|
3 |
+
diffusers
|
4 |
+
transformers
|
5 |
+
accelerate
|
6 |
+
safetensors
|
7 |
+
whisper
|
8 |
+
ffmpeg
|
style.css
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
background-color: #0f172a;
|
3 |
+
color: white;
|
4 |
+
font-family: 'Segoe UI', sans-serif;
|
5 |
+
}
|
6 |
+
|
7 |
+
h1 {
|
8 |
+
color: #38bdf8;
|
9 |
+
}
|
10 |
+
|
11 |
+
.gr-button {
|
12 |
+
background-color: #2563eb !important;
|
13 |
+
border-radius: 12px !important;
|
14 |
+
font-weight: bold !important;
|
15 |
+
}
|
utils.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import DiffusionPipeline
|
2 |
+
import torch
|
3 |
+
|
4 |
+
prompt_presets = {
|
5 |
+
"Cinematic": "cinematic lighting, epic composition, 8k",
|
6 |
+
"Realistic Portrait": "realistic face, shallow depth of field, photography",
|
7 |
+
"Anime Style": "anime, cel-shading, crisp lines, colorful",
|
8 |
+
"Fantasy": "mythical, magical light, detailed, fantasy world",
|
9 |
+
"None": ""
|
10 |
+
}
|
11 |
+
|
12 |
+
def load_model():
|
13 |
+
print("Loading SDXL model...")
|
14 |
+
pipe = DiffusionPipeline.from_pretrained(
|
15 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
16 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
17 |
+
variant="fp16" if torch.cuda.is_available() else None
|
18 |
+
)
|
19 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
20 |
+
return pipe
|
21 |
+
|
22 |
+
def generate_image(pipe, prompt: str, guidance: float, steps: int, width: int, height: int):
|
23 |
+
if not prompt or len(prompt.strip()) < 5:
|
24 |
+
raise ValueError("Prompt too short. Please describe your idea better.")
|
25 |
+
|
26 |
+
result = pipe(prompt, guidance_scale=guidance, num_inference_steps=steps, height=height, width=width)
|
27 |
+
return result.images[0]
|