Spaces:
Runtime error
Runtime error
Commit
·
3005acd
1
Parent(s):
ef95c58
updates
Browse files
app.py
CHANGED
@@ -2,9 +2,6 @@ import cv2
|
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
|
5 |
-
# import os
|
6 |
-
# os.chdir('modeling')
|
7 |
-
|
8 |
import tensorflow as tf, tf_keras
|
9 |
import tensorflow_hub as hub
|
10 |
from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
|
@@ -18,7 +15,7 @@ movinet_model = tf_keras.models.load_model(movinet_path)
|
|
18 |
movinet_model.trainable = False
|
19 |
|
20 |
tokenizer = AutoTokenizer.from_pretrained("t5-base")
|
21 |
-
t5_model = TFAutoModelForSeq2SeqLM.from_pretrained("deanna-emery/
|
22 |
t5_model.trainable = False
|
23 |
|
24 |
def crop_center_square(frame):
|
@@ -71,24 +68,34 @@ def translate(video_file):
|
|
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
|
78 |
title = "ASL Translation (MoViNet + T5)"
|
79 |
examples = [
|
80 |
-
[
|
81 |
-
[
|
82 |
-
['videos/
|
83 |
-
['videos/
|
84 |
['videos/no.mp4', 'no'],
|
85 |
-
['videos/
|
86 |
]
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# Gradio App interface
|
89 |
gr.Interface(fn=translate,
|
90 |
-
inputs="
|
91 |
outputs="text",
|
92 |
allow_flagging="never",
|
93 |
title=title,
|
94 |
-
|
|
|
|
|
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
|
|
5 |
import tensorflow as tf, tf_keras
|
6 |
import tensorflow_hub as hub
|
7 |
from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
|
|
|
15 |
movinet_model.trainable = False
|
16 |
|
17 |
tokenizer = AutoTokenizer.from_pretrained("t5-base")
|
18 |
+
t5_model = TFAutoModelForSeq2SeqLM.from_pretrained("deanna-emery/ASL_t5_movinet_sentence")
|
19 |
t5_model.trainable = False
|
20 |
|
21 |
def crop_center_square(frame):
|
|
|
68 |
|
69 |
translation = tokenizer.batch_decode(tokens, skip_special_tokens=True)
|
70 |
|
|
|
71 |
return {"translation":translation}
|
72 |
|
73 |
# Gradio App config
|
74 |
title = "ASL Translation (MoViNet + T5)"
|
75 |
examples = [
|
76 |
+
["videos/My second ASL professor's name was Will White.mp4", "My second ASL professor's name was Will White"],
|
77 |
+
["videos/Rainbows rainbows high up in the sky.mp4", "Rainbows rainbows high up in the sky"],
|
78 |
+
['videos/You are my sunshine.mp4', 'You are my sunshine'],
|
79 |
+
['videos/scrub your hands for at least 20 seconds.mp4', 'scrub your hands for at least 20 seconds'],
|
80 |
['videos/no.mp4', 'no'],
|
81 |
+
['videos/before.mp4', 'before']
|
82 |
]
|
83 |
|
84 |
+
description = "Gradio demo of word-level sign language classification using I3D model pretrained on the WLASL video dataset. " \
|
85 |
+
"WLASL is a large-scale dataset containing more than 2000 words in American Sign Language. " \
|
86 |
+
"Examples used in the demo are videos from the the test subset. " \
|
87 |
+
"Note that WLASL100 contains 100 words while WLASL2000 contains 2000."
|
88 |
+
|
89 |
+
|
90 |
+
article = "More information about the trained models can be found <a href=https://github.com/deanna-emery/ASL-Translator/>here</a>."
|
91 |
+
|
92 |
+
|
93 |
# Gradio App interface
|
94 |
gr.Interface(fn=translate,
|
95 |
+
inputs=[gr.Video(label="Video (*.mp4)"),gr.Radio(label='Caption')],
|
96 |
outputs="text",
|
97 |
allow_flagging="never",
|
98 |
title=title,
|
99 |
+
description=description,
|
100 |
+
examples=examples,
|
101 |
+
article=article).launch()
|