Spaces:
Build error
Build error
results
Browse files- .gitignore +3 -1
- app.py +7 -5
.gitignore
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
__pycache__
|
|
|
|
|
|
1 |
+
__pycache__
|
2 |
+
venv
|
3 |
+
gradio_queue*
|
app.py
CHANGED
@@ -46,11 +46,13 @@ def inference(audio):
|
|
46 |
result = model.inference(in_val)
|
47 |
pred = result['clipwise_output'][0]
|
48 |
# pred = np.exp(pred)/np.sum(np.exp(pred)) # softmax
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
# return str({win_class_name: result['clipwise_output'][0][win_class_index]})
|
|
|
54 |
|
55 |
|
56 |
title = "HTS-Audio-Transformer"
|
@@ -62,7 +64,7 @@ gr.Interface(
|
|
62 |
inference,
|
63 |
gr.inputs.Audio(type="numpy", label="Input"),
|
64 |
# gr.outputs.Textbox(),
|
65 |
-
gr.outputs.
|
66 |
title=title,
|
67 |
description=description,
|
68 |
# article=article,
|
|
|
46 |
result = model.inference(in_val)
|
47 |
pred = result['clipwise_output'][0]
|
48 |
# pred = np.exp(pred)/np.sum(np.exp(pred)) # softmax
|
49 |
+
output = {class_mapping[i]: float(p) for i, p in enumerate(pred)}
|
50 |
+
|
51 |
+
win_classes = np.argmax(result['clipwise_output'], axis=1)
|
52 |
+
win_class_index = win_classes[0]
|
53 |
+
win_class_name = class_mapping[win_class_index]
|
54 |
# return str({win_class_name: result['clipwise_output'][0][win_class_index]})
|
55 |
+
return str({win_class_name: result['clipwise_output'][0][win_class_index]}), output
|
56 |
|
57 |
|
58 |
title = "HTS-Audio-Transformer"
|
|
|
64 |
inference,
|
65 |
gr.inputs.Audio(type="numpy", label="Input"),
|
66 |
# gr.outputs.Textbox(),
|
67 |
+
[gr.outputs.Textbox(), gr.outputs.JSON()],
|
68 |
title=title,
|
69 |
description=description,
|
70 |
# article=article,
|