jjz5463 commited on
Commit
7f96eab
·
1 Parent(s): bf9ea64

gradio interface video combine with prompts

Browse files
Files changed (2) hide show
  1. app.py +20 -5
  2. baseline_utils.py +1 -1
app.py CHANGED
@@ -40,16 +40,19 @@ def process_images(diary_image, writer_image):
40
  writer_summary = analyze_writer_image(writer_image_path, gemini_api_key)
41
 
42
  # Generate the video based on the summaries
43
- video_paths = generate_video(activity_list, writer_summary, fps=24)
44
 
45
- return video_paths
46
 
47
 
48
  # Define the Gradio interface
49
  def gradio_interface(diary_image, writer_image):
50
  # Process the images and generate the video
51
- generated_videos = process_images(diary_image, writer_image)
52
- return generated_videos
 
 
 
53
 
54
 
55
  # Set up the Gradio interface
@@ -65,14 +68,26 @@ with gr.Blocks() as interface:
65
  with gr.Row():
66
  with gr.Column():
67
  video_output_1 = gr.Video(label="Generated Video 1")
 
 
68
  video_output_2 = gr.Video(label="Generated Video 2")
 
 
 
69
  with gr.Column():
70
  video_output_3 = gr.Video(label="Generated Video 3")
 
 
71
  video_output_4 = gr.Video(label="Generated Video 4")
 
72
 
 
73
  submit_button.click(fn=gradio_interface,
74
  inputs=[diary_image_input, writer_image_input],
75
- outputs=[video_output_1, video_output_2, video_output_3, video_output_4])
 
 
 
76
 
77
  # Launch the interface
78
  interface.launch()
 
40
  writer_summary = analyze_writer_image(writer_image_path, gemini_api_key)
41
 
42
  # Generate the video based on the summaries
43
+ video_paths, prompts = generate_video(activity_list, writer_summary, fps=24)
44
 
45
+ return video_paths, prompts
46
 
47
 
48
  # Define the Gradio interface
49
  def gradio_interface(diary_image, writer_image):
50
  # Process the images and generate the video
51
+ video_paths, prompts = process_images(diary_image, writer_image)
52
+
53
+ # Return the paths and corresponding prompts
54
+ return video_paths[0], prompts[0], video_paths[1], prompts[1], video_paths[2], prompts[2], video_paths[3], prompts[
55
+ 3]
56
 
57
 
58
  # Set up the Gradio interface
 
68
  with gr.Row():
69
  with gr.Column():
70
  video_output_1 = gr.Video(label="Generated Video 1")
71
+ prompt_output_1 = gr.Markdown(label="Prompt for Video 1")
72
+ with gr.Column():
73
  video_output_2 = gr.Video(label="Generated Video 2")
74
+ prompt_output_2 = gr.Markdown(label="Prompt for Video 2")
75
+
76
+ with gr.Row():
77
  with gr.Column():
78
  video_output_3 = gr.Video(label="Generated Video 3")
79
+ prompt_output_3 = gr.Markdown(label="Prompt for Video 3")
80
+ with gr.Column():
81
  video_output_4 = gr.Video(label="Generated Video 4")
82
+ prompt_output_4 = gr.Markdown(label="Prompt for Video 4")
83
 
84
+ # Bind the submit button click to trigger the video generation and display
85
  submit_button.click(fn=gradio_interface,
86
  inputs=[diary_image_input, writer_image_input],
87
+ outputs=[video_output_1, prompt_output_1,
88
+ video_output_2, prompt_output_2,
89
+ video_output_3, prompt_output_3,
90
+ video_output_4, prompt_output_4])
91
 
92
  # Launch the interface
93
  interface.launch()
baseline_utils.py CHANGED
@@ -112,7 +112,7 @@ def generate_video(activity_list, writer_summary, fps=24): # Lower fps
112
  video_path = export_to_video(np.squeeze(video_frames, axis=0), output_video_path=f'videos/video{i}.mp4')
113
  video_paths.append(video_path)
114
 
115
- return video_paths
116
 
117
 
118
 
 
112
  video_path = export_to_video(np.squeeze(video_frames, axis=0), output_video_path=f'videos/video{i}.mp4')
113
  video_paths.append(video_path)
114
 
115
+ return video_paths, prompts
116
 
117
 
118