Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLMD Model Card add colab example with more information #264

Open
zippeurfou opened this issue Aug 10, 2023 · 5 comments
Open

MLMD Model Card add colab example with more information #264

zippeurfou opened this issue Aug 10, 2023 · 5 comments

Comments

@zippeurfou
Copy link

Expected Behavior

We should have a colab that can display the model architecture (model.summary() if using keras) as part of the model card.
In addition tensorflow data validation also output general statistics see screenshot:
Screenshot 2023-08-10 at 2 50 16 PM
Finally, It would be nice to show an example where we connect some tensorboard chart (ie. loss chart).

Actual Behavior

No example

Steps to Reproduce the Problem

This is a feature request not a bug

@zippeurfou zippeurfou changed the title MLMD Model Card example with more information MLMD Model Card add colab example with more information Aug 10, 2023
@codesue
Copy link
Contributor

codesue commented Aug 15, 2023

Hi @zippeurfou, I'm not sure I fully understand your suggestion. Is the idea to create a notebook on Colab then link to it from the model card? Or perhaps to create a notebook that's in itself a model card and contains interactive components? Or something else?

@zippeurfou
Copy link
Author

Thanks for getting back to me.
This is the latter.
The idea is to add more tensorflow components as mentioned before in the model card and create an example or tutorial explaining how to do so in a reproducible Google colab.

@zippeurfou
Copy link
Author

zippeurfou commented Aug 19, 2023

@codesue here is some sample code that can display what I mean.
Assuming keras:
Add model architecture:

from tf.keras.utils import plot_model
import io
model = get_model(...)
model_plot_fn = 'model.png'
def get_model_architecture():
    # Plot the model and save it to a file
    plot_model(model, to_file=model_plot_fn, show_shapes=True, show_layer_names=True)

    # Encode the image as base64
    with open(model_plot_fn, 'rb') as img_file:
        base64_image = base64.b64encode(img_file.read()).decode('utf-8')
    return base64_image


def get_model_param():
    buffer = io.StringIO()
    model.summary(print_fn=lambda x: buffer.write(x + '\n\n'))
    model_summary = buffer.getvalue()

    # Close the buffer to free up resources
    buffer.close()
    return model_summary

base64_image = get_model_architecture()
model_summary = get_model_param()
model_output = create_model_card()
model_output.model_parameters.data[0].graphics.collection.insert(0,mctlib.Graphic(name='Model architecture', image=base64_image)) 
model_output.model_parameters.model_architecture = model_summary
mct.update_model_card(model_output)

Of course a lot more can be done but this is just an example.

@codesue
Copy link
Contributor

codesue commented Aug 22, 2023

Hi @zippeurfou, I like the general ideas here! I think we could flesh out the design a bit more and confirm whether the tfdv and tensorboard widgets would work outside of a notebook. Would you be willing to contribute these features?

@zippeurfou
Copy link
Author

zippeurfou commented Aug 22, 2023

thanks @codesue

Would you be willing to contribute these features?

To be frank it depends, I have limited availabilities but I do feel like this would be a great addition.
One main reason is to follow metaflow model card where they create a model card by execution.
We have everything (with tfx) to allow us to compare production runs within the model card and I think this would be really helpful.
Starting with including Tensorboard information would be fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants