Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,8 +33,9 @@ def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, lengt
|
|
33 |
max_length=length_of_prompt + length_of_generated,
|
34 |
eos_token_id=tokenizer.eos_token_id
|
35 |
)
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
|
40 |
medium_model, medium_tokenizer = get_model('sberbank-ai/rugpt3medium_based_on_gpt2', 'korzh-medium_best_eval_loss.bin')
|
@@ -46,24 +47,25 @@ image = Image.open('korzh.jpg')
|
|
46 |
st.image(image, caption='НейроКорж')
|
47 |
|
48 |
option = st.selectbox('Выберите своего Коржа', ('Быстрый', 'Глубокий'))
|
49 |
-
craziness = st.slider(label='Абсурдность', min_value=0
|
|
|
50 |
|
51 |
st.markdown("\n")
|
52 |
|
53 |
-
text = st.text_area(label='Напишите начало песни', value='Что делать, Макс?', height=
|
54 |
button = st.button('Старт')
|
55 |
|
56 |
if button:
|
57 |
try:
|
58 |
with st.spinner("Пушечка пишется"):
|
59 |
if option == 'Быстрый':
|
60 |
-
result = predict(text, medium_model, medium_tokenizer, temperature=
|
61 |
elif option == 'Глубокий':
|
62 |
-
result = predict(text, large_model, large_tokenizer, temperature=
|
63 |
else:
|
64 |
-
|
65 |
|
66 |
-
st.text_area(label='', value=result, height=
|
67 |
|
68 |
except Exception:
|
69 |
st.error("Ooooops, something went wrong. Please try again and report to me, tg: @vladyur")
|
|
|
33 |
max_length=length_of_prompt + length_of_generated,
|
34 |
eos_token_id=tokenizer.eos_token_id
|
35 |
)
|
36 |
+
|
37 |
+
generated = list(map(tokenizer.decode, out))[0]
|
38 |
+
return generated.replace('\n[EOS]\n', '')
|
39 |
|
40 |
|
41 |
medium_model, medium_tokenizer = get_model('sberbank-ai/rugpt3medium_based_on_gpt2', 'korzh-medium_best_eval_loss.bin')
|
|
|
47 |
st.image(image, caption='НейроКорж')
|
48 |
|
49 |
option = st.selectbox('Выберите своего Коржа', ('Быстрый', 'Глубокий'))
|
50 |
+
craziness = st.slider(label='Абсурдность', min_value=0, max_value=100, value=50, step=5)
|
51 |
+
temperature = 2 + craziness / 50.
|
52 |
|
53 |
st.markdown("\n")
|
54 |
|
55 |
+
text = st.text_area(label='Напишите начало песни', value='Что делать, Макс?', height=75)
|
56 |
button = st.button('Старт')
|
57 |
|
58 |
if button:
|
59 |
try:
|
60 |
with st.spinner("Пушечка пишется"):
|
61 |
if option == 'Быстрый':
|
62 |
+
result = predict(text, medium_model, medium_tokenizer, temperature=temperature)
|
63 |
elif option == 'Глубокий':
|
64 |
+
result = predict(text, large_model, large_tokenizer, temperature=temperature)
|
65 |
else:
|
66 |
+
st.error('Error in selectbox')
|
67 |
|
68 |
+
st.text_area(label='', value=result, height=1000)
|
69 |
|
70 |
except Exception:
|
71 |
st.error("Ooooops, something went wrong. Please try again and report to me, tg: @vladyur")
|