Ridam7777u commited on
Commit
be416b0
Β·
verified Β·
1 Parent(s): 6ab757c

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +17 -12
  2. app.py +47 -0
  3. requirements.txt +8 -0
  4. style.css +15 -0
  5. utils.py +27 -0
README.md CHANGED
@@ -1,12 +1,17 @@
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
 
 
 
 
 
 
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]