add youtube_dl
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from PIL import Image
|
|
5 |
import pafy
|
6 |
import gradio as gra
|
7 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
8 |
-
import
|
9 |
|
10 |
model_id = "Salesforce/blip-image-captioning-base"
|
11 |
|
@@ -49,8 +49,18 @@ def user_greeting(name):
|
|
49 |
return "Hi! " + name + " Welcome to your first Gradio application!😎"
|
50 |
|
51 |
# video_url = 'https://www.youtube.com/watch?v=orbkg5JH9C8'
|
52 |
-
#
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
app.launch()
|
55 |
|
56 |
|
|
|
5 |
import pafy
|
6 |
import gradio as gra
|
7 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
8 |
+
import youtube_dl
|
9 |
|
10 |
model_id = "Salesforce/blip-image-captioning-base"
|
11 |
|
|
|
49 |
return "Hi! " + name + " Welcome to your first Gradio application!😎"
|
50 |
|
51 |
# video_url = 'https://www.youtube.com/watch?v=orbkg5JH9C8'
|
52 |
+
# URL of the YouTube video
|
53 |
+
video_url = 'https://www.youtube.com/watch?v=VIDEO_ID'
|
54 |
+
|
55 |
+
# Download the video using youtube_dl and extract the frames using OpenCV
|
56 |
+
ydl_opts = {
|
57 |
+
'format': 'best',
|
58 |
+
'outtmpl': 'video.mp4'
|
59 |
+
}
|
60 |
+
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
61 |
+
ydl.download([video_url])
|
62 |
+
|
63 |
+
app = gra.Interface(fn=caption_youtube, inputs='text', outputs="text")
|
64 |
app.launch()
|
65 |
|
66 |
|