KingNish commited on
Commit
b1d6fce
1 Parent(s): 492f003

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -44,7 +44,7 @@ def fn(vid, fps, color):
44
  pil_image = Image.fromarray(frame)
45
  processed_image = process(pil_image, color)
46
  processed_frames.append(np.array(processed_image))
47
- yield processed_image, gr.update(visible=False)
48
 
49
  # Create a new video from the processed frames
50
  processed_video = mp.ImageSequenceClip(processed_frames, fps=fps)
@@ -58,9 +58,10 @@ def fn(vid, fps, color):
58
  unique_filename = str(uuid.uuid4()) + ".mp4"
59
  temp_filepath = os.path.join(temp_dir, unique_filename)
60
  processed_video.write_videofile(temp_filepath, codec="libx264")
61
-
 
62
  # Return the path to the temporary file
63
- yield gr.update(visible=False), temp_filepath
64
 
65
 
66
  def process(image, color_hex):
@@ -97,7 +98,7 @@ def process_file(f, color="#00FF00"):
97
  with gr.Blocks() as demo:
98
  with gr.Row():
99
  in_video = gr.Video(label="Input Video")
100
- stream_image = gr.Image(label="Streaming Output")
101
  out_video = gr.Video(label="Final Output Video")
102
  submit_button = gr.Button("Change Background")
103
  with gr.Row():
 
44
  pil_image = Image.fromarray(frame)
45
  processed_image = process(pil_image, color)
46
  processed_frames.append(np.array(processed_image))
47
+ yield processed_image, None
48
 
49
  # Create a new video from the processed frames
50
  processed_video = mp.ImageSequenceClip(processed_frames, fps=fps)
 
58
  unique_filename = str(uuid.uuid4()) + ".mp4"
59
  temp_filepath = os.path.join(temp_dir, unique_filename)
60
  processed_video.write_videofile(temp_filepath, codec="libx264")
61
+
62
+ yield gr.update(visible=False), gr.update(visible=True)
63
  # Return the path to the temporary file
64
+ yield None, temp_filepath
65
 
66
 
67
  def process(image, color_hex):
 
98
  with gr.Blocks() as demo:
99
  with gr.Row():
100
  in_video = gr.Video(label="Input Video")
101
+ stream_image = gr.Image(label="Streaming Output", visible=False)
102
  out_video = gr.Video(label="Final Output Video")
103
  submit_button = gr.Button("Change Background")
104
  with gr.Row():