Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
1littlecoder
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def generate_roast(image_path):
|
|
34 |
model = genai.GenerativeModel(
|
35 |
model_name="gemini-1.5-flash-002",
|
36 |
generation_config=generation_config,
|
37 |
-
system_instruction="You are a professional satirist and fashion expert.
|
38 |
)
|
39 |
|
40 |
chat_session = model.start_chat(
|
@@ -87,30 +87,29 @@ def generate_video(image_path, audio_path):
|
|
87 |
except Exception as e:
|
88 |
return f"Error generating video: {e}"
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
# Gradio Interface
|
91 |
with gr.Blocks(theme=theme) as demo:
|
92 |
-
gr.Markdown("# Image
|
93 |
-
gr.Markdown("Upload an image, and the AI will roast it, convert the roast to audio, and
|
94 |
-
|
95 |
with gr.Row():
|
96 |
image_input = gr.Image(type="filepath", label="Upload Image")
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
# Button to generate roast text
|
104 |
-
roast_button = gr.Button("Generate Roast Text")
|
105 |
-
roast_button.click(generate_roast, inputs=image_input, outputs=output_text)
|
106 |
-
|
107 |
-
# Button to generate audio from roast text
|
108 |
-
audio_button = gr.Button("Generate Roast Audio")
|
109 |
-
audio_button.click(text_to_speech, inputs=output_text, outputs=audio_output)
|
110 |
|
111 |
-
#
|
112 |
-
|
113 |
-
|
114 |
|
115 |
# Launch the app
|
116 |
demo.launch(debug=True)
|
|
|
34 |
model = genai.GenerativeModel(
|
35 |
model_name="gemini-1.5-flash-002",
|
36 |
generation_config=generation_config,
|
37 |
+
system_instruction="You are a professional satirist and fashion expert. Roast the provided profile picture in less than 50 words.",
|
38 |
)
|
39 |
|
40 |
chat_session = model.start_chat(
|
|
|
87 |
except Exception as e:
|
88 |
return f"Error generating video: {e}"
|
89 |
|
90 |
+
# Function to process all steps at once
|
91 |
+
def process_roast(image_path):
|
92 |
+
roast_text = generate_roast(image_path)
|
93 |
+
audio_path = text_to_speech(roast_text)
|
94 |
+
video_path = generate_video(image_path, audio_path)
|
95 |
+
return roast_text, audio_path, video_path
|
96 |
+
|
97 |
# Gradio Interface
|
98 |
with gr.Blocks(theme=theme) as demo:
|
99 |
+
gr.Markdown("# Image Roasting App with TTS and Video")
|
100 |
+
gr.Markdown("Upload an image, click 'Roast Image', and the AI will roast it, convert the roast to audio, and generate a video.")
|
101 |
+
|
102 |
with gr.Row():
|
103 |
image_input = gr.Image(type="filepath", label="Upload Image")
|
104 |
|
105 |
+
with gr.Column():
|
106 |
+
output_text = gr.Textbox(label="Roast Text")
|
107 |
+
audio_output = gr.Audio(label="Roast Audio")
|
108 |
+
video_output = gr.Video(label="Roast Video")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
# Single button to handle all actions
|
111 |
+
roast_button = gr.Button("Roast Image")
|
112 |
+
roast_button.click(process_roast, inputs=image_input, outputs=[output_text, audio_output, video_output])
|
113 |
|
114 |
# Launch the app
|
115 |
demo.launch(debug=True)
|