eaglelandsonce
commited on
Commit
•
1783a8c
1
Parent(s):
1e472cd
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
import requests
|
4 |
from pytube import YouTube
|
5 |
import os
|
|
|
6 |
|
7 |
# Streamlit interface setup
|
8 |
st.title('Video Summary Interface')
|
@@ -35,6 +36,10 @@ with tab2:
|
|
35 |
|
36 |
st.title('Video Upload and Processing Interface')
|
37 |
|
|
|
|
|
|
|
|
|
38 |
# Container for video input
|
39 |
with st.container():
|
40 |
st.header("Video Input")
|
@@ -56,16 +61,20 @@ with tab2:
|
|
56 |
st.warning("Please upload a video file or enter a YouTube URL.")
|
57 |
st.stop()
|
58 |
|
59 |
-
# Assume 'client' and 'index_id' are set correctly
|
60 |
print(f"Uploading {video_path}")
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
with tab3:
|
71 |
st.header("Video Indexer")
|
|
|
3 |
import requests
|
4 |
from pytube import YouTube
|
5 |
import os
|
6 |
+
from twelvelabs.models.task import Task
|
7 |
|
8 |
# Streamlit interface setup
|
9 |
st.title('Video Summary Interface')
|
|
|
36 |
|
37 |
st.title('Video Upload and Processing Interface')
|
38 |
|
39 |
+
# Setup your Twelve Labs client
|
40 |
+
# Assuming 'client' is set up here (use your actual client initialization)
|
41 |
+
# client = TwelveLabsClient(api_key="your_api_key")
|
42 |
+
|
43 |
# Container for video input
|
44 |
with st.container():
|
45 |
st.header("Video Input")
|
|
|
61 |
st.warning("Please upload a video file or enter a YouTube URL.")
|
62 |
st.stop()
|
63 |
|
|
|
64 |
print(f"Uploading {video_path}")
|
65 |
+
task = client.task.create(index_id="<YOUR_INDEX_ID>", file=video_path, language="en")
|
66 |
+
st.success(f"Task id={task.id}")
|
67 |
+
|
68 |
+
# Optional: Monitor the video indexing process
|
69 |
+
def on_task_update(task: Task):
|
70 |
+
st.write(f"Status={task.status}")
|
71 |
+
|
72 |
+
task.wait_for_done(callback=on_task_update)
|
73 |
+
|
74 |
+
if task.status != "ready":
|
75 |
+
st.error(f"Indexing failed with status {task.status}")
|
76 |
+
else:
|
77 |
+
st.success(f"Uploaded {video_path}. The unique identifier of your video is {task.video_id}.")
|
78 |
|
79 |
with tab3:
|
80 |
st.header("Video Indexer")
|