
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
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}")Upload the file Jan26_CatVSDog_Evaluation.py to the google drive when you are done.
You can reach me at ddjapri@ayclogic.com.
All class notes can be found here.