Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,23 +63,17 @@ def display_results(video_url, video_file, description):
|
|
63 |
elif video_file:
|
64 |
video_path = save_uploaded_file(video_file)
|
65 |
else:
|
66 |
-
return "No video provided", None
|
67 |
|
68 |
scenes = find_scenes(video_path)
|
69 |
if not scenes:
|
70 |
-
return "No scenes detected", None
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
output_dir = "output"
|
76 |
-
os.makedirs(output_dir, exist_ok=True)
|
77 |
-
final_clip_path = os.path.join(output_dir, f"{uuid.uuid4()}_final_clip.mp4")
|
78 |
-
final_clip.write_videofile(final_clip_path, codec='libx264', audio_codec='aac')
|
79 |
-
cleanup_temp_files()
|
80 |
-
return final_clip_path, final_clip_path
|
81 |
else:
|
82 |
-
return "No matching scene found", None
|
83 |
|
84 |
|
85 |
# Custom CSS for additional styling
|
@@ -140,17 +134,25 @@ def save_uploaded_file(uploaded_file):
|
|
140 |
f.write(uploaded_file)
|
141 |
return file_path
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
with gr.Blocks(theme=custom_theme, css=css) as demo:
|
144 |
with gr.Column():
|
145 |
gr.Markdown("# **Sickstadium AI**", elem_classes="centered-markdown", elem_id="sickstadium-title")
|
146 |
-
gr.Markdown("### Upload your videos. Find sick clips. Tell your truth.", elem_classes="centered-markdown")
|
147 |
-
gr.Markdown("**Welcome to Sickstadium AI. Our goal is to empower content creators with the ability to tell their stories without the friction of traditional video editing software. Skip the timeline, and don't worry about your video editing skills. Upload your video, describe the clip you want, and let our AI video editor do the work for you. Get more info about the Sickstadium project at [Strongholdlabs.io](https://strongholdlabs.io/)**", elem_classes="centered-markdown")
|
148 |
video_url = gr.Textbox(label="Video URL:", elem_id="video_url")
|
149 |
video_file = gr.File(label="Upload Video File:", elem_id="video_file", interactive=True, file_types=["video"], type="binary")
|
150 |
description = gr.Textbox(label="Describe your clip:", elem_id="description")
|
151 |
submit_button = gr.Button("Process Video", elem_id="submit_button")
|
152 |
video_output = gr.Video(label="Processed Video", elem_id="video_output")
|
153 |
-
|
154 |
-
submit_button.click(fn=display_results, inputs=[video_url, video_file, description], outputs=[video_output,
|
155 |
-
|
156 |
demo.launch()
|
|
|
63 |
elif video_file:
|
64 |
video_path = save_uploaded_file(video_file)
|
65 |
else:
|
66 |
+
return "No video provided", None, None
|
67 |
|
68 |
scenes = find_scenes(video_path)
|
69 |
if not scenes:
|
70 |
+
return "No scenes detected", None, None
|
71 |
|
72 |
+
final_clip_path, sentiments = analyze_scenes(video_path, scenes, description)
|
73 |
+
if final_clip_path:
|
74 |
+
return final_clip_path, sentiments
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
else:
|
76 |
+
return "No matching scene found", None, None
|
77 |
|
78 |
|
79 |
# Custom CSS for additional styling
|
|
|
134 |
f.write(uploaded_file)
|
135 |
return file_path
|
136 |
|
137 |
+
import matplotlib.pyplot as plt
|
138 |
+
|
139 |
+
def create_plot(sentiments):
|
140 |
+
categories = ["Joy", "Trust", "Fear", "Surprise", "Sadness", "Disgust", "Anger", "Anticipation"]
|
141 |
+
fig, ax = plt.subplots()
|
142 |
+
ax.bar(categories, sentiments)
|
143 |
+
ax.set_ylabel('Probability')
|
144 |
+
ax.set_title('Sentiment Distribution')
|
145 |
+
plt.setp(ax.get_xticklabels(), rotation=45, horizontalalignment='right')
|
146 |
+
return fig
|
147 |
+
|
148 |
with gr.Blocks(theme=custom_theme, css=css) as demo:
|
149 |
with gr.Column():
|
150 |
gr.Markdown("# **Sickstadium AI**", elem_classes="centered-markdown", elem_id="sickstadium-title")
|
|
|
|
|
151 |
video_url = gr.Textbox(label="Video URL:", elem_id="video_url")
|
152 |
video_file = gr.File(label="Upload Video File:", elem_id="video_file", interactive=True, file_types=["video"], type="binary")
|
153 |
description = gr.Textbox(label="Describe your clip:", elem_id="description")
|
154 |
submit_button = gr.Button("Process Video", elem_id="submit_button")
|
155 |
video_output = gr.Video(label="Processed Video", elem_id="video_output")
|
156 |
+
sentiment_plot = gr.Plot(label="Sentiment Analysis", elem_id="sentiment_plot")
|
157 |
+
submit_button.click(fn=display_results, inputs=[video_url, video_file, description], outputs=[video_output, sentiment_plot])
|
|
|
158 |
demo.launch()
|