new2 / app /app.py
LDJA's picture
53
fb9116f
raw
history blame
3.01 kB
# -*- coding: utf-8 -*-
import streamlit as st
import subprocess
def run_command(command):
try:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
return result.stdout, result.stderr
except Exception as e:
return None, str(e)
def prepare_data():
"""
st.text("Préparation des données en cours...")
subprocess.run_command(["python3", "../data/shakespeare_char/prepare.py"])
st.text("Préparation des données terminée.")
"""
st.text("Préparation des données en cours...")
st.title("Sortie de la commande Python")
# Commande Python à exécuter
command = "python3 ../data/shakespeare_char/prepare.py"
# Sorties de la commmande
stdout, stderr = run_command(command)
# Affichage de la sortie
st.subheader("Sortie standard (stdout) :")
st.code(stdout)
st.subheader("Sortie d'erreur (stderr) :")
st.code(stderr)
st.text("Préparation des données terminée.")
def train_model():
"""
st.text("Entraînement du modèle en cours...")
subprocess.run_command(["python3", "../train.py", "../config/train_shakespeare_char.py", "--device=cpu", "--compile=False", "--eval_iters=20", "--log_interval=1", "--block_size=64", "--batch_size=12", "--n_layer=4", "--n_head=4", "--n_embd=128", "--max_iters=2000", "--lr_decay_iters=2000", "--dropout=0.0"])
st.text("Entraînement du modèle terminé.")
"""
st.text("Entraînement du modèle en cours...")
st.title("Sortie de la commande Python")
# Commande Python à exécuter
command = ""python3 ../train.py ../config/train_shakespeare_char.py", "--device=cpu", "--compile=False", "--eval_iters=20", "--log_interval=1", "--block_size=64", "--batch_size=12", "--n_layer=4", "--n_head=4", "--n_embd=128", "--max_iters=2000", "--lr_decay_iters=2000", "--dropout=0.0""
# Sorties de la commande
stdout, stderr = run_command(command)
# Affichez la sortie
st.subheader("Sortie standard (stdout) :")
st.code(stdout)
st.subheader("Sortie d'erreur (stderr) :")
st.code(stderr)
st.text("Entraînement du modèle terminé.")
def generate_samples():
st.text("Génération d'échantillons en cours...")
st.title("Sortie de la commande Python")
# Commande Python à exécuter
command = "python3 sample.py --out_dir=out-shakespeare-char"
# Sorties de la commande
stdout, stderr = run_command(command)
# Affichez la sortie
st.subheader("Sortie standard (stdout) :")
st.code(stdout)
st.subheader("Sortie d'erreur (stderr) :")
st.code(stderr)
st.text("Génération d'échantillons terminée.")
def main():
st.title("Application de Commandes")
if st.button("Préparer les données"):
prepare_data()
if st.button("Entraîner le modèle"):
train_model()
if st.button("Générer des échantillons"):
generate_samples()
if __name__ == "__main__":
main()