Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
import torch
|
3 |
-
from diffusers import StableDiffusionPipeline
|
4 |
from groq import Groq
|
5 |
|
6 |
-
# Initialize the Stable Diffusion model
|
7 |
-
model_id = "stabilityai/stable-diffusion-2" # Example model
|
8 |
-
sd_pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
9 |
-
sd_pipe.to("cpu")
|
10 |
-
|
11 |
# Initialize the Groq client with your API key
|
12 |
-
client = Groq(api_key="
|
13 |
|
14 |
# Define the system message for the model
|
15 |
system_message = {
|
@@ -46,19 +39,15 @@ def generate_movie_content(theme):
|
|
46 |
])
|
47 |
script = script_response["choices"][0]["message"]["content"]
|
48 |
|
49 |
-
|
50 |
-
image_prompt = f"A cinematic illustration of the theme: {theme}"
|
51 |
-
image = sd_pipe(image_prompt).images[0]
|
52 |
-
|
53 |
-
return characters, storyline, script, image
|
54 |
|
55 |
def main_interface(theme):
|
56 |
-
characters, storyline, script
|
57 |
-
return
|
58 |
|
59 |
# Gradio Interface
|
60 |
-
title = "Movie Script
|
61 |
-
description = "Generate movie scripts, characters, and
|
62 |
|
63 |
demo = gr.Interface(
|
64 |
fn=main_interface,
|
@@ -66,11 +55,14 @@ demo = gr.Interface(
|
|
66 |
gr.Textbox(label="Theme", placeholder="Enter the movie theme"),
|
67 |
],
|
68 |
outputs=[
|
69 |
-
gr.Textbox(label="
|
70 |
-
gr.
|
|
|
71 |
],
|
72 |
title=title,
|
73 |
description=description,
|
|
|
|
|
74 |
)
|
75 |
|
76 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from groq import Groq
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
# Initialize the Groq client with your API key
|
5 |
+
client = Groq(api_key="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")
|
6 |
|
7 |
# Define the system message for the model
|
8 |
system_message = {
|
|
|
39 |
])
|
40 |
script = script_response["choices"][0]["message"]["content"]
|
41 |
|
42 |
+
return characters, storyline, script
|
|
|
|
|
|
|
|
|
43 |
|
44 |
def main_interface(theme):
|
45 |
+
characters, storyline, script = generate_movie_content(theme)
|
46 |
+
return characters, storyline, script
|
47 |
|
48 |
# Gradio Interface
|
49 |
+
title = "Movie Script Generator"
|
50 |
+
description = "Generate movie scripts, characters, and storylines based on a single theme."
|
51 |
|
52 |
demo = gr.Interface(
|
53 |
fn=main_interface,
|
|
|
55 |
gr.Textbox(label="Theme", placeholder="Enter the movie theme"),
|
56 |
],
|
57 |
outputs=[
|
58 |
+
gr.Textbox(label="Main Characters", lines=5),
|
59 |
+
gr.Textbox(label="Storyline", lines=5),
|
60 |
+
gr.Textbox(label="Movie Script", lines=10),
|
61 |
],
|
62 |
title=title,
|
63 |
description=description,
|
64 |
+
layout="vertical",
|
65 |
+
theme="compact"
|
66 |
)
|
67 |
|
68 |
if __name__ == "__main__":
|