Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,91 +1,92 @@
|
|
1 |
|
2 |
import streamlit as st
|
3 |
-
# Import the `set_page_config` and `display_sidebar` functions from the `utils` module.
|
4 |
-
# These functions are responsible for setting up the Streamlit app's page configuration and displaying the sidebar, respectively.
|
5 |
from utils import set_page_config, display_sidebar
|
6 |
import os
|
7 |
|
8 |
-
# Set the page configuration
|
9 |
-
# This function sets the app's title, icon, layout, and other parameters.
|
10 |
set_page_config()
|
11 |
|
12 |
-
# Display
|
13 |
st.title("CodeGen Hub")
|
14 |
|
15 |
-
#
|
16 |
-
# This provides a more formatted and readable way to present the app's purpose and features.
|
17 |
st.markdown("""
|
18 |
Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
|
19 |
|
20 |
### Core Features:
|
21 |
-
- Upload and preprocess Python code datasets for model training
|
22 |
-
- Configure and train models with customizable parameters
|
23 |
-
- Generate code predictions using trained models through an interactive interface
|
24 |
-
- Monitor training progress with visualizations and detailed logs
|
25 |
-
- Seamless integration with Hugging Face Hub for model management
|
26 |
|
27 |
Navigate through the different sections using the sidebar menu.
|
28 |
""")
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
#
|
35 |
-
|
36 |
-
|
37 |
-
#
|
38 |
-
#
|
39 |
-
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
st.session_state.trained_models = {}
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
st.
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
with
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
""")
|
66 |
-
|
67 |
-
with col2:
|
68 |
-
# Display the second set of instructions in the right column.
|
69 |
-
st.info("""
|
70 |
-
3. ๐ก Generate code predictions using your trained models in the **Code Generation** section.
|
71 |
-
4. ๐ Access your models on Hugging Face Hub for broader use.
|
72 |
-
""")
|
73 |
|
74 |
-
# Display platform statistics
|
75 |
st.subheader("Platform Statistics")
|
76 |
col1, col2, col3 = st.columns(3)
|
77 |
|
78 |
with col1:
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
with col2:
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
with col3:
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
# Display the number of active training jobs.
|
91 |
-
st.metric("Active Training Jobs", active_jobs)
|
|
|
1 |
|
2 |
import streamlit as st
|
|
|
|
|
3 |
from utils import set_page_config, display_sidebar
|
4 |
import os
|
5 |
|
6 |
+
# Set the Streamlit page configuration
|
|
|
7 |
set_page_config()
|
8 |
|
9 |
+
# Display main app title
|
10 |
st.title("CodeGen Hub")
|
11 |
|
12 |
+
# App description with markdown formatting
|
|
|
13 |
st.markdown("""
|
14 |
Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
|
15 |
|
16 |
### Core Features:
|
17 |
+
- ๐ Upload and preprocess Python code datasets for model training
|
18 |
+
- ๐๏ธ Configure and train models with customizable parameters
|
19 |
+
- ๐ค Generate code predictions using trained models through an interactive interface
|
20 |
+
- ๐ Monitor training progress with visualizations and detailed logs
|
21 |
+
- ๐ Seamless integration with Hugging Face Hub for model management
|
22 |
|
23 |
Navigate through the different sections using the sidebar menu.
|
24 |
""")
|
25 |
|
26 |
+
# Sidebar navigation using session state
|
27 |
+
def navigate(page):
|
28 |
+
st.session_state["current_page"] = page
|
29 |
|
30 |
+
# Initialize session state variables using a loop
|
31 |
+
session_defaults = {
|
32 |
+
"datasets": {}, # Stores uploaded datasets
|
33 |
+
"trained_models": {}, # Stores trained model details
|
34 |
+
"training_logs": [], # Stores training logs
|
35 |
+
"training_progress": {}, # Tracks active training jobs
|
36 |
+
"current_page": "home" # Default landing page
|
37 |
+
}
|
38 |
|
39 |
+
for key, value in session_defaults.items():
|
40 |
+
if key not in st.session_state:
|
41 |
+
st.session_state[key] = value
|
|
|
42 |
|
43 |
+
# Display sidebar with navigation buttons
|
44 |
+
with st.sidebar:
|
45 |
+
st.header("Navigation")
|
46 |
+
if st.button("๐๏ธ Dataset Management"):
|
47 |
+
navigate("dataset_management")
|
48 |
+
if st.button("๐ฏ Model Training"):
|
49 |
+
navigate("model_training")
|
50 |
+
if st.button("๐ฎ Code Generation"):
|
51 |
+
navigate("code_generation")
|
52 |
|
53 |
+
# Render content dynamically based on session state
|
54 |
+
if st.session_state["current_page"] == "dataset_management":
|
55 |
+
st.subheader("Dataset Management")
|
56 |
+
st.write("Upload and manage your datasets here.")
|
57 |
+
elif st.session_state["current_page"] == "model_training":
|
58 |
+
st.subheader("Model Training")
|
59 |
+
st.write("Configure and train your models.")
|
60 |
+
elif st.session_state["current_page"] == "code_generation":
|
61 |
+
st.subheader("Code Generation")
|
62 |
+
st.write("Generate predictions using your trained models.")
|
63 |
+
else:
|
64 |
+
st.subheader("Getting Started")
|
65 |
+
col1, col2 = st.columns(2)
|
66 |
|
67 |
+
with col1:
|
68 |
+
st.info("""
|
69 |
+
1. ๐ Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
|
70 |
+
2. ๐ ๏ธ Configure and train your model in the **Model Training** section.
|
71 |
+
""")
|
72 |
|
73 |
+
with col2:
|
74 |
+
st.info("""
|
75 |
+
3. ๐ก Generate code predictions using your trained models in the **Code Generation** section.
|
76 |
+
4. ๐ Access your models on Hugging Face Hub for broader use.
|
77 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
# Display platform statistics dynamically
|
80 |
st.subheader("Platform Statistics")
|
81 |
col1, col2, col3 = st.columns(3)
|
82 |
|
83 |
with col1:
|
84 |
+
st.metric("๐ Datasets Available", len(st.session_state.get("datasets", {})))
|
85 |
+
|
|
|
86 |
with col2:
|
87 |
+
st.metric("๐ฆ Trained Models", len(st.session_state.get("trained_models", {})))
|
88 |
+
|
|
|
89 |
with col3:
|
90 |
+
active_jobs = sum(1 for progress in st.session_state["training_progress"].values()
|
91 |
+
if progress.get("status") == "running")
|
92 |
+
st.metric("๐ Active Training Jobs", active_jobs)
|
|
|
|