Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
|
|
3 |
from groq import Groq
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
# Initialize the Groq client with your API key
|
6 |
client = Groq(api_key="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")
|
7 |
|
@@ -40,14 +46,18 @@ def generate_movie_content(theme):
|
|
40 |
])
|
41 |
script = script_response["choices"][0]["message"]["content"]
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
def main_interface(theme):
|
46 |
-
characters, storyline, script = generate_movie_content(theme)
|
47 |
-
return f"Main Characters: {characters}\n\nStoryline: {storyline}\n\nScript: {script}"
|
48 |
|
49 |
# Gradio Interface
|
50 |
-
title = "Movie Generator"
|
51 |
description = "Generate movie scripts, characters, and thematic images based on a single theme."
|
52 |
|
53 |
demo = gr.Interface(
|
@@ -56,7 +66,8 @@ demo = gr.Interface(
|
|
56 |
gr.Textbox(label="Theme", placeholder="Enter the movie theme"),
|
57 |
],
|
58 |
outputs=[
|
59 |
-
gr.Textbox(label="Generated Content")
|
|
|
60 |
],
|
61 |
title=title,
|
62 |
description=description,
|
|
|
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="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")
|
13 |
|
|
|
46 |
])
|
47 |
script = script_response["choices"][0]["message"]["content"]
|
48 |
|
49 |
+
# Generate image
|
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, image = generate_movie_content(theme)
|
57 |
+
return f"Main Characters: {characters}\n\nStoryline: {storyline}\n\nScript: {script}", image
|
58 |
|
59 |
# Gradio Interface
|
60 |
+
title = "Movie Script and Image Generator"
|
61 |
description = "Generate movie scripts, characters, and thematic images based on a single theme."
|
62 |
|
63 |
demo = gr.Interface(
|
|
|
66 |
gr.Textbox(label="Theme", placeholder="Enter the movie theme"),
|
67 |
],
|
68 |
outputs=[
|
69 |
+
gr.Textbox(label="Generated Content"),
|
70 |
+
gr.Image(label="Generated Image"),
|
71 |
],
|
72 |
title=title,
|
73 |
description=description,
|