S-Dreamer commited on
Commit
f528fb2
ยท
verified ยท
1 Parent(s): 204f12a

Upload 14 files

Browse files
Files changed (1) hide show
  1. app.py +45 -71
app.py CHANGED
@@ -1,97 +1,71 @@
1
-
2
  import streamlit as st
 
 
3
 
4
- from utils import set_page_config
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
 
27
- # Sidebar navigation using session state
28
- def navigate(page):
29
- st.session_state["current_page"] = page
30
 
 
 
31
 
32
- # Initialize session state variables using a loop
33
- session_defaults = {
34
- "datasets": {}, # Stores uploaded datasets
35
- "trained_models": {}, # Stores trained model details
36
- "training_logs": [], # Stores training logs
37
- "training_progress": {}, # Tracks active training jobs
38
- "current_page": "home", # Default landing page
39
- }
40
 
41
- for key, value in session_defaults.items():
42
- if key not in st.session_state:
43
- st.session_state[key] = value
44
 
45
- # Display sidebar with navigation buttons
46
- with st.sidebar:
47
- st.header("Navigation")
48
- if st.button("๐Ÿ—๏ธ Dataset Management"):
49
- navigate("dataset_management")
50
- if st.button("๐ŸŽฏ Model Training"):
51
- navigate("model_training")
52
- if st.button("๐Ÿ”ฎ Code Generation"):
53
- navigate("code_generation")
54
 
55
- # Render content dynamically based on session state
56
- if st.session_state["current_page"] == "dataset_management":
57
- st.subheader("Dataset Management")
58
- st.write("Upload and manage your datasets here.")
59
- elif st.session_state["current_page"] == "model_training":
60
- st.subheader("Model Training")
61
- st.write("Configure and train your models.")
62
- elif st.session_state["current_page"] == "code_generation":
63
- st.subheader("Code Generation")
64
- st.write("Generate predictions using your trained models.")
65
- else:
66
- st.subheader("Getting Started")
67
- col1, col2 = st.columns(2)
68
 
69
- with col1:
70
- st.info("""
71
- 1. ๐Ÿ“Š Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
72
- 2. ๐Ÿ› ๏ธ Configure and train your model in the **Model Training** section.
73
- """)
74
 
75
- with col2:
76
- st.info("""
77
- 3. ๐Ÿ’ก Generate code predictions using your trained models in the **Code Generation** section.
78
- 4. ๐Ÿ”„ Access your models on Hugging Face Hub for broader use.
79
- """)
 
 
 
 
 
 
80
 
81
- # Display platform statistics dynamically
82
  st.subheader("Platform Statistics")
83
  col1, col2, col3 = st.columns(3)
84
 
85
  with col1:
86
- st.metric("๐Ÿ“‚ Datasets Available", len(st.session_state.get("datasets",
87
- {})))
88
-
89
  with col2:
90
- st.metric("๐Ÿ“ฆ Trained Models",
91
- len(st.session_state.get("trained_models", {})))
92
-
93
  with col3:
94
- active_jobs = sum(
95
- 1 for progress in st.session_state["training_progress"].values()
96
- if progress.get("status") == "running")
97
- st.metric("๐Ÿš€ Active Training Jobs", active_jobs)
 
 
1
  import streamlit as st
2
+ from utils import set_page_config, display_sidebar
3
+ import os
4
 
5
+ # Set page configuration
 
 
6
  set_page_config()
7
 
8
+ # Title and description
9
  st.title("CodeGen Hub")
 
 
10
  st.markdown("""
11
  Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
12
+
13
  ### Core Features:
14
+ - Upload and preprocess Python code datasets for model training
15
+ - Configure and train models with customizable parameters
16
+ - Generate code predictions using trained models through an interactive interface
17
+ - Monitor training progress with visualizations and detailed logs
18
+ - Seamless integration with Hugging Face Hub for model management
19
+
20
  Navigate through the different sections using the sidebar menu.
21
  """)
22
 
23
+ # Display sidebar
24
+ display_sidebar()
25
 
26
+ # Create the session state for storing information across app pages
27
+ if 'datasets' not in st.session_state:
28
+ st.session_state.datasets = {}
29
 
30
+ if 'trained_models' not in st.session_state:
31
+ st.session_state.trained_models = {}
32
 
33
+ if 'training_logs' not in st.session_state:
34
+ st.session_state.training_logs = []
 
 
 
 
 
 
35
 
36
+ if 'training_progress' not in st.session_state:
37
+ st.session_state.training_progress = {}
 
38
 
 
 
 
 
 
 
 
 
 
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ # Display getting started card
42
+ st.subheader("Getting Started")
43
+ col1, col2 = st.columns(2)
 
 
44
 
45
+ with col1:
46
+ st.info("""
47
+ 1. ๐Ÿ“Š Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
48
+ 2. ๐Ÿ› ๏ธ Configure and train your model in the **Model Training** section.
49
+ """)
50
+
51
+ with col2:
52
+ st.info("""
53
+ 3. ๐Ÿ’ก Generate code predictions using your trained models in the **Code Generation** section.
54
+ 4. ๐Ÿ”„ Access your models on Hugging Face Hub for broader use.
55
+ """)
56
 
57
+ # Display platform statistics if available
58
  st.subheader("Platform Statistics")
59
  col1, col2, col3 = st.columns(3)
60
 
61
  with col1:
62
+ st.metric("Datasets Available", len(st.session_state.datasets))
63
+
 
64
  with col2:
65
+ st.metric("Trained Models", len(st.session_state.trained_models))
66
+
 
67
  with col3:
68
+ # Calculate active training jobs
69
+ active_jobs = sum(1 for progress in st.session_state.training_progress.values()
70
+ if progress.get('status') == 'running')
71
+ st.metric("Active Training Jobs", active_jobs)