Spaces:
Runtime error
Runtime error
File size: 2,403 Bytes
67eee42 55db734 67eee42 55db734 67eee42 1e77e4f 67eee42 6861011 67eee42 6861011 67eee42 1e77e4f 67eee42 |
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 |
import gpt_2_simple as gpt2
from datetime import datetime
import streamlit as st
# -----------------------------------------------------------------------------
st.set_page_config(page_title="MPB versao 2", page_icon=":milky_way:", layout="wide")
st.subheader("Gerador Canções de musica brasileira (2)")
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess, model_name='br_music1/')
def gera_texto(start, temperature, max_new_tokens, num_samples):
result = gpt2.generate(sess,
model_name='br_music1/',
prefix=start,
length=max_new_tokens,
temperature=temperature,
top_p=0.5,
nsamples=num_samples,
batch_size= 2,
return_as_list=True
)
k =0
for s in result:
k=k+1
st.text_area("Gerado {}".format(k+1), value= s, height=300, placeholder="")
with st.form("my_form"):
col1, col2, col3 = st.columns(3)
with col1:
int_samples = st.slider('Exemplos', min_value=2, max_value=10, value=4, step=2)
with col2:
int_size = st.slider('Num Tokens', min_value=20, max_value=500, value=160, step=5)
with col3:
int_temp = st.number_input("Temperatura",min_value=0.8,max_value=2.0,value=1.2,step=0.1,format="%.1f")
source = st.text_area("Escolha uma frase inicial", value="Contrui uma casa para nos", placeholder="Entre com o inicio da musica...")
submitted = st.form_submit_button("Gerar músicas")
if submitted:
with st.spinner("Gerando exemplos ..."):
gera_texto(source,int_temp,int_size,int_samples)
st.write("Finetunning do GPT-2 Portugues para geracao de musicas")
st.write("A preparação dos dados estava pronta do MPB1.")
st.write("Tunning dos dados demorou a tarde do domingo no Colab")
st.write("Agradecimentos ao [Gabriel](https://www.linkedin.com/in/go2035/) pela ajuda no scrap.")
st.markdown("""---""")
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>'
st.markdown(original_title, unsafe_allow_html=True)
st.write("Made with [simpleGPT](https://github.com/minimaxir/gpt-2-simple) e [ColabPro+](https://colab.research.google.com/signup)")
|