|
import os |
|
import wandb |
|
import streamlit as st |
|
import streamlit.components.v1 as components |
|
|
|
from utils import train |
|
|
|
project = "st" |
|
entity = "capecape" |
|
|
|
HEIGHT = 720 |
|
|
|
def get_project(api, name, entity=None): |
|
return api.project(name, entity=entity).to_html(height=HEIGHT) |
|
|
|
st.title("Let's log some metrics to wandb π") |
|
|
|
|
|
sb = st.sidebar |
|
sb.title("Train your model") |
|
|
|
|
|
|
|
|
|
wandb.login(anonymous="must") |
|
api = wandb.Api() |
|
|
|
|
|
components.html(get_project(api, project, entity), height=HEIGHT) |
|
|
|
|
|
runs = sb.number_input('Number of runs:', min_value=1, max_value=10, value=1) |
|
epochs = sb.number_input('Number of epochs:', min_value=1, max_value=1000, value=100) |
|
|
|
|
|
|
|
pseudo_code = """ |
|
We will execute a simple training loop |
|
```python |
|
wandb.init(project="st", ...) |
|
for i in range(epochs): |
|
acc = 1 - 2 ** -i - random() |
|
loss = 2 ** -i + random() |
|
wandb.log({"acc": acc, |
|
"loss": loss}) |
|
``` |
|
""" |
|
|
|
sb.write(pseudo_code) |
|
|
|
|
|
if sb.button("Run Example"): |
|
|
|
print("Running training") |
|
for i in range(runs): |
|
my_bar = sb.progress(0) |
|
train(project=project, entity=entity, epochs=epochs, bar=my_bar) |