Spaces:
Runtime error
Runtime error
Scriptyfai
#1
by
Ridam7777u
- opened
- README.md +5 -6
- app.py +0 -47
- requirements.txt +0 -8
- style.css +0 -15
- utils.py +0 -27
README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.36.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
|
13 |
-
Generate beautiful images from text using SDXL, voice input, and style presets.
|
|
|
1 |
---
|
2 |
+
title: Scriptyfa
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: red
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.36.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
app.py
DELETED
@@ -1,47 +0,0 @@
|
|
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
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
gradio==4.24.0
|
2 |
-
torch
|
3 |
-
diffusers
|
4 |
-
transformers
|
5 |
-
accelerate
|
6 |
-
safetensors
|
7 |
-
whisper
|
8 |
-
ffmpeg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
style.css
DELETED
@@ -1,15 +0,0 @@
|
|
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
DELETED
@@ -1,27 +0,0 @@
|
|
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]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|