Spaces:
Sleeping
Sleeping
File size: 1,526 Bytes
2ad7d0e 76d9193 2ad7d0e 76d9193 118680e 76d9193 118680e 2ad7d0e 76d9193 2ad7d0e 76d9193 2ad7d0e 118680e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import gradio as gr
from evo_transformer import EvoTransformer
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
def simulate_evolution(generations):
model = EvoTransformer()
model.evolve(generations)
history = model.get_history()
# Evaluation of final model
final_result = model.evaluate()
# Visualization
fig, ax = plt.subplots(figsize=(10, 5))
df = pd.DataFrame(history)
sns.lineplot(data=df.drop("memory", axis=1), markers=True, ax=ax)
ax.set_title("EvoTransformer Trait Evolution")
ax.set_ylabel("Value")
ax.set_xlabel("Generation")
plt.xticks(range(len(df)))
plt.tight_layout()
return (
final_result["accuracy"],
round(final_result["params"], 2),
fig
)
# UI
with gr.Blocks(title="EvoTransformer: Adaptive Architecture Evolution") as demo:
gr.Markdown("# 🧬 EvoTransformer Demo")
gr.Markdown("Evolving architecture live — inspired by nature. Tune the number of generations below and visualize how traits change during evolution.")
generations = gr.Slider(1, 20, value=5, step=1, label="Number of Generations")
btn = gr.Button("Evolve EvoTransformer")
accuracy = gr.Textbox(label="Estimated Accuracy", interactive=False)
params = gr.Textbox(label="Estimated Parameter Count (M)", interactive=False)
plot = gr.Plot(label="Architecture Trait Evolution")
btn.click(fn=simulate_evolution, inputs=generations, outputs=[accuracy, params, plot])
demo.launch()
|