Spaces:
Sleeping
Sleeping
Show time for inference
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import allin1
|
|
|
4 |
|
5 |
from pathlib import Path
|
6 |
|
@@ -44,6 +45,9 @@ CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
|
|
44 |
|
45 |
|
46 |
def analyze(path):
|
|
|
|
|
|
|
47 |
path = Path(path)
|
48 |
result = allin1.analyze(
|
49 |
path,
|
@@ -65,7 +69,11 @@ def analyze(path):
|
|
65 |
)
|
66 |
sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
|
70 |
|
71 |
with gr.Blocks() as demo:
|
@@ -89,6 +97,7 @@ with gr.Blocks() as demo:
|
|
89 |
show_download_button=False,
|
90 |
scale=9,
|
91 |
)
|
|
|
92 |
|
93 |
#gr.Examples(
|
94 |
# examples=[
|
@@ -104,7 +113,7 @@ with gr.Blocks() as demo:
|
|
104 |
button.click(
|
105 |
fn=analyze,
|
106 |
inputs=input_audio_path,
|
107 |
-
outputs=[output_bpm, output_viz, output_sonif],
|
108 |
api_name='analyze',
|
109 |
)
|
110 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import allin1
|
4 |
+
import time
|
5 |
|
6 |
from pathlib import Path
|
7 |
|
|
|
45 |
|
46 |
|
47 |
def analyze(path):
|
48 |
+
#Measure time for inference
|
49 |
+
start = time.time()
|
50 |
+
|
51 |
path = Path(path)
|
52 |
result = allin1.analyze(
|
53 |
path,
|
|
|
69 |
)
|
70 |
sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
|
71 |
|
72 |
+
#Measure time for inference
|
73 |
+
end = time.time()
|
74 |
+
elapsed_time = end-start
|
75 |
+
|
76 |
+
return result.bpm, fig, sonif_path, elapsed_time
|
77 |
|
78 |
|
79 |
with gr.Blocks() as demo:
|
|
|
97 |
show_download_button=False,
|
98 |
scale=9,
|
99 |
)
|
100 |
+
elapsed_time = gr.Textbox(label='Overall inference time', scale=1)
|
101 |
|
102 |
#gr.Examples(
|
103 |
# examples=[
|
|
|
113 |
button.click(
|
114 |
fn=analyze,
|
115 |
inputs=input_audio_path,
|
116 |
+
outputs=[output_bpm, output_viz, output_sonif, elapsed_time],
|
117 |
api_name='analyze',
|
118 |
)
|
119 |
|