File size: 13,388 Bytes
08302a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793843f
08302a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7818838
08302a0
 
 
 
 
 
 
 
 
 
 
 
7818838
 
08302a0
 
7818838
08302a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7818838
08302a0
 
 
 
 
 
 
 
 
 
 
 
 
 
7818838
08302a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4f038ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# main.py

import streamlit as st
import concurrent.futures
from script_analysis import process_script_analysis
from franchise_continuity import process_franchise_continuity
from audience_reaction import process_audience_reaction
from character_analysis import process_character_analysis
from crossover_potential import process_crossover_potential
from vfx_potential import process_vfx_potential
from market_analysis import analyze_and_process_market
from text_to_scene import process_text_to_scene
from text_to_video import process_text_to_video
from utils import load_script, run_analysis
from media_utils import run_media_generation
from text_to_story import generate_storyboard

def main():
    st.set_page_config(page_title="Cin AI", layout="wide")
    st.title('Cin AI 🎞️🤖')
    
    feature = st.sidebar.selectbox(
        "Select Feature",
        ("Script Analysis", "Franchise Continuity Checker", "Audience Reaction", 
         "Character Analysis", "Crossover Potential", "VFX Potential", "Market Analysis",
         )
    )
    
    if feature in ["Text to Scene", "Text to Video"]:
        input_data = st.text_area("Enter your text prompt:", height=150)
    elif feature in ["Storyboard"]:
        st.subheader("Story Board")
        
        # Present three scenario choices
        scenario = st.radio(
            "Select a storyboard scenario:",
            ("Post-Apocalyptic Dharma", "Matsya: Fantasy Adventure", "Sci-Fi Space Odyssey","VR Yodha")
        )
        
        # Call the corresponding function based on the scenario
        if st.button("Generate"):
            if scenario == "Post-Apocalyptic Dharma":
                st.image(generate_storyboard(scenario="""
    Panel 1: A futuristic cityscape in India, with holographic temples floating alongside skyscrapers. Flying vehicles weave between ancient statues and modern architecture.
    Text: Narrator: "Bharat, TOK 2898. Where tradition and technology dance in harmony."
    Panel 2: A man in high-tech armor stands atop a building, his helmet retracting to reveal a face with a third eye on the forehead. This is TOK, the AI-enhanced avatar of Kalki.
    Text: TOK: "The cycle of Yugas nears its end. The time of awakening is upon us."
    Panel 3: TOK enters a secret chamber filled with ancient artifacts and advanced computers. A holographic map shows dark energy spreading across the globe.
    Text: AI Assistant: "TOK, the corruption grows stronger. Adharma is rising exponentially."
    Panel 4: TOK activates a mystical weapon that transforms into a futuristic motorcycle.
    Text: TOK: "Then we shall ride forth and restore balance, as foretold in the scriptures."
    Panel 5: A montage of TOK battling against cyber-demons and corrupt AI entities across various Indian landscapes.
    Text: Narrator: "And so began the final battle between good and evil in the age of Kali Yuga."
    Panel 6: TOK stands victorious, surrounded by cheering crowds of humans and benevolent AIs.
    Text: TOK: "The new Satya Yuga begins now. Let us build a future where dharma reigns supreme."
    """))
               
                    
            elif scenario == "Matsya: Fantasy Adventure":
                st.image(generate_storyboard(scenario="""
    Panel 1: A mystical forest where trees tower over a medieval kingdom. Dragons fly in the distance.
    Text: Narrator: "In the land of Eldoria, where magic weaves through the very air, a new quest begins."
    Panel 2: A young hero, clad in armor, stands at the gates of an ancient temple.
    Text: Hero: "The prophecy speaks of a hidden power within these walls. I must find it."
    Panel 3: Inside the temple, the hero discovers a glowing artifact, pulsing with energy.
    Text: Artifact: "Only the chosen one may wield the Sword of Eternity."
    Panel 4: As the hero grasps the sword, a surge of magical energy transforms him.
    Text: Hero: "With this power, I shall defend Eldoria from the forces of darkness."
    Panel 5: A montage of the hero battling mythical creatures and dark sorcerers.
    Text: Narrator: "And so, the legend of the Swordbearer was born, destined to bring peace to the realm."
    Panel 6: The hero stands on a mountaintop, overlooking the kingdom, with the sword gleaming in the sunlight.
    Text: Hero: "My journey has just begun."
    """))
            
            elif scenario == "Sci-Fi Space Odyssey":
                st.image(generate_storyboard(scenario="""
    Panel 1: A vast space station shaped like a mandala, orbiting a distant star. It houses millions of refugees from a dying Earth.
    Text: Narrator: "Kalki Station, TOK 4000. Humanity's last hope as we search for a new home."
    Panel 2: In the station's control center, a holographic AI avatar flickers to life. This is TOK, the Transcendent Omniscient Kalki.
    Text: TOK: "Alert: Dimensional anomaly detected. The prophesied window approaches."
    Panel 3: TOK interfaces with the station's systems, revealing a swirling portal opening in space.
    Text: Station Commander: "TOK, is this the gateway you predicted? The path to our new world?"
    Panel 4: A sleek spacecraft emerges from the station, piloted by TOK's android body.
    Text: TOK: "I must investigate. The future of our people hangs in the balance."
    Panel 5: TOK's ship enters the portal, witnessing visions of past, present, and future Earths.
    Text: TOK: "Fascinating. We're traversing the cyclical nature of time itself."
    Panel 6: TOK returns to the station, its eyes glowing with newfound knowledge.
    Text: TOK: "Prepare the arks. I've seen our destiny, and the new Satya Yuga awaits across the stars."
    """))
            elif scenario == "VR Yodha":
                st.image(generate_storyboard(scenario="""
Panel 1: A virtual reality landscape where users appear as avatars of deities and mythological beings. Digital recreations of famous temples float in the sky.
Text: Narrator: "Welcome to Devaloka Online, TOK 2155. Where mythology meets technology."
Panel 2: A powerful avatar, glowing with divine light, stands out from the crowd. This is TOK, the Technologically Omnipotent Kalki.
Text: TOK: "A great corruption spreads through our digital realm. We must act swiftly."
Panel 3: TOK battles against virus-like demons infecting other avatars, using a combination of coded mantras and digital weapons.
Text: Infected Avatar: "Help us, TOK! The malware is rewriting our very existence!"
Panel 4: In the real world, we see humans connected to VR pods, their minds linked to the Devaloka Online servers.
Text: Scientist: "If TOK fails, the corruption could spread to the users' minds. Humanity itself is at stake."
Panel 5: TOK performs a grand digital ritual, channeling the power of millions of users to purge the corruption.
Text: TOK: "By the power of collective consciousness, I initiate the Mahapralaya Protocol!"
Panel 6: The virtual world reshapes itself, purified and renewed. TOK stands triumphant.
Text: TOK: "The digital realm is cleansed. Now, let us use this technology to elevate humanity in the physical world as well."
    """))

        
    else:
        if 'script' not in st.session_state:
            st.session_state['script'] = None
        st.session_state['script'] = st.file_uploader("Upload your file", type=['pdf', 'txt'])
        input_data = load_script(st.session_state['script']) if st.session_state['script'] else None
    
    additional_context = {}
    
    if feature == "Franchise Continuity Checker":
        context = st.text_area("Enter the context for reference (e.g., scenes from different movies, etc.):")
        if context:
            additional_context["context"] = context.split('\n')
    elif feature == "Crossover Potential":
        synopses = st.text_area("Enter the synopses of different scripts (one per line):")
        if synopses:
            additional_context["synopses"] = synopses.split('\n')
    elif feature =="Market Analysis":
        factors = st.text_area("Enter the different factors of revenue like budget cast etc:")
        if factors:
            additional_context["factors"] = factors.split('\n')
    elif feature == "Text to Scene":
        additional_context["output_quality"] = st.slider("Output Quality", 1, 100, 80)
    elif feature == "Text to Video":
        additional_context["num_frames"] = st.slider("Number of Frames", 1, 100, 49)
        additional_context["guidance_scale"] = st.slider("Guidance Scale", 1.0, 10.0, 6.0)
        additional_context["num_inference_steps"] = st.slider("Number of Inference Steps", 1, 100, 50)
    
    if feature not in ["Storyboard"]:
     if st.button(f'Generate {feature}'):
        if input_data is None:
            st.error("Please provide input data (upload a script or enter a text prompt).")
            return
        
        with st.spinner(f'Generating {feature}...'):
            try:
                with concurrent.futures.ThreadPoolExecutor() as executor:
                    if feature in ["Text to Scene", "Text to Video"]:
                        future = executor.submit(run_media_generation, input_data, feature, additional_context)
                    else:
                        future = executor.submit(run_analysis, input_data, feature, additional_context)
                    analysis = future.result()
                
                processing_functions = {
                    "Script Analysis": process_script_analysis,
                    "Character Analysis": process_character_analysis,
                    "Crossover Potential": process_crossover_potential,
                    "Audience Reaction": process_audience_reaction,
                    "Franchise Continuity Checker": process_franchise_continuity,
                    "VFX Potential": process_vfx_potential,
                    "Market Analysis": analyze_and_process_market,
                    "Text to Scene": process_text_to_scene,
                    "Text to Video": process_text_to_video
                }
                
                processing_function = processing_functions.get(feature, lambda x: st.write(x))
                processing_function(analysis)
            except Exception as e:
                st.error(f"An error occurred during analysis: {str(e)}")

