Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions panels/ModelCheckpointComparison/ModelCheckpointComparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,7 @@

st.set_page_config(layout="wide")

api_key = st.sidebar.text_input(
"Comet API key:",
value=os.environ.get("COMET_REAL_API_KEY", ""),
type="password"
)
if not api_key:
st.info("Enter your Comet API key on left sidebar", icon="ℹ️")
st.stop()

os.environ["COMET_REAL_API_KEY"] = api_key

api = API(api_key)
api = API()
experiments = api.get_panel_experiments()

if len(experiments) > 1:
Expand Down Expand Up @@ -104,35 +93,6 @@ def filter_keys(data, keys):

st.dataframe(df, use_container_width=True)

# Model registration form
st.header("Create Model Artifact")

# Select a model to register
model_names = df['Model-Name'].unique().tolist()
selected_model = st.selectbox("Select a model:", model_names)

# Model name input
workspace = api.get_panel_workspace()
artifacts = api.get_artifact_list(workspace)["artifacts"]
artifact_names = [artifact["name"] for artifact in artifacts]
artifact_name = st.selectbox("Select an Artifact:", artifact_names, help = "A new version will be created within this artifact")
def create_artifact():
try:
api_experiment.download_model(selected_model, f"./{selected_model}")
# Filter and get the "Asset-Name" where "Model-Name" is "checkpoint_0"
asset_name = df.loc[df["Model-Name"] == selected_model, "Asset-Name"].values[0]
path = f'./{selected_model}/{asset_name}'
artifact = Artifact(name=artifact_name, metadata = {"model_checkpoint":path, f"{step_or_epoch}": df.loc[df["Model-Name"] == selected_model, f"metadata.{step_or_epoch}"].values[0]})
artifact.add(path)
#exp = ExistingExperiment(api_key = api_key, experiment_key=api_experiment.key)
exp = start(api_key = api_key, mode="get", experiment_key=api_experiment.key)
exp.log_artifact(artifact)
st.success("Artifact Created Successfully!")
exp.end()
except Exception as e:
ui.display_text(f"Error registering model: {str(e)}")

st.button("Create Model Artifact", on_click=create_artifact)

else:
ui.display('No models logged to this experiment')
15 changes: 14 additions & 1 deletion panels/ModelCheckpointComparison/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ Or, you can simply [copy the code](https://raw.githubusercontent.com/comet-ml/co

#### How it works

The Python panel will retrieve a list of your model checkpoints, then use the epoch values logged to the checkpoint metadata to fine the value of the specific metric at that epoch.
The Python panel will retrieve a list of your model checkpoints, then use the epoch values logged to the checkpoint metadata to find the value of the specific metric at that epoch.

Once you have decided on which checkpoint you want to move forward with, you can then click the 'Register Model' button in the top right corner of the experiment page to promote that checkpoint to the Comet Model Registry.

<table>
<tr>
<td>
<img src="https://raw.githubusercontent.com/comet-ml/comet-examples/refs/heads/master/panels/ModelCheckpointComparison/register-model-button.png"
style="max-width: 300px; max-height: 300px;">
</img>
</td>
</tr>
</table>


See [here](https://www.comet.com/docs/v2/guides/model-registry/using-model-registry/#register-a-model-from-comet-ui) for further documentation on promoting models to the model registry.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading