Spaces:
Runtime error
Runtime error
deanna-emery
commited on
Commit
·
6a3746d
1
Parent(s):
b4864f2
updates
Browse files
app.py
CHANGED
@@ -55,7 +55,7 @@ def preprocess(filename, max_frames=0, resize=(224,224)):
|
|
55 |
video = np.expand_dims(video, axis=0)
|
56 |
return video
|
57 |
|
58 |
-
def translate(video_file,
|
59 |
|
60 |
video = preprocess(video_file, max_frames=0, resize=(224,224))
|
61 |
|
@@ -70,8 +70,7 @@ def translate(video_file, text=None):
|
|
70 |
)
|
71 |
|
72 |
translation = tokenizer.batch_decode(tokens, skip_special_tokens=True)
|
73 |
-
|
74 |
-
# Return dict {label:pred}
|
75 |
return {"translation":translation}
|
76 |
|
77 |
# Gradio App config
|
@@ -108,10 +107,11 @@ article = """The captions for the example videos are as follows in order: \n
|
|
108 |
|
109 |
# Gradio App interface
|
110 |
gr.Interface(fn=translate,
|
111 |
-
inputs=[gr.Video(label='Video', show_label=True, max_length=10, sources='upload'),
|
|
|
112 |
outputs="text",
|
113 |
allow_flagging="never",
|
114 |
title=title,
|
115 |
description=description,
|
116 |
examples=examples,
|
117 |
-
|
|
|
55 |
video = np.expand_dims(video, axis=0)
|
56 |
return video
|
57 |
|
58 |
+
def translate(video_file, true_caption=None):
|
59 |
|
60 |
video = preprocess(video_file, max_frames=0, resize=(224,224))
|
61 |
|
|
|
70 |
)
|
71 |
|
72 |
translation = tokenizer.batch_decode(tokens, skip_special_tokens=True)
|
73 |
+
|
|
|
74 |
return {"translation":translation}
|
75 |
|
76 |
# Gradio App config
|
|
|
107 |
|
108 |
# Gradio App interface
|
109 |
gr.Interface(fn=translate,
|
110 |
+
inputs=[gr.Video(label='Video', show_label=True, max_length=10, sources='upload'),
|
111 |
+
gr.Textbox(label='Caption (optional)', show_label=True, interactive=False, visible=False)],
|
112 |
outputs="text",
|
113 |
allow_flagging="never",
|
114 |
title=title,
|
115 |
description=description,
|
116 |
examples=examples,
|
117 |
+
).launch()
|