-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample.py
69 lines (51 loc) · 1.93 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import streamlit as st
import os
from flerken.utils import BaseDict
import glob
import numpy as np
from VnBSS.utils.metrics import get_metrics as _gm
@st.cache()
def get_metrics(path):
return _gm(path) # wrapper around this function to use st.cache
def return_files(path):
files = sorted([x for x in os.listdir(path)])
return files, len(files)
def get_audio_files(path):
files = sorted([os.path.join(path, x) for x in os.listdir(path) if x.endswith(('.mp3', '.wav'))])
yield from files
def get_video_files(path):
files = sorted([os.path.join(path, x) for x in os.listdir(path) if x.endswith('.mp4')])
yield from files
def get_images_files(path):
files = sorted([os.path.join(path, x) for x in os.listdir(path) if x.endswith('.png')])
yield from files
def get_metadata(path):
files = sorted([os.path.join(path, x) for x in os.listdir(path) if x.endswith('.json')])
for p in files:
yield BaseDict().load(p), p
json_files = {}
st.title('Training and eval visualization')
root = st.text_input('Folder to visualization default_path')
# if os.default_path.exists(root) and root != '':
# json_files = get_metrics(root)
# json_files
# Get all the elements (independent samples) predicted
path_list, slicer_nmax = return_files(root)
# Choose one with the slider
idx = st.sidebar.slider('Select a file', 0, slicer_nmax)
filename = path_list[idx]
st.sidebar.text(filename)
# Get all the info about that element
path = os.path.join(root, filename)
for f, p in get_metadata(path):
st.text(f'File {p}')
st.json(f)
for audio_path in get_audio_files(path):
st.text(f'File: {audio_path}')
st.audio(audio_path)
for video_path in get_video_files(path):
st.text(f'File: {video_path}')
st.video(video_path)
for image_path in get_images_files(path):
st.text(f'File: {image_path}')
st.image(image_path, format='PNG')