Spaces:
Runtime error
Runtime error
oliveiracwb
commited on
Commit
•
67eee42
1
Parent(s):
c3e3943
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gpt_2_simple as gpt2
|
2 |
+
from datetime import datetime
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
# -----------------------------------------------------------------------------
|
6 |
+
st.set_page_config(page_title="MPB versao 2", page_icon=":milky_way:", layout="wide")
|
7 |
+
st.subheader("Gerador Canções de musica brasileira (2)")
|
8 |
+
|
9 |
+
sess = gpt2.start_tf_sess()
|
10 |
+
|
11 |
+
gpt2.load_gpt2(sess, model_name='br_music1\\')
|
12 |
+
|
13 |
+
def gera_texto(start, temperature, max_new_tokens, num_samples):
|
14 |
+
result = gpt2.generate(sess,
|
15 |
+
model_name='br_music1\\',
|
16 |
+
prefix=start,
|
17 |
+
length=max_new_tokens,
|
18 |
+
temperature=temperature,
|
19 |
+
top_p=0.5,
|
20 |
+
nsamples=num_samples,
|
21 |
+
batch_size=5,
|
22 |
+
return_as_list=True
|
23 |
+
)
|
24 |
+
k =0
|
25 |
+
for s in result:
|
26 |
+
k=k+1
|
27 |
+
st.text_area("Gerado {}".format(k+1), value= s, height=300, placeholder="")
|
28 |
+
|
29 |
+
with st.form("my_form"):
|
30 |
+
col1, col2, col3 = st.columns(3)
|
31 |
+
with col1:
|
32 |
+
int_samples = st.slider('Exemplos', min_value=1, max_value=10, value=5, step=1)
|
33 |
+
with col2:
|
34 |
+
int_size = st.slider('Num Tokens', min_value=20, max_value=500, value=160, step=5)
|
35 |
+
with col3:
|
36 |
+
int_temp = st.number_input("Temperatura",min_value=0.1,max_value=2.0,value=1.2,step=0.1,format="%.1f")
|
37 |
+
|
38 |
+
source = st.text_area("Escolha uma frase inicial", value="Quero voce ao meu lado", placeholder="Entre com o inicio da musica...")
|
39 |
+
|
40 |
+
submitted = st.form_submit_button("Gerar músicas")
|
41 |
+
if submitted:
|
42 |
+
with st.spinner("Gerando exemplos ..."):
|
43 |
+
gera_texto(source,int_temp,int_size,int_samples)
|
44 |
+
|
45 |
+
st.write("Finetunning do GPT-2 Portugues para geracao de musicas")
|
46 |
+
st.write("A preparação dos dados estava pronta do MPB1.")
|
47 |
+
st.write("Tunning dos dados demorou a tarde do domingo no Colab")
|
48 |
+
st.write("Agradecimentos ao [Gabriel](https://www.linkedin.com/in/go2035/) pela ajuda no scrap.")
|
49 |
+
st.markdown("""---""")
|
50 |
+
original_title = '<p style="font-family:Verdana; color:Blue; font-size: 12px;">Gosta de IA ou é um maker por natureza ? Conecte-se ao meu <a href=https://www.linkedin.com/in/israeloliveira2035/> linkedin</a> e vamos conversar !</p>'
|
51 |
+
st.markdown(original_title, unsafe_allow_html=True)
|
52 |
+
st.write("Made with [simpleGPT](https://github.com/minimaxir/gpt-2-simple) e [ColabPro+](https://colab.research.google.com/signup)")
|