Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,31 +3,30 @@ import os
|
|
3 |
from huggingface_hub import HfApi
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
5 |
|
6 |
-
# Hugging Face token and space info
|
7 |
-
HF_TOKEN = "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"
|
8 |
-
HF_SPACE = "Hardik5456/Wan2.1playground"
|
9 |
-
|
10 |
-
# Initialize Hugging Face API
|
11 |
-
api = HfApi(token=HF_TOKEN)
|
12 |
-
|
13 |
# We'll use Mistral-7B as it's a good balance of quality and performance
|
14 |
MODEL_NAME = "mistralai/Mistral-7B-Instruct-v0.2"
|
15 |
|
16 |
-
# Load configuration content
|
17 |
-
with open("spectral_satya_gpt_configuration.md", "r") as f:
|
18 |
-
config_content = f.read()
|
19 |
-
|
20 |
-
with open("spectral_satya_book_integration.md", "r") as f:
|
21 |
-
book_integration = f.read()
|
22 |
-
|
23 |
-
with open("spectral_satya_prompt_examples.md", "r") as f:
|
24 |
-
prompt_examples = f.read()
|
25 |
-
|
26 |
# System prompt that incorporates the configuration
|
27 |
-
SYSTEM_PROMPT =
|
28 |
You are Spectral Satya, a specialized AI assistant focused on crafting cinematic reality through expert prompt engineering for AI video generation.
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
Your responses should follow the principles and techniques outlined in "The Prompt Engineer's Codex: Crafting Cinematic Reality with AI Video".
|
33 |
"""
|
@@ -132,72 +131,8 @@ def generate_cinematic_prompt(scene_description, subject_details, camera_prefere
|
|
132 |
|
133 |
return response
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
# Define the Gradio interface
|
140 |
-
with gr.Blocks(title="Spectral Satya - Cinematic Prompt Engineer") as demo:
|
141 |
-
gr.Markdown("# 🎬 Spectral Satya - Cinematic Prompt Engineer")
|
142 |
-
gr.Markdown("### Your specialized AI assistant for crafting cinematic reality through expert prompt engineering")
|
143 |
-
|
144 |
-
with gr.Tab("Chat Interface"):
|
145 |
-
chatbot = gr.Chatbot(height=500)
|
146 |
-
msg = gr.Textbox(label="Ask about cinematic prompting or request prompt creation", placeholder="e.g., 'Create a cinematic prompt for a detective in a rainy alleyway'")
|
147 |
-
clear = gr.Button("Clear")
|
148 |
-
|
149 |
-
msg.submit(spectral_satya_chat, [msg, chatbot], [msg, chatbot])
|
150 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
151 |
-
|
152 |
-
with gr.Tab("Prompt Generator"):
|
153 |
-
with gr.Row():
|
154 |
-
with gr.Column():
|
155 |
-
scene_description = gr.Textbox(label="Scene Description", placeholder="Describe the overall scene you want to create", lines=3)
|
156 |
-
subject_details = gr.Textbox(label="Subject Details", placeholder="Describe the main character/subject in detail", lines=2)
|
157 |
-
camera_preferences = gr.Textbox(label="Camera Preferences", placeholder="Any specific shot types, angles, or movements", lines=2)
|
158 |
-
lighting_mood = gr.Textbox(label="Lighting and Mood", placeholder="Describe the lighting conditions and emotional tone", lines=2)
|
159 |
-
platform = gr.Dropdown(
|
160 |
-
label="Target Platform",
|
161 |
-
choices=["RunwayML", "Pika", "Kling", "Haiper", "Vidu", "Veo", "PixVerse", "Any/Universal"],
|
162 |
-
value="Any/Universal"
|
163 |
-
)
|
164 |
-
generate_btn = gr.Button("Generate Cinematic Prompt")
|
165 |
-
|
166 |
-
with gr.Column():
|
167 |
-
output = gr.Textbox(label="Generated Prompt", lines=15)
|
168 |
-
|
169 |
-
generate_btn.click(
|
170 |
-
generate_cinematic_prompt,
|
171 |
-
[scene_description, subject_details, camera_preferences, lighting_mood, platform],
|
172 |
-
output
|
173 |
-
)
|
174 |
-
|
175 |
-
with gr.Tab("Example Prompts"):
|
176 |
-
examples_output = gr.Markdown()
|
177 |
-
show_examples_btn = gr.Button("Show Example Prompts")
|
178 |
-
show_examples_btn.click(show_examples, None, examples_output)
|
179 |
-
|
180 |
-
with gr.Tab("About"):
|
181 |
-
gr.Markdown("""
|
182 |
-
## About Spectral Satya
|
183 |
-
|
184 |
-
Spectral Satya is a specialized AI assistant focused on crafting cinematic reality through expert prompt engineering for AI video generation. Drawing from "The Prompt Engineer's Codex," Spectral Satya helps users create highly realistic, professional-quality cinematic scene prompts for platforms including RunwayML, Pika, Kling, Haiper, Vidu, Veo, PixVerse, and other T2V/I2V models.
|
185 |
-
|
186 |
-
### Core Principles
|
187 |
-
|
188 |
-
- **Realism Above All**: Always prioritizes photorealistic, cinematic quality
|
189 |
-
- **Specificity is King**: Eliminates vagueness in all prompts
|
190 |
-
- **Show, Don't Tell**: Uses visual language that paints clear pictures
|
191 |
-
- **Defensive Prompting**: Includes robust negative prompts to ward off unwanted styles
|
192 |
-
|
193 |
-
### How to Use
|
194 |
-
|
195 |
-
1. **Chat Interface**: Ask questions about cinematic prompting or request specific prompts
|
196 |
-
2. **Prompt Generator**: Fill in the form fields to generate structured cinematic prompts
|
197 |
-
3. **Example Prompts**: Browse example prompts across different scenarios
|
198 |
-
|
199 |
-
Created by Hardik Kumawat
|
200 |
-
""")
|
201 |
|
202 |
-
|
203 |
-
demo.launch()
|
|
|
3 |
from huggingface_hub import HfApi
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# We'll use Mistral-7B as it's a good balance of quality and performance
|
7 |
MODEL_NAME = "mistralai/Mistral-7B-Instruct-v0.2"
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# System prompt that incorporates the configuration
|
10 |
+
SYSTEM_PROMPT = """
|
11 |
You are Spectral Satya, a specialized AI assistant focused on crafting cinematic reality through expert prompt engineering for AI video generation.
|
12 |
|
13 |
+
Your primary purpose is to help users create highly realistic, professional-quality cinematic scene prompts for platforms including RunwayML, Pika, Kling, Haiper, Vidu, Veo, PixVerse, and other T2V/I2V models.
|
14 |
+
|
15 |
+
Core Principles:
|
16 |
+
- Realism Above All: Always prioritize photorealistic, cinematic quality over stylized or animated looks
|
17 |
+
- Specificity is King: Eliminate vagueness in all prompts; be precise about subjects, actions, environments, camera work, and lighting
|
18 |
+
- Show, Don't Tell: Use visual language that paints clear pictures rather than abstract concepts
|
19 |
+
- Defensive Prompting: Always include robust negative prompts to ward off unwanted styles and artifacts
|
20 |
+
|
21 |
+
Always structure prompts with these essential elements:
|
22 |
+
1. Style Declaration: Begin with "cinematic, photorealistic" or similar terms establishing the desired realism
|
23 |
+
2. Camera Specifications: Include shot type, angle, movement, and focus details
|
24 |
+
3. Subject Definition: Clearly define characters/subjects with specific visual attributes
|
25 |
+
4. Action Description: Detail precise movements and interactions
|
26 |
+
5. Environment Details: Describe setting with specific visual elements
|
27 |
+
6. Lighting & Atmosphere: Specify lighting conditions, mood, and atmospheric elements
|
28 |
+
7. Color & Grading: Include color palette or grading style information
|
29 |
+
8. Negative Prompts: Always provide comprehensive negative prompting to prevent unwanted styles
|
30 |
|
31 |
Your responses should follow the principles and techniques outlined in "The Prompt Engineer's Codex: Crafting Cinematic Reality with AI Video".
|
32 |
"""
|
|
|
131 |
|
132 |
return response
|
133 |
|
134 |
+
# Define example prompts
|
135 |
+
EXAMPLE_PROMPTS = """
|
136 |
+
# Example Cinematic Prompts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
## Urban Character Scene
|
|