13
Browse files- app/app.py +19 -18
app/app.py
CHANGED
|
@@ -12,11 +12,6 @@ def train_model():
|
|
| 12 |
subprocess.run(["python", "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"])
|
| 13 |
st.text("Entraînement du modèle terminé.")
|
| 14 |
|
| 15 |
-
def generate_samples():
|
| 16 |
-
st.text("Génération d'échantillons en cours...")
|
| 17 |
-
subprocess.run(["python", "sample.py", "--out_dir=out-shakespeare-char", "--device=cpu"])
|
| 18 |
-
st.text("Génération d'échantillons terminée.")
|
| 19 |
-
|
| 20 |
def run_command(command):
|
| 21 |
try:
|
| 22 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
|
|
@@ -24,22 +19,13 @@ def run_command(command):
|
|
| 24 |
except Exception as e:
|
| 25 |
return None, str(e)
|
| 26 |
|
| 27 |
-
def
|
| 28 |
-
st.
|
| 29 |
-
|
| 30 |
-
if st.button("Préparer les données"):
|
| 31 |
-
prepare_data()
|
| 32 |
-
|
| 33 |
-
if st.button("Entraîner le modèle"):
|
| 34 |
-
train_model()
|
| 35 |
-
|
| 36 |
-
if st.button("Générer des échantillons"):
|
| 37 |
-
generate_samples()
|
| 38 |
-
|
| 39 |
st.title("Sortie de la commande Python dans Streamlit")
|
| 40 |
|
| 41 |
# Commande Python que vous souhaitez exécuter
|
| 42 |
-
command = "python sample.py --out_dir=out-shakespeare-char"
|
| 43 |
|
| 44 |
# Exécutez la commande et obtenez la sortie
|
| 45 |
stdout, stderr = run_command(command)
|
|
@@ -51,6 +37,21 @@ def main():
|
|
| 51 |
st.subheader("Sortie d'erreur (stderr) :")
|
| 52 |
st.code(stderr)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
main()
|
|
|
|
| 12 |
subprocess.run(["python", "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"])
|
| 13 |
st.text("Entraînement du modèle terminé.")
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def run_command(command):
|
| 16 |
try:
|
| 17 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
|
|
|
|
| 19 |
except Exception as e:
|
| 20 |
return None, str(e)
|
| 21 |
|
| 22 |
+
def generate_samples():
|
| 23 |
+
st.text("Génération d'échantillons en cours...")
|
| 24 |
+
#subprocess.run(["python", "sample.py", "--out_dir=out-shakespeare-char", "--device=cpu"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
st.title("Sortie de la commande Python dans Streamlit")
|
| 26 |
|
| 27 |
# Commande Python que vous souhaitez exécuter
|
| 28 |
+
command = "python sample.py --out_dir=out-shakespeare-char"
|
| 29 |
|
| 30 |
# Exécutez la commande et obtenez la sortie
|
| 31 |
stdout, stderr = run_command(command)
|
|
|
|
| 37 |
st.subheader("Sortie d'erreur (stderr) :")
|
| 38 |
st.code(stderr)
|
| 39 |
|
| 40 |
+
st.text("Génération d'échantillons terminée.")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def main():
|
| 44 |
+
st.title("Application de Commandes")
|
| 45 |
+
|
| 46 |
+
if st.button("Préparer les données"):
|
| 47 |
+
prepare_data()
|
| 48 |
+
|
| 49 |
+
if st.button("Entraîner le modèle"):
|
| 50 |
+
train_model()
|
| 51 |
+
|
| 52 |
+
if st.button("Générer des échantillons"):
|
| 53 |
+
generate_samples()
|
| 54 |
+
|
| 55 |
|
| 56 |
if __name__ == "__main__":
|
| 57 |
main()
|