Spaces:
Sleeping
Sleeping
notbulubula
commited on
Commit
·
45b152e
1
Parent(s):
bb382f3
rankingowanie modeli
Browse files
app.py
CHANGED
|
@@ -41,35 +41,74 @@ option = st.sidebar.radio(
|
|
| 41 |
|
| 42 |
df = fetch_runs_to_df(api, projects, selected_project)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
df = fetch_runs_to_df(api, projects, selected_project)
|
| 43 |
|
| 44 |
+
if option == "General":
|
| 45 |
+
# Streamlit UI
|
| 46 |
+
st.title("W&B Data in Streamlit")
|
| 47 |
+
|
| 48 |
+
# Sidebar filter options
|
| 49 |
+
st.sidebar.header("Filter Options")
|
| 50 |
+
run_name_filter = st.sidebar.text_input("Filter by Run Name", "")
|
| 51 |
+
state_filter = st.sidebar.selectbox("Filter by State", ["All"] + df["State"].unique().tolist())
|
| 52 |
+
tag_filter = st.sidebar.text_input("Filter by Tags (comma separated)", "")
|
| 53 |
+
|
| 54 |
+
# Apply filters
|
| 55 |
+
if run_name_filter:
|
| 56 |
+
df = df[df["Run Name"].str.contains(run_name_filter, case=False, na=False)]
|
| 57 |
+
if state_filter != "All":
|
| 58 |
+
df = df[df["State"] == state_filter]
|
| 59 |
+
if tag_filter:
|
| 60 |
+
tag_list = [tag.strip() for tag in tag_filter.split(",")]
|
| 61 |
+
df = df[df["Tags"].apply(lambda tags: any(tag in tags for tag in tag_list))]
|
| 62 |
+
|
| 63 |
+
# Display the filtered DataFrame
|
| 64 |
+
st.dataframe(df)
|
| 65 |
+
|
| 66 |
+
# Display details of selected run
|
| 67 |
+
if not df.empty:
|
| 68 |
+
selected_run_id = st.selectbox("Select a Run ID to see details", df["ID"].tolist())
|
| 69 |
+
run = fetch_run(api, projects, selected_project, selected_run_id)
|
| 70 |
+
|
| 71 |
+
if run:
|
| 72 |
+
run_df = run.history()
|
| 73 |
+
st.write(f"Details for run: {run.name}")
|
| 74 |
+
st.dataframe(run_df)
|
| 75 |
+
else:
|
| 76 |
+
st.warning("No runs available to select.")
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
if option == "Models":
|
| 81 |
+
st.subheader("Model Ranking")
|
| 82 |
+
|
| 83 |
+
# Ensure the DataFrame is not empty
|
| 84 |
+
if not df.empty:
|
| 85 |
+
# Fetch metrics for ranking (e.g., accuracy or loss)
|
| 86 |
+
ranking_data = []
|
| 87 |
+
for index, row in df.iterrows():
|
| 88 |
+
try:
|
| 89 |
+
# Fetch the run details
|
| 90 |
+
run = api.run(f"{projects[selected_project]['entity']}/{projects[selected_project]['project']}/{row['ID']}")
|
| 91 |
+
metrics = run.summary
|
| 92 |
+
model_name = run.config.get("model_name", "Unknown") # Fetch model name from the config, defaulting to "Unknown"
|
| 93 |
+
|
| 94 |
+
ranking_data.append({
|
| 95 |
+
"Model Name": model_name, # Add model name to the table
|
| 96 |
+
"Run Name": row["Run Name"],
|
| 97 |
+
"ID": row["ID"],
|
| 98 |
+
"Accuracy": metrics.get("accuracy"), # Example metric
|
| 99 |
+
"Loss": metrics.get("loss") # Example metric
|
| 100 |
+
})
|
| 101 |
+
except wandb.errors.CommError:
|
| 102 |
+
continue
|
| 103 |
+
|
| 104 |
+
# Convert to DataFrame
|
| 105 |
+
ranking_df = pd.DataFrame(ranking_data)
|
| 106 |
+
|
| 107 |
+
# Rank by Accuracy (or another metric)
|
| 108 |
+
ranking_df = ranking_df.sort_values(by="Accuracy", ascending=False).reset_index(drop=True)
|
| 109 |
+
ranking_df.index += 1 # Start ranking from 1
|
| 110 |
+
|
| 111 |
+
# Display the ranking table
|
| 112 |
+
st.dataframe(ranking_df)
|
| 113 |
+
else:
|
| 114 |
+
st.warning("No runs available for ranking.")
|