updating the thumbnail gallery
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import os
|
|
5 |
import getpass
|
6 |
from pixeltable.functions.video import extract_audio
|
7 |
from pixeltable.functions import openai as pxop
|
|
|
8 |
import openai
|
9 |
|
10 |
|
@@ -164,7 +165,15 @@ def process_and_generate_post(video_file, social_media_type):
|
|
164 |
if sm_gen_flag:
|
165 |
cur_video_df.update({"sm_post": social_media_post})
|
166 |
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
except Exception as e:
|
170 |
return f"An error occurred: {e}"
|
@@ -203,6 +212,8 @@ def gradio_interface():
|
|
203 |
|
204 |
output = gr.Textbox(label="Generated Social Media Post", show_copy_button=True)
|
205 |
|
|
|
|
|
206 |
examples = gr.Examples(
|
207 |
[["example1.mp4"], ["example2.mp4"],["example3.mp4"]], inputs=[video_input]
|
208 |
)
|
@@ -211,7 +222,7 @@ def gradio_interface():
|
|
211 |
generate_btn.click(
|
212 |
fn=process_and_generate_post,
|
213 |
inputs=[video_input, social_media_type],
|
214 |
-
outputs=[output],
|
215 |
)
|
216 |
|
217 |
return demo
|
|
|
5 |
import getpass
|
6 |
from pixeltable.functions.video import extract_audio
|
7 |
from pixeltable.functions import openai as pxop
|
8 |
+
from pixeltable.iterators import FrameIterator
|
9 |
import openai
|
10 |
|
11 |
|
|
|
165 |
if sm_gen_flag:
|
166 |
cur_video_df.update({"sm_post": social_media_post})
|
167 |
|
168 |
+
|
169 |
+
print("######## processing thumbnail ##########")
|
170 |
+
|
171 |
+
images = []
|
172 |
+
for frame in FrameIterator(video=video_file, num_frames=10):
|
173 |
+
images.append(frame['frame']) # frame['frame'] is a PIL image
|
174 |
+
|
175 |
+
|
176 |
+
return cur_video_df["sm_post"], images
|
177 |
|
178 |
except Exception as e:
|
179 |
return f"An error occurred: {e}"
|
|
|
212 |
|
213 |
output = gr.Textbox(label="Generated Social Media Post", show_copy_button=True)
|
214 |
|
215 |
+
thumbnail = gr.Gallery(label = "Pick your favorite Post Thumbnail", show_download_button= True, show_fullscreen_button= True)
|
216 |
+
|
217 |
examples = gr.Examples(
|
218 |
[["example1.mp4"], ["example2.mp4"],["example3.mp4"]], inputs=[video_input]
|
219 |
)
|
|
|
222 |
generate_btn.click(
|
223 |
fn=process_and_generate_post,
|
224 |
inputs=[video_input, social_media_type],
|
225 |
+
outputs=[output, thumbnail],
|
226 |
)
|
227 |
|
228 |
return demo
|