Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
+
import random
|
| 4 |
+
import string
|
| 5 |
+
|
| 6 |
+
# Page Configuration
|
| 7 |
+
st.set_page_config(page_title="AutoTrain Advanced", page_icon="π", layout="wide")
|
| 8 |
+
|
| 9 |
+
# Title
|
| 10 |
+
st.title("AutoTrain Advanced π")
|
| 11 |
+
st.subheader("Train AI models without writing code")
|
| 12 |
+
|
| 13 |
+
# Sidebar Configuration
|
| 14 |
+
st.sidebar.header("Configuration")
|
| 15 |
+
hf_user = st.sidebar.selectbox("Hugging Face User", ["hennings1984"])
|
| 16 |
+
task = st.sidebar.selectbox(
|
| 17 |
+
"Select Task",
|
| 18 |
+
[
|
| 19 |
+
"LLM SFT", "LLM ORPO", "LLM Generic", "LLM DPO", "LLM Reward",
|
| 20 |
+
"VLM Captioning", "VLM VQA", "Text Classification", "Seq2Seq",
|
| 21 |
+
"Token Classification", "Image Classification", "Object Detection"
|
| 22 |
+
]
|
| 23 |
+
)
|
| 24 |
+
hardware = st.sidebar.selectbox("Hardware", ["Local/Space"])
|
| 25 |
+
parameter_mode = st.sidebar.radio("Parameter Mode", ["Basic", "Full"])
|
| 26 |
+
|
| 27 |
+
# Function to Generate a Random Project Name
|
| 28 |
+
def generate_project_name():
|
| 29 |
+
part1 = ''.join(random.choices(string.ascii_lowercase + string.digits, k=5))
|
| 30 |
+
part2 = ''.join(random.choices(string.ascii_lowercase + string.digits, k=5))
|
| 31 |
+
return f"autotrain-{part1}-{part2}"
|
| 32 |
+
|
| 33 |
+
# Model & Dataset Selection
|
| 34 |
+
st.write("### Model & Dataset Configuration")
|
| 35 |
+
|
| 36 |
+
col1, col2 = st.columns(2)
|
| 37 |
+
|
| 38 |
+
with col1:
|
| 39 |
+
project_name = st.text_input("Project Name", value=generate_project_name())
|
| 40 |
+
base_model = st.selectbox("Base Model", ["Fetching models..."])
|
| 41 |
+
if st.button("Fetch Models"):
|
| 42 |
+
time.sleep(2) # Simulating API request
|
| 43 |
+
models = ["GPT-3", "Llama-2", "BERT", "Custom"]
|
| 44 |
+
base_model = st.selectbox("Base Model", models)
|
| 45 |
+
if base_model == "Custom":
|
| 46 |
+
custom_model = st.text_input("Custom Model Name")
|
| 47 |
+
|
| 48 |
+
with col2:
|
| 49 |
+
dataset_source = st.selectbox("Dataset Source", ["Local", "Hugging Face Hub"])
|
| 50 |
+
if dataset_source == "Hugging Face Hub":
|
| 51 |
+
hub_dataset = st.text_input("Enter Dataset Path (Hugging Face)")
|
| 52 |
+
|
| 53 |
+
# File Upload Section
|
| 54 |
+
st.write("### Upload Dataset")
|
| 55 |
+
uploaded_train_files = st.file_uploader("Upload Training Data", accept_multiple_files=True)
|
| 56 |
+
uploaded_valid_files = st.file_uploader("Upload Validation Data (Optional)", accept_multiple_files=True)
|
| 57 |
+
|
| 58 |
+
# Accelerator Polling (Simulated)
|
| 59 |
+
st.write("### Available Accelerators")
|
| 60 |
+
if hardware == "Local/Space":
|
| 61 |
+
num_accelerators = random.randint(1, 4) # Simulating response
|
| 62 |
+
st.write(f"π§ Accelerators Available: **{num_accelerators}**")
|
| 63 |
+
else:
|
| 64 |
+
st.write("β οΈ Accelerators available only in local mode.")
|
| 65 |
+
|
| 66 |
+
# Display Selected Task & Parameters
|
| 67 |
+
st.write("### Selected Parameters")
|
| 68 |
+
st.json({
|
| 69 |
+
"User": hf_user,
|
| 70 |
+
"Task": task,
|
| 71 |
+
"Hardware": hardware,
|
| 72 |
+
"Parameter Mode": parameter_mode,
|
| 73 |
+
"Project Name": project_name,
|
| 74 |
+
"Base Model": base_model if base_model != "Custom" else custom_model,
|
| 75 |
+
"Dataset Source": dataset_source,
|
| 76 |
+
"Dataset Path": hub_dataset if dataset_source == "Hugging Face Hub" else "Local Upload"
|
| 77 |
+
})
|
| 78 |
+
|
| 79 |
+
# Training Buttons
|
| 80 |
+
st.write("### Model Training Control")
|
| 81 |
+
start_train = st.button("Start Training π", key="start_train")
|
| 82 |
+
stop_train = st.button("Stop Training β", key="stop_train")
|
| 83 |
+
|
| 84 |
+
if start_train:
|
| 85 |
+
st.success(f"Training started for {task} with {base_model} on {hardware}")
|
| 86 |
+
|
| 87 |
+
if stop_train:
|
| 88 |
+
st.warning("Training stopped.")
|
| 89 |
+
|
| 90 |
+
# Live Logs Simulation
|
| 91 |
+
st.write("### Training Logs (Live Updates)")
|
| 92 |
+
log_area = st.empty()
|
| 93 |
+
if start_train:
|
| 94 |
+
for i in range(5):
|
| 95 |
+
log_area.text(f"Training step {i+1}... β
")
|
| 96 |
+
time.sleep(1)
|
| 97 |
+
|
| 98 |
+
# Footer
|
| 99 |
+
st.markdown("---")
|
| 100 |
+
st.markdown("Made with β€οΈ by [Hugging Face](https://huggingface.co)")
|