Spaces:
Runtime error
Runtime error
better smiles
Browse files- src/streamlit_app.py +7 -7
src/streamlit_app.py
CHANGED
|
@@ -57,11 +57,11 @@ def predict_genres(synopsis, tokenizer, model, mlb):
|
|
| 57 |
|
| 58 |
|
| 59 |
st.title("Anime Genre Classifier")
|
| 60 |
-
st.write("Введи описание аниме — модель предскажет жанры.")
|
| 61 |
|
| 62 |
synopsis = st.text_area(
|
| 63 |
label="Описание аниме (на АНГЛИЙСКОМ)",
|
| 64 |
-
placeholder="Примерчик: Determined to put his life back on track, Keyaru decided to unleash a powerful.",
|
| 65 |
height=100
|
| 66 |
)
|
| 67 |
|
|
@@ -73,13 +73,13 @@ if predict_button:
|
|
| 73 |
elif len(synopsis.strip().split()) < 5:
|
| 74 |
st.warning("Напиши хоть пару предложений")
|
| 75 |
else:
|
| 76 |
-
with st.spinner("Работаем"):
|
| 77 |
tokenizer, model, mlb = load_model()
|
| 78 |
genres = predict_genres(synopsis, tokenizer, model, mlb)
|
| 79 |
if not genres:
|
| 80 |
st.error("Ошибочка: не удалось определить жанры")
|
| 81 |
else:
|
| 82 |
-
st.subheader("Предсказанные жанры:")
|
| 83 |
for genre, prob in genres:
|
| 84 |
st.write(f"**{genre}**")
|
| 85 |
st.progress(float(prob))
|
|
@@ -89,14 +89,14 @@ st.divider()
|
|
| 89 |
st.subheader("Примеры для теста:")
|
| 90 |
|
| 91 |
|
| 92 |
-
for title, text in {"Dragon Ball": "Goku is a young boy with a monkey tail and incredible strength. He embarks on a journey to collect the seven Dragon Balls, meeting friends and fighting powerful enemies along the way.", "Spirited Away": "A young girl named Chihiro wanders into a spirit world. Her parents are turned into pigs, and she must work in a bathhouse to save them and return to the human world.", "Death Note": "A high school student finds a supernatural notebook that allows him to kill anyone whose name he writes in it. He decides to use it to rid the world of criminals."}.items():
|
| 93 |
-
if st.button(f"
|
| 94 |
st.session_state["example_text"] = text
|
| 95 |
st.rerun()
|
| 96 |
|
| 97 |
if "example_text" in st.session_state:
|
| 98 |
st.text_area(
|
| 99 |
-
"Описание (из примера):",
|
| 100 |
value=st.session_state["example_text"],
|
| 101 |
height=100
|
| 102 |
)
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
st.title("Anime Genre Classifier")
|
| 60 |
+
st.write("Введи описание аниме — модель предскажет жанры. ♪└|∵|┐♪└|∵|┘♪┌|∵|┘♪")
|
| 61 |
|
| 62 |
synopsis = st.text_area(
|
| 63 |
label="Описание аниме (на АНГЛИЙСКОМ)",
|
| 64 |
+
placeholder="(ノಠ益ಠ)ノ彡┻━┻ Примерчик: Determined to put his life back on track, Keyaru decided to unleash a powerful.",
|
| 65 |
height=100
|
| 66 |
)
|
| 67 |
|
|
|
|
| 73 |
elif len(synopsis.strip().split()) < 5:
|
| 74 |
st.warning("Напиши хоть пару предложений")
|
| 75 |
else:
|
| 76 |
+
with st.spinner("(;一_一) Работаем"):
|
| 77 |
tokenizer, model, mlb = load_model()
|
| 78 |
genres = predict_genres(synopsis, tokenizer, model, mlb)
|
| 79 |
if not genres:
|
| 80 |
st.error("Ошибочка: не удалось определить жанры")
|
| 81 |
else:
|
| 82 |
+
st.subheader("(●´ω`●) Предсказанные жанры:")
|
| 83 |
for genre, prob in genres:
|
| 84 |
st.write(f"**{genre}**")
|
| 85 |
st.progress(float(prob))
|
|
|
|
| 89 |
st.subheader("Примеры для теста:")
|
| 90 |
|
| 91 |
|
| 92 |
+
for title, text in {"ʕ•ᴥ•ʔ Dragon Ball": "Goku is a young boy with a monkey tail and incredible strength. He embarks on a journey to collect the seven Dragon Balls, meeting friends and fighting powerful enemies along the way.", "¯(ツ)_/¯ Spirited Away": "A young girl named Chihiro wanders into a spirit world. Her parents are turned into pigs, and she must work in a bathhouse to save them and return to the human world.", "ಠoಠ Death Note": "A high school student finds a supernatural notebook that allows him to kill anyone whose name he writes in it. He decides to use it to rid the world of criminals."}.items():
|
| 93 |
+
if st.button(f"{title}"):
|
| 94 |
st.session_state["example_text"] = text
|
| 95 |
st.rerun()
|
| 96 |
|
| 97 |
if "example_text" in st.session_state:
|
| 98 |
st.text_area(
|
| 99 |
+
"(╥_╥) Описание (из примера):",
|
| 100 |
value=st.session_state["example_text"],
|
| 101 |
height=100
|
| 102 |
)
|