Spaces:
Build error
Build error
Matyáš Boháček
commited on
Commit
•
9f09b81
1
Parent(s):
81003f6
Add webcam
Browse files
app.py
CHANGED
@@ -49,7 +49,16 @@ def dictionary_to_tensor(landmarks_dict: dict) -> torch.Tensor:
|
|
49 |
return torch.from_numpy(output)
|
50 |
|
51 |
|
52 |
-
def greet(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
data = obtain_pose_data(video)
|
55 |
|
@@ -60,7 +69,6 @@ def greet(video):
|
|
60 |
depth_map[:, index, 1] = data.data_hub[identifier + "_Y"]
|
61 |
|
62 |
depth_map = torch.from_numpy(np.copy(depth_map))
|
63 |
-
print(depth_map.shape)
|
64 |
|
65 |
depth_map = tensor_to_dictionary(depth_map)
|
66 |
|
@@ -88,13 +96,14 @@ def greet(video):
|
|
88 |
results = torch.nn.functional.softmax(outputs, dim=2).detach().numpy()[0, 0]
|
89 |
|
90 |
results = {GLOSS[i]: float(results[i]) for i in range(100)}
|
91 |
-
print(outputs.shape)
|
92 |
-
print(results)
|
93 |
|
94 |
return results
|
95 |
|
96 |
|
97 |
label = gr.outputs.Label(num_top_classes=5)
|
98 |
-
demo = gr.Interface(fn=greet, inputs="
|
|
|
|
|
|
|
99 |
|
100 |
demo.launch()
|
|
|
49 |
return torch.from_numpy(output)
|
50 |
|
51 |
|
52 |
+
def greet(label, video0, video1):
|
53 |
+
|
54 |
+
if label == "Webcam":
|
55 |
+
video = video0
|
56 |
+
|
57 |
+
elif label == "Video upload":
|
58 |
+
video = video1
|
59 |
+
|
60 |
+
else:
|
61 |
+
return {}
|
62 |
|
63 |
data = obtain_pose_data(video)
|
64 |
|
|
|
69 |
depth_map[:, index, 1] = data.data_hub[identifier + "_Y"]
|
70 |
|
71 |
depth_map = torch.from_numpy(np.copy(depth_map))
|
|
|
72 |
|
73 |
depth_map = tensor_to_dictionary(depth_map)
|
74 |
|
|
|
96 |
results = torch.nn.functional.softmax(outputs, dim=2).detach().numpy()[0, 0]
|
97 |
|
98 |
results = {GLOSS[i]: float(results[i]) for i in range(100)}
|
|
|
|
|
99 |
|
100 |
return results
|
101 |
|
102 |
|
103 |
label = gr.outputs.Label(num_top_classes=5)
|
104 |
+
demo = gr.Interface(fn=greet, inputs=[gr.Dropdown(["Webcam", "Video"], label="Please select the input type:"), gr.Video(source="webcam", label="Webcam recording"), gr.Video(label="Video upload")], outputs=label,
|
105 |
+
title="SPOTER Sign language recognition",
|
106 |
+
description="Lightweight and accurate sign langage recognitoon right in your browser.",
|
107 |
+
article="This is joint work of Matyas Bohacek and Zhuo Cao. For more info, visit [our website.](www.signlanguagerecognition.com)")
|
108 |
|
109 |
demo.launch()
|