hbfreed commited on
Commit
f489a67
·
1 Parent(s): 377d6e7

switched show_progress to minimal

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -78,14 +78,18 @@ def generate_random_pitch():
78
 
79
 
80
  def download_pitch(video_link,ump_out=None):
 
 
81
  #download and process the video link using yt-dlp and ffmpeg
82
  if ump_out is not None:
83
  video_out = f"demo_files/downloaded_videos/{ump_out}_demo_video.mp4"
84
- os.system(f"yt-dlp -q --no-warnings --force-overwrites -f mp4 {video_link} -o '{video_out}'")
 
85
  os.system(f'ffmpeg -y -nostats -loglevel 0 -i {video_out} -vf "crop=700:700:in_w/2-350:in_h/2-350,scale=224:224" -r 15 -c:v libx264 -crf 23 -c:a aac -an -strict experimental {video_out}_cropped_video.mp4')
86
  else:
87
  video_out = f"demo_files/downloaded_videos/own_demo_video.mp4"
88
  os.system(f"yt-dlp -q --no-warnings --force-overwrites -f mp4 {video_link} -o '{video_out}'")
 
89
  os.system(f'ffmpeg -y -nostats -loglevel 0 -i {video_out} -vf "crop=700:700:in_w/2-350:in_h/2-350,scale=224:224" -r 15 -c:v libx264 -crf 23 -c:a aac -an -strict experimental {video_out}_cropped_video.mp4')
90
  return f"{video_out}_cropped_video.mp4"
91
 
@@ -97,6 +101,7 @@ with gr.Blocks(title="Picklebot") as demo:
97
  gr.Markdown(value="""
98
  To load a video, click the random button or choose from the examples.
99
  Play the video by clicking anywhere on the video, and watch Picklebot's call!
 
100
 
101
  To use your own video, click the "Use Your Own Video!" tab and follow the instructions.""")
102
  with gr.Row():
@@ -106,8 +111,8 @@ with gr.Blocks(title="Picklebot") as demo:
106
  ump_out = gr.Label(label="Umpire's Original Call")
107
  pb_out = gr.Label(label="Picklebot's Call")
108
  random_button = gr.Button("🔀 Load a Random Pitch")
109
- random_button.click(fn=generate_random_pitch,outputs=[inp])
110
- inp.play(fn=call_pitch,inputs=inp,outputs=[pb_out,ump_out])
111
  gr.ClearButton([inp,pb_out,ump_out])
112
  gr.Examples(demo_files,inputs=inp,outputs=[inp])
113
  with gr.Tab("Use Your Own Video!"):
@@ -128,9 +133,9 @@ with gr.Blocks(title="Picklebot") as demo:
128
  with gr.Column(scale=2):
129
  #make a textbox to take in the user's video link
130
  input_txt = gr.Textbox(placeholder="Paste your video link here",label="Video Link")
131
- input_txt.submit(fn=download_pitch,inputs=input_txt,outputs=vid_inp)
132
  submit_button = gr.Button("Go!")
133
- submit_button.click(fn=download_pitch,inputs=input_txt,outputs=vid_inp)
134
  pb_out = gr.Label(label="Picklebot's Call")
135
  vid_inp.play(fn=call_pitch,inputs=vid_inp,outputs=pb_out)
136
  gr.ClearButton([vid_inp,pb_out,input_txt])
 
78
 
79
 
80
  def download_pitch(video_link,ump_out=None):
81
+ # progress = gr.Progress()
82
+ # progress(1,"Downloading Video...")
83
  #download and process the video link using yt-dlp and ffmpeg
84
  if ump_out is not None:
85
  video_out = f"demo_files/downloaded_videos/{ump_out}_demo_video.mp4"
86
+ os.system(f"yt-dlp -q --no-warnings --force-overwrites --progress -f mp4 {video_link} -o '{video_out}'")
87
+ # progress(None,"Processing Video...")
88
  os.system(f'ffmpeg -y -nostats -loglevel 0 -i {video_out} -vf "crop=700:700:in_w/2-350:in_h/2-350,scale=224:224" -r 15 -c:v libx264 -crf 23 -c:a aac -an -strict experimental {video_out}_cropped_video.mp4')
89
  else:
90
  video_out = f"demo_files/downloaded_videos/own_demo_video.mp4"
91
  os.system(f"yt-dlp -q --no-warnings --force-overwrites -f mp4 {video_link} -o '{video_out}'")
92
+ # progress(None,"Processing Video...")
93
  os.system(f'ffmpeg -y -nostats -loglevel 0 -i {video_out} -vf "crop=700:700:in_w/2-350:in_h/2-350,scale=224:224" -r 15 -c:v libx264 -crf 23 -c:a aac -an -strict experimental {video_out}_cropped_video.mp4')
94
  return f"{video_out}_cropped_video.mp4"
95
 
 
101
  gr.Markdown(value="""
102
  To load a video, click the random button or choose from the examples.
103
  Play the video by clicking anywhere on the video, and watch Picklebot's call!
104
+ Picklebot's call will appear after the video is done playing.
105
 
106
  To use your own video, click the "Use Your Own Video!" tab and follow the instructions.""")
107
  with gr.Row():
 
111
  ump_out = gr.Label(label="Umpire's Original Call")
112
  pb_out = gr.Label(label="Picklebot's Call")
113
  random_button = gr.Button("🔀 Load a Random Pitch")
114
+ random_button.click(fn=generate_random_pitch,outputs=[inp],show_progress="minimal")
115
+ inp.play(fn=call_pitch,inputs=inp,outputs=[pb_out,ump_out],show_progress="minimal")
116
  gr.ClearButton([inp,pb_out,ump_out])
117
  gr.Examples(demo_files,inputs=inp,outputs=[inp])
118
  with gr.Tab("Use Your Own Video!"):
 
133
  with gr.Column(scale=2):
134
  #make a textbox to take in the user's video link
135
  input_txt = gr.Textbox(placeholder="Paste your video link here",label="Video Link")
136
+ input_txt.submit(fn=download_pitch,inputs=input_txt,outputs=vid_inp,show_progress="minimal")
137
  submit_button = gr.Button("Go!")
138
+ submit_button.click(fn=download_pitch,inputs=input_txt,outputs=vid_inp,show_progress="minimal")
139
  pb_out = gr.Label(label="Picklebot's Call")
140
  vid_inp.play(fn=call_pitch,inputs=vid_inp,outputs=pb_out)
141
  gr.ClearButton([vid_inp,pb_out,input_txt])