Bruno B commited on
Commit
707d0b6
·
1 Parent(s): 977da63

new changes to run streamlit

Browse files
autotab_app final.py DELETED
@@ -1,118 +0,0 @@
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
- ###########################################################
56
- # slider for number of divisions
57
-
58
- num_div = st.slider('Select number of frets per line', 1, 10, 3)
59
- # web_tabs(tabs, num_div=4, len_div=16)
60
-
61
- ###########################################################
62
-
63
- model = tp.load_model_and_weights()
64
- model.load_weights('./h5-model/full_val0_75acc_weights.h5')
65
- genrep = TabDataReprGen()
66
-
67
- if uploaded_file is not None:
68
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
69
- y_pred = model.predict(x_new)
70
- processed_file= uploaded_file
71
-
72
- if uploaded_file is not None and mode == 'Ergonomic Simple':
73
- st.title("""
74
- Ergonomic Simple predicted Tabs:
75
- """)
76
- if uploaded_file != processed_file:
77
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
78
- # st.write(x_new.shape)
79
- y_pred = model.predict(x_new)
80
- processed_file = uploaded_file
81
-
82
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
83
- simple_tabs = tp.make_squeezed_tab(all_frames_tab)
84
- simple_text = tp.web_tabs(simple_tabs)
85
- st.text(simple_text)
86
-
87
- if uploaded_file is not None and mode == 'Ergonomic Rhythm':
88
- st.title("""
89
- Ergonomic Rhythm predicted Tabs:
90
- """)
91
- if uploaded_file != processed_file:
92
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
93
- # st.write(x_new.shape)
94
- y_pred = model.predict(x_new)
95
- processed_file = uploaded_file
96
-
97
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
98
- rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
99
- rythm_text = tp.web_tabs(rythm_tabs)
100
- st.text(rythm_text)
101
-
102
- if uploaded_file is not None and mode == 'All Frames':
103
- st.title("""
104
- All Frames predicted Tabs:
105
- """)
106
- if uploaded_file != processed_file:
107
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
108
- # st.write(x_new.shape)
109
- y_pred = model.predict(x_new)
110
- processed_file = uploaded_file
111
-
112
-
113
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
114
- ################################################
115
- # all_frames_tab.to_csv('all_frames_tab.csv')
116
- ################################################
117
- all_frames_text = tp.web_tabs(all_frames_tab)
118
- st.text(all_frames_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
streamlit/autotab_app final.py DELETED
@@ -1,118 +0,0 @@
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
- ###########################################################
56
- # slider for number of divisions
57
-
58
- num_div = st.slider('Select number of frets per line', 1, 10, 3)
59
- # web_tabs(tabs, num_div=4, len_div=16)
60
-
61
- ###########################################################
62
-
63
- model = tp.load_model_and_weights()
64
- model.load_weights('./h5-model/full_val0_75acc_weights.h5')
65
- genrep = TabDataReprGen()
66
-
67
- if uploaded_file is not None:
68
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
69
- y_pred = model.predict(x_new)
70
- processed_file= uploaded_file
71
-
72
- if uploaded_file is not None and mode == 'Ergonomic Simple':
73
- st.title("""
74
- Ergonomic Simple predicted Tabs:
75
- """)
76
- if uploaded_file != processed_file:
77
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
78
- # st.write(x_new.shape)
79
- y_pred = model.predict(x_new)
80
- processed_file = uploaded_file
81
-
82
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
83
- simple_tabs = tp.make_squeezed_tab(all_frames_tab)
84
- simple_text = tp.web_tabs(simple_tabs)
85
- st.text(simple_text)
86
-
87
- if uploaded_file is not None and mode == 'Ergonomic Rhythm':
88
- st.title("""
89
- Ergonomic Rhythm predicted Tabs:
90
- """)
91
- if uploaded_file != processed_file:
92
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
93
- # st.write(x_new.shape)
94
- y_pred = model.predict(x_new)
95
- processed_file = uploaded_file
96
-
97
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
98
- rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
99
- rythm_text = tp.web_tabs(rythm_tabs)
100
- st.text(rythm_text)
101
-
102
- if uploaded_file is not None and mode == 'All Frames':
103
- st.title("""
104
- All Frames predicted Tabs:
105
- """)
106
- if uploaded_file != processed_file:
107
- x_new = genrep.load_rep_from_raw_file(uploaded_file)
108
- # st.write(x_new.shape)
109
- y_pred = model.predict(x_new)
110
- processed_file = uploaded_file
111
-
112
-
113
- all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
114
- ################################################
115
- # all_frames_tab.to_csv('all_frames_tab.csv')
116
- ################################################
117
- all_frames_text = tp.web_tabs(all_frames_tab)
118
- st.text(all_frames_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
streamlit/autotab_app.py CHANGED
@@ -2,7 +2,7 @@ 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
 
@@ -70,42 +70,42 @@ if uploaded_file is not None:
70
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
71
  y_pred = model.predict(x_new)
72
  processed_file= uploaded_file
73
-
74
- if uploaded_file is not None and mode == 'Ergonomic Simple':
75
  st.title("""
76
- Ergonomic Simple predicted Tabs:
77
  """)
78
- if uploaded_file != processed_file:
79
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
80
  # st.write(x_new.shape)
81
  y_pred = model.predict(x_new)
82
  processed_file = uploaded_file
83
-
84
  all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
85
  simple_tabs = tp.make_squeezed_tab(all_frames_tab)
86
  simple_text = tp.web_tabs(simple_tabs)
87
  st.text(simple_text)
88
-
89
- if uploaded_file is not None and mode == 'Ergonomic Rhythm':
90
  st.title("""
91
  Ergonomic Rhythm predicted Tabs:
92
  """)
93
- if uploaded_file != processed_file:
94
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
95
  # st.write(x_new.shape)
96
  y_pred = model.predict(x_new)
97
  processed_file = uploaded_file
98
-
99
  all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
100
  rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
101
  rythm_text = tp.web_tabs(rythm_tabs)
102
  st.text(rythm_text)
103
-
104
- if uploaded_file is not None and mode == 'All Frames':
105
  st.title("""
106
  All Frames predicted Tabs:
107
  """)
108
- if uploaded_file != processed_file:
109
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
110
  # st.write(x_new.shape)
111
  y_pred = model.predict(x_new)
 
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
 
 
70
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
71
  y_pred = model.predict(x_new)
72
  processed_file= uploaded_file
73
+
74
+ if uploaded_file is not None and mode == 'Ergonomic Simple':
75
  st.title("""
76
+ Ergonomic Simple predicted Tabs:
77
  """)
78
+ if uploaded_file != processed_file:
79
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
80
  # st.write(x_new.shape)
81
  y_pred = model.predict(x_new)
82
  processed_file = uploaded_file
83
+
84
  all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
85
  simple_tabs = tp.make_squeezed_tab(all_frames_tab)
86
  simple_text = tp.web_tabs(simple_tabs)
87
  st.text(simple_text)
88
+
89
+ if uploaded_file is not None and mode == 'Ergonomic Rhythm':
90
  st.title("""
91
  Ergonomic Rhythm predicted Tabs:
92
  """)
93
+ if uploaded_file != processed_file:
94
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
95
  # st.write(x_new.shape)
96
  y_pred = model.predict(x_new)
97
  processed_file = uploaded_file
98
+
99
  all_frames_tab = tp.make_smart_tab(y_pred, len(y_pred))
100
  rythm_tabs = tp.make_dynamic_tab(all_frames_tab)
101
  rythm_text = tp.web_tabs(rythm_tabs)
102
  st.text(rythm_text)
103
+
104
+ if uploaded_file is not None and mode == 'All Frames':
105
  st.title("""
106
  All Frames predicted Tabs:
107
  """)
108
+ if uploaded_file != processed_file:
109
  x_new = genrep.load_rep_from_raw_file(uploaded_file)
110
  # st.write(x_new.shape)
111
  y_pred = model.predict(x_new)
streamlit/autotab_app_hoz.py CHANGED
@@ -5,6 +5,15 @@ 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",
 
5
  import numpy as np
6
  from autotab.TabDataReprGen import TabDataReprGen
7
  from PIL import Image
8
+ import sys
9
+
10
+
11
+ # Insert the parent directory into sys.path
12
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
13
+
14
+ # Now you can import from autotab
15
+ import autotab.TabPrediction as tp
16
+
17
 
18
  st.set_page_config(
19
  page_title="AutoTab tab generator",