Spaces:
Running
Running
Ruslan Zitser commited on
Commit ·
86fbc72
1
Parent(s): 5575bfa
streamlit_final app
Browse files- streamlit/autotab_app final.py +110 -0
- streamlit/autotab_app.py +30 -11
streamlit/autotab_app final.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import autotab.TabPrediction as tp
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import numpy as np
|
| 6 |
+
from autotab.TabDataReprGen import TabDataReprGen
|
| 7 |
+
from PIL import Image
|
| 8 |
+
|
| 9 |
+
st.set_page_config(
|
| 10 |
+
page_title="AutoTab tab generator",
|
| 11 |
+
layout="centered", # centered
|
| 12 |
+
initial_sidebar_state="auto") # collapsed
|
| 13 |
+
|
| 14 |
+
image_path = "https://images.unsplash.com/photo-1535587566541-97121a128dc5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80"
|
| 15 |
+
st.write(f'<div class="banner" style="background-image: linear-gradient(rgba(0,0,0,0.4),rgba(0,0,0,0.4)), url({image_path});"><h1>Autotab</h1><p>Learning the guitar the easy way</p></div>', unsafe_allow_html=True)
|
| 16 |
+
CSS = """
|
| 17 |
+
.banner {
|
| 18 |
+
background-position: center;
|
| 19 |
+
background-repeat: no-repeat;
|
| 20 |
+
background-size: cover;
|
| 21 |
+
position: relative;
|
| 22 |
+
height: 300px;
|
| 23 |
+
text-align: center;
|
| 24 |
+
margin-top: -100px;
|
| 25 |
+
margin-left: -480px;
|
| 26 |
+
margin-right: -480px;
|
| 27 |
+
}
|
| 28 |
+
.banner h1 {
|
| 29 |
+
padding-top: 120px;
|
| 30 |
+
margin: 0;
|
| 31 |
+
color: white;
|
| 32 |
+
text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
|
| 33 |
+
font-size: 56px;
|
| 34 |
+
font-weight: bold;
|
| 35 |
+
}
|
| 36 |
+
.banner p {
|
| 37 |
+
font-size: 32px;
|
| 38 |
+
color: white;
|
| 39 |
+
opacity: .7;
|
| 40 |
+
text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
|
| 41 |
+
}
|
| 42 |
+
"""
|
| 43 |
+
st.write(f'<style>{CSS}</style>', unsafe_allow_html=True)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
st.set_option('deprecation.showfileUploaderEncoding', False)
|
| 47 |
+
|
| 48 |
+
uploaded_file = st.file_uploader("choose a music file:", type="wav")
|
| 49 |
+
|
| 50 |
+
processed_file = None
|
| 51 |
+
|
| 52 |
+
mode = st.radio('Choose Mode of Tab production:', ('Ergonomic Simple', 'Ergonomic Rhythm', 'All Frames'))
|
| 53 |
+
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
|
| 54 |
+
|
| 55 |
+
model = tp.load_model_and_weights()
|
| 56 |
+
model.load_weights('./h5-model/full_val0_75acc_weights.h5')
|
| 57 |
+
genrep = TabDataReprGen()
|
| 58 |
+
|
| 59 |
+
if uploaded_file is not None:
|
| 60 |
+
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
| 61 |
+
y_pred = model.predict(x_new)
|
| 62 |
+
processed_file= uploaded_file
|
| 63 |
+
|
| 64 |
+
if uploaded_file is not None and mode == 'Ergonomic Simple':
|
| 65 |
+
st.title("""
|
| 66 |
+
Ergonomic Simple predicted Tabs:
|
| 67 |
+
""")
|
| 68 |
+
if uploaded_file != processed_file:
|
| 69 |
+
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
| 70 |
+
# st.write(x_new.shape)
|
| 71 |
+
y_pred = model.predict(x_new)
|
| 72 |
+
processed_file = uploaded_file
|
| 73 |
+
|
| 74 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 75 |
+
simple_tabs = tp.make_squeezed_tab(all_frames_tab)
|
| 76 |
+
simple_text = tp.web_tabs(simple_tabs)
|
| 77 |
+
st.text(simple_text)
|
| 78 |
+
|
| 79 |
+
if uploaded_file is not None and mode == 'Ergonomic Rhythm':
|
| 80 |
+
st.title("""
|
| 81 |
+
Ergonomic Rhythm predicted Tabs:
|
| 82 |
+
""")
|
| 83 |
+
if uploaded_file != processed_file:
|
| 84 |
+
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
| 85 |
+
# st.write(x_new.shape)
|
| 86 |
+
y_pred = model.predict(x_new)
|
| 87 |
+
processed_file = uploaded_file
|
| 88 |
+
|
| 89 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 90 |
+
rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
|
| 91 |
+
rythm_text = tp.web_tabs(rythm_tabs)
|
| 92 |
+
st.text(rythm_text)
|
| 93 |
+
|
| 94 |
+
if uploaded_file is not None and mode == 'All Frames':
|
| 95 |
+
st.title("""
|
| 96 |
+
All Frames predicted Tabs:
|
| 97 |
+
""")
|
| 98 |
+
if uploaded_file != processed_file:
|
| 99 |
+
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
| 100 |
+
# st.write(x_new.shape)
|
| 101 |
+
y_pred = model.predict(x_new)
|
| 102 |
+
processed_file = uploaded_file
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 106 |
+
################################################
|
| 107 |
+
# all_frames_tab.to_csv('all_frames_tab.csv')
|
| 108 |
+
################################################
|
| 109 |
+
all_frames_text = tp.web_tabs(all_frames_tab)
|
| 110 |
+
st.text(all_frames_text)
|
streamlit/autotab_app.py
CHANGED
|
@@ -49,7 +49,7 @@ uploaded_file = st.file_uploader("choose a music file:", type="wav")
|
|
| 49 |
|
| 50 |
processed_file = None
|
| 51 |
|
| 52 |
-
mode = st.radio('Choose Mode of Tab production:', ('
|
| 53 |
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
|
| 54 |
|
| 55 |
model = tp.load_model_and_weights()
|
|
@@ -61,9 +61,9 @@ if uploaded_file is not None:
|
|
| 61 |
y_pred = model.predict(x_new)
|
| 62 |
processed_file= uploaded_file
|
| 63 |
|
| 64 |
-
if uploaded_file is not None and mode == '
|
| 65 |
st.title("""
|
| 66 |
-
|
| 67 |
""")
|
| 68 |
if uploaded_file != processed_file:
|
| 69 |
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
|
@@ -71,13 +71,29 @@ if uploaded_file is not None and mode == 'squeezed notes':
|
|
| 71 |
y_pred = model.predict(x_new)
|
| 72 |
processed_file = uploaded_file
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
-
if uploaded_file is not None and mode == '
|
| 79 |
st.title("""
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
""")
|
| 82 |
if uploaded_file != processed_file:
|
| 83 |
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
|
@@ -85,7 +101,10 @@ if uploaded_file is not None and mode == 'changed notes':
|
|
| 85 |
y_pred = model.predict(x_new)
|
| 86 |
processed_file = uploaded_file
|
| 87 |
|
| 88 |
-
expanded_tab = tp.make_full_tab(y_pred, len(y_pred))
|
| 89 |
-
display_tab = tp.make_dynamic_tab(expanded_tab)
|
| 90 |
-
st.text(tp.web_tabs(display_tab))
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
processed_file = None
|
| 51 |
|
| 52 |
+
mode = st.radio('Choose Mode of Tab production:', ('Ergonomic Simple', 'Ergonomic Rhythm', 'All Frames'))
|
| 53 |
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
|
| 54 |
|
| 55 |
model = tp.load_model_and_weights()
|
|
|
|
| 61 |
y_pred = model.predict(x_new)
|
| 62 |
processed_file= uploaded_file
|
| 63 |
|
| 64 |
+
if uploaded_file is not None and mode == 'Ergonomic Simple':
|
| 65 |
st.title("""
|
| 66 |
+
Ergonomic Simple predicted Tabs:
|
| 67 |
""")
|
| 68 |
if uploaded_file != processed_file:
|
| 69 |
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
|
|
|
| 71 |
y_pred = model.predict(x_new)
|
| 72 |
processed_file = uploaded_file
|
| 73 |
|
| 74 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 75 |
+
simple_tabs = tp.make_squeezed_tab(all_frames_tab)
|
| 76 |
+
simple_text = tp.web_tabs(simple_tabs)
|
| 77 |
+
st.text(simple_text)
|
| 78 |
|
| 79 |
+
if uploaded_file is not None and mode == 'Ergonomic Rhythm':
|
| 80 |
st.title("""
|
| 81 |
+
Ergonomic Rhythm predicted Tabs:
|
| 82 |
+
""")
|
| 83 |
+
if uploaded_file != processed_file:
|
| 84 |
+
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
| 85 |
+
# st.write(x_new.shape)
|
| 86 |
+
y_pred = model.predict(x_new)
|
| 87 |
+
processed_file = uploaded_file
|
| 88 |
+
|
| 89 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 90 |
+
rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
|
| 91 |
+
rythm_text = tp.web_tabs(rythm_tabs)
|
| 92 |
+
st.text(rythm_text)
|
| 93 |
+
|
| 94 |
+
if uploaded_file is not None and mode == 'All Frames':
|
| 95 |
+
st.title("""
|
| 96 |
+
All Frames predicted Tabs:
|
| 97 |
""")
|
| 98 |
if uploaded_file != processed_file:
|
| 99 |
x_new = genrep.load_rep_from_raw_file(uploaded_file)
|
|
|
|
| 101 |
y_pred = model.predict(x_new)
|
| 102 |
processed_file = uploaded_file
|
| 103 |
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
+
all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
|
| 106 |
+
################################################
|
| 107 |
+
# all_frames_tab.to_csv('all_frames_tab.csv')
|
| 108 |
+
################################################
|
| 109 |
+
all_frames_text = tp.web_tabs(all_frames_tab)
|
| 110 |
+
st.text(all_frames_text)
|