- This event has passed.
7 PM – AI/ML – Darin
January 26 @ 7:00 pm - 8:00 pm
Today’s Activities:
- Learnt a bit about tensors, pre-trained models, model sizes
- Exported our trained AI model to a .pkl file for use outside of kaggle
- Ran a quick streamlit app to visualize model working on the browser
Homework:
- Run training again like we did in class, but this time using 3 different AI backbones (replacing the ‘resnet34’ under the vision_learner function call) like last week.
References for model types:
https://docs.pytorch.org/vision/stable/models.html#initializing-pre-trained-models
https://docs.fast.ai/vision.learner.html#vision_learner - SAVE these models as .pkl files and put them in your pycharm project directory.
- Finally modify the pycharm file to be able to select between different models you have trained for evaluation.
You can add this section beneath the “created by” code to replace the load_learner for multi model selection functionality.
MODELS_DIR = Path("models") # Find all .pkl files in models/ model_paths = sorted(MODELS_DIR.glob("*.pkl")) model_names = [p.name for p in model_paths] if not model_paths: st.error(f"No .pkl models found in: {MODELS_DIR.resolve()}") st.stop() # UI: choose which model to use selected_name = st.selectbox("Select a model to use:", model_names) @st.cache_resource # cache the loaded learner per selected model def get_model(model_path_str: str): return load_learner(model_path_str) model_path = str(MODELS_DIR / selected_name) cat_vs_dog_model = get_model(model_path) st.caption(f"Loaded model: {selected_name}") - RUN your app with “streamlit run <python file path>” such as “streamlit run src/Jan26_CatVSDog_Evaluation.py”
Upload the file Jan26_CatVSDog_Evaluation.py to the google drive when you are done.
Notes:
You can reach me at ddjapri@ayclogic.com.
All class notes can be found here.