Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
import requests
|
4 |
+
from PIL import Image
|
5 |
+
from io import BytesIO
|
6 |
+
import time
|
7 |
+
import numpy as np
|
8 |
+
import os
|
9 |
+
from toxic1 import toxicity_page
|
10 |
+
from strim_nlp import classic_ml_page
|
11 |
+
from lstm import lstm_model_page
|
12 |
+
from bert_strim import bert_model_page
|
13 |
+
|
14 |
+
# Определение первой страницы с общим описанием приложения
|
15 |
+
def app_description_page():
|
16 |
+
st.title("Welcome to My App!")
|
17 |
+
st.write("This is a Streamlit application where you can explore two different models.")
|
18 |
+
|
19 |
+
# Определение второй страницы с обеими моделями и выбором между ними
|
20 |
+
def model_selection_page():
|
21 |
+
st.sidebar.title("Model Selection")
|
22 |
+
selected_model = st.sidebar.radio("Select a model", ("Classic ML", "LSTM", "BERT"))
|
23 |
+
|
24 |
+
|
25 |
+
# Depending on the model selected, display different information or use different models
|
26 |
+
if selected_model == "Classic ML":
|
27 |
+
classic_ml_page()# Здесь можно добавить код для загрузки и использования первой модели
|
28 |
+
st.write("You selected Classic ML.")
|
29 |
+
elif selected_model == "LSTM":
|
30 |
+
lstm_model_page()# Здесь можно добавить код для загрузки и использования второй модели
|
31 |
+
st.write("You selected LSTM.")
|
32 |
+
elif selected_model == "BERT":
|
33 |
+
bert_model_page()
|
34 |
+
# Здесь можно добавить код для загрузки и использования третьей модели
|
35 |
+
st.write("You selected BERT.")
|
36 |
+
|
37 |
+
# Add other components for review prediction here if needed
|
38 |
+
|
39 |
+
# Определение главной функции
|
40 |
+
def main():
|
41 |
+
# st.sidebar.title("Navigation") # You can remove or comment out this line since the sidebar title is set in model_selection_page now
|
42 |
+
page = st.sidebar.radio("Go to", ("App Description", "Model Selection", "Toxicity Model"))
|
43 |
+
|
44 |
+
if page == "App Description":
|
45 |
+
app_description_page()
|
46 |
+
elif page == "Model Selection":
|
47 |
+
model_selection_page()
|
48 |
+
elif page == "Toxicity Model":
|
49 |
+
toxicity_page() # Call the function from toxic.py
|
50 |
+
|
51 |
+
|
52 |
+
# Запуск главной функции
|
53 |
+
if __name__ == "__main__":
|
54 |
+
main()
|