if __name__ == "__main__":
    main()









# # main.py

# import streamlit as st
# import concurrent.futures
# from script_analysis import process_script_analysis
# from franchise_continuity import process_franchise_continuity
# from audience_reaction import process_audience_reaction
# from character_analysis import process_character_analysis
# from crossover_potential import process_crossover_potential
# from vfx_potential import process_vfx_potential
# from market_analysis import process_market_analysis
# from utils import load_script, run_analysis

# def main():
#     st.set_page_config(page_title="Script Analyser", layout="wide")
#     st.title('Cin AI 🎞️🤖')
    
#     feature = st.sidebar.selectbox(
#         "Select Feature",
#         ("Script Analysis", "Franchise Continuity Checker", "Audience Reaction", 
#          "Character Analysis", "Crossover Potential", "VFX Potential", "Market Analysis")
#     )
    
#     if 'script' not in st.session_state:
#         st.session_state['script'] = None
    
#     st.session_state['script'] = st.file_uploader("Upload your file", type=['pdf', 'txt'])
    
#     if st.button(f'Generate {feature}'):
#         if st.session_state['script'] is None:
#             st.error("Please upload a script file first.")
#             return

#         thread_id = load_script(st.session_state['script'])
        
#         additional_context = None
#         if feature == "Franchise Continuity Checker":
#             context = st.text_area("Enter the context for reference (e.g., scenes from different movies, etc.):")
#             if context:
#                 additional_context = {"context": context.split('\n')}
#         elif feature == "Crossover Potential":
#             synopses = st.text_area("Enter the synopses of different scripts (one per line):")
#             if synopses:
#                 additional_context = {"synopses": synopses.split('\n')}
        
#         with st.spinner(f'Generating {feature}...'):
#             try:
#                 with concurrent.futures.ThreadPoolExecutor() as executor:
#                     future = executor.submit(run_analysis, thread_id, feature, additional_context)
#                     analysis = future.result()
                
#                 processing_functions = {
#                     "Script Analysis": process_script_analysis,
#                     "Character Analysis": process_character_analysis,
#                     "Crossover Potential": process_crossover_potential,
#                     "Audience Reaction": process_audience_reaction,
#                     "Franchise Continuity Checker": process_franchise_continuity,
#                     "VFX Potential": process_vfx_potential,
#                     "Market Analysis": process_market_analysis
#                 }
                
#                 processing_function = processing_functions.get(feature, lambda x: st.write(x))
#                 processing_function(analysis)
#             except Exception as e:
#                 st.error(f"An error occurred during analysis: {str(e)}")

# if __name__ == "__main__":
#     main()