Spaces:
Running
Running
Commit
·
473f7b5
1
Parent(s):
3f23678
Save update + README
Browse files- .gitignore +5 -1
- README.md +0 -0
- Resources/captions.jsonl +15 -5
- Resources/captions_backup.jsonl +0 -5
- Resources/db_upload.py +0 -16
- Resources/users.json +0 -3
- Resources/videos.json +0 -4
- app.py +1 -1
- caption_editor_functions.py +19 -16
.gitignore
CHANGED
|
@@ -82,8 +82,12 @@ http-client.private.env.json
|
|
| 82 |
.idea/.cache/.Apifox_Helper
|
| 83 |
.idea/ApifoxUploaderProjectSetting.xml
|
| 84 |
|
| 85 |
-
#
|
| 86 |
Resources/key.json
|
| 87 |
Resources/salt.py
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
venv
|
| 89 |
**/__pycache__
|
|
|
|
| 82 |
.idea/.cache/.Apifox_Helper
|
| 83 |
.idea/ApifoxUploaderProjectSetting.xml
|
| 84 |
|
| 85 |
+
# Manually added
|
| 86 |
Resources/key.json
|
| 87 |
Resources/salt.py
|
| 88 |
+
Resources/upload.py
|
| 89 |
+
Resources/users.json
|
| 90 |
+
Resources/videos.json
|
| 91 |
+
Resources/captions_backup.jsonl
|
| 92 |
venv
|
| 93 |
**/__pycache__
|
README.md
CHANGED
|
Binary files a/README.md and b/README.md differ
|
|
|
Resources/captions.jsonl
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
-
{"clean_text":"
|
| 2 |
-
{"clean_text":"
|
| 3 |
-
{"clean_text":"
|
| 4 |
-
{"clean_text":"
|
| 5 |
-
{"clean_text":"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"clean_text":"one","start_time":1.5,"user_id":"a","signer":40,"file":"Y4stD_ypaAI","end_time":1.6,"url":"www.youtube.com\/watch?v=Y4stD_ypaAI","text":"one"}
|
| 2 |
+
{"clean_text":"measure","start_time":0.0,"user_id":"admin","signer":20,"file":"tkMg8g8vVUo","end_time":1.435,"url":"www.youtube.com\/watch?v=tkMg8g8vVUo","text":"measure"}
|
| 3 |
+
{"clean_text":"apple","start_time":1.7,"user_id":"admin","signer":20,"file":"tkMg8g8vVUo","end_time":2.0,"url":"www.youtube.com\/watch?v=tkMg8g8vVUo","text":"apple"}
|
| 4 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 5 |
+
{"clean_text":"test","start_time":1.5,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.6,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test 2"}
|
| 6 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 7 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 8 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 9 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 10 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 11 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 12 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 13 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 14 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 15 |
+
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
Resources/captions_backup.jsonl
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
{"clean_text": "measure", "start_time": 0.0, "user_id": 11, "signer": 39, "file": "Aj9SDSAOXf4", "end_time": 1.435, "url": "www.youtube.com/watch?v=Aj9SDSAOXf4", "text": "measure"}
|
| 2 |
-
{"clean_text": "apple", "start_time": 1.5, "user_id": 11, "signer": 39, "file": "Aj9SDSAOXf4", "end_time": 1.6, "url": "www.youtube.com/watch?v=Aj9SDSAOXf4", "text": "apple"}
|
| 3 |
-
{"clean_text": "test", "start_time": 0.0, "user_id": 11, "signer": 39, "file": "c2ORbHSQ5pw", "end_time": 1.435, "url": "www.youtube.com/watch?v=c2ORbHSQ5pw", "text": "test"}
|
| 4 |
-
{"clean_text": "aaaaaaaaaa", "start_time": 1.5, "user_id": 11, "signer": 39, "file": "c2ORbHSQ5pw", "end_time": 1.6, "url": "www.youtube.com/watch?v=c2ORbHSQ5pw", "text": "aaaaaaaaaa"}
|
| 5 |
-
{"clean_text": "bbbbbbbb", "start_time": 1.5, "user_id": 11, "signer": 39, "file": "c2ORbHSQ5pw", "end_time": 1.6, "url": "www.youtube.com/watch?v=c2ORbHSQ5pw", "text": "bbbbbbbb"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resources/db_upload.py
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
import firebase_admin
|
| 2 |
-
from firebase_admin import db
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
cred_obj = firebase_admin.credentials.Certificate('key.json')
|
| 6 |
-
default_app = firebase_admin.initialize_app(cred_obj, {
|
| 7 |
-
'databaseURL': "https://video-link-db-default-rtdb.europe-west1.firebasedatabase.app/"
|
| 8 |
-
})
|
| 9 |
-
# videos_ref = db.reference("/Videos")
|
| 10 |
-
# with open("videos.json", "r") as f:
|
| 11 |
-
# file_contents = json.load(f)
|
| 12 |
-
# videos_ref.set(file_contents)
|
| 13 |
-
users_ref = db.reference("/Users")
|
| 14 |
-
with open("users.json", "r") as f:
|
| 15 |
-
file_contents = json.load(f)
|
| 16 |
-
users_ref.set(file_contents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resources/users.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"sample_user": "f8f81086d3347f78c14e822641b1475da6f6921d5cb032acd400468aaca20f4d"
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
Resources/videos.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"1": "www.youtube.com/watch?v=c2ORbHSQ5pw",
|
| 3 |
-
"2": "www.youtube.com/watch?v=Aj9SDSAOXf4"
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -58,7 +58,7 @@ with gr.Blocks(css=css) as app:
|
|
| 58 |
datatype=["number", "str", "number"],
|
| 59 |
row_count=(start_captions.shape[0], "fixed"),
|
| 60 |
col_count=(3, "fixed"), column_widths=["20%", "60%", "20%"])
|
| 61 |
-
save_button = gr.Button("Save")
|
| 62 |
save_result = gr.Markdown()
|
| 63 |
with gr.Column():
|
| 64 |
video_embed = gr.HTML(value=start_video)
|
|
|
|
| 58 |
datatype=["number", "str", "number"],
|
| 59 |
row_count=(start_captions.shape[0], "fixed"),
|
| 60 |
col_count=(3, "fixed"), column_widths=["20%", "60%", "20%"])
|
| 61 |
+
save_button = gr.Button(value="Save")
|
| 62 |
save_result = gr.Markdown()
|
| 63 |
with gr.Column():
|
| 64 |
video_embed = gr.HTML(value=start_video)
|
caption_editor_functions.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
-
import
|
| 3 |
|
| 4 |
|
| 5 |
def get_captions_by_video_id(video_id):
|
|
@@ -13,22 +13,25 @@ def get_captions_by_video_id(video_id):
|
|
| 13 |
|
| 14 |
|
| 15 |
def save_dataframe(df, video_id, user):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
try:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
other_captions = captions[captions['file'] != video_id].copy()
|
| 21 |
-
new_captions = captions[captions['file'] == video_id].copy()
|
| 22 |
-
|
| 23 |
-
new_captions['start_time'] = np.where(df['Start'].isnull(),
|
| 24 |
-
new_captions['start_time'],
|
| 25 |
-
df['Start'].apply(lambda x: float(x)))
|
| 26 |
-
new_captions['text'] = np.where(df['Text'].isnull(),
|
| 27 |
-
new_captions['text'],
|
| 28 |
-
df['Text'])
|
| 29 |
-
new_captions['end_time'] = np.where(df['End'].isnull(),
|
| 30 |
-
new_captions['end_time'],
|
| 31 |
-
df['End'].apply(lambda x: float(x)))
|
| 32 |
new_captions['user_id'] = user
|
| 33 |
|
| 34 |
all_captions = pd.concat([other_captions, new_captions], ignore_index=True)
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import json
|
| 3 |
|
| 4 |
|
| 5 |
def get_captions_by_video_id(video_id):
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def save_dataframe(df, video_id, user):
|
| 16 |
+
cols = ["clean_text", "start_time", "user_id", "signer", "file", "end_time", "url", "text"]
|
| 17 |
+
other_captions_data = []
|
| 18 |
+
new_captions_data = []
|
| 19 |
+
file_name = "Resources/captions.jsonl"
|
| 20 |
+
|
| 21 |
+
with open(file_name) as f:
|
| 22 |
+
for line in f:
|
| 23 |
+
caption = json.loads(line)
|
| 24 |
+
if caption['file'] == video_id:
|
| 25 |
+
new_captions_data.append(caption)
|
| 26 |
+
else:
|
| 27 |
+
other_captions_data.append(caption)
|
| 28 |
+
|
| 29 |
+
other_captions = pd.DataFrame(data=other_captions_data, columns=cols)
|
| 30 |
+
new_captions = pd.DataFrame(data=new_captions_data, columns=cols)
|
| 31 |
try:
|
| 32 |
+
new_captions['start_time'] = df['Start'].apply(lambda x: float(x))
|
| 33 |
+
new_captions['text'] = df['Text']
|
| 34 |
+
new_captions['end_time'] = df['End'].apply(lambda x: float(x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
new_captions['user_id'] = user
|
| 36 |
|
| 37 |
all_captions = pd.concat([other_captions, new_captions], ignore_index=True)
|