{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Install" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pip install uv" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!uv pip install dagshub setuptools accelerate toml torch torchvision transformers mlflow datasets ipywidgets python-dotenv evaluate" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Setup" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Initialized MLflow to track repo \"amaye15/CanineNet\"\n",
"
\n"
],
"text/plain": [
"Initialized MLflow to track repo \u001b[32m\"amaye15/CanineNet\"\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Repository amaye15/CanineNet initialized!\n", "\n" ], "text/plain": [ "Repository amaye15/CanineNet initialized!\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import os\n", "import toml\n", "import torch\n", "import mlflow\n", "import dagshub\n", "import datasets\n", "import evaluate\n", "from dotenv import load_dotenv\n", "from torchvision.transforms import v2\n", "from transformers import AutoImageProcessor, AutoModelForImageClassification, TrainingArguments, Trainer\n", "\n", "ENV_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/.env\"\n", "CONFIG_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/code/config.toml\"\n", "CONFIG = toml.load(CONFIG_PATH)\n", "\n", "load_dotenv(ENV_PATH)\n", "\n", "dagshub.init(repo_name=os.environ['MLFLOW_TRACKING_PROJECTNAME'], repo_owner=os.environ['MLFLOW_TRACKING_USERNAME'], mlflow=True, dvc=True)\n", "\n", "os.environ['MLFLOW_TRACKING_USERNAME'] = \"amaye15\"\n", "\n", "mlflow.set_tracking_uri(f'https://dagshub.com/' + os.environ['MLFLOW_TRACKING_USERNAME']\n", " + '/' + os.environ['MLFLOW_TRACKING_PROJECTNAME'] + '.mlflow')\n", "\n", "CREATE_DATASET = True\n", "ORIGINAL_DATASET = \"Alanox/stanford-dogs\"\n", "MODIFIED_DATASET = \"amaye15/stanford-dogs\"\n", "REMOVE_COLUMNS = [\"name\", \"annotations\"]\n", "RENAME_COLUMNS = {\"image\":\"pixel_values\", \"target\":\"label\"}\n", "SPLIT = 0.2\n", "\n", "METRICS = [\"accuracy\", \"f1\", \"precision\", \"recall\"]\n", "# MODELS = 'google/vit-base-patch16-224'\n", "# MODELS = \"google/siglip-base-patch16-224\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Affenpinscher: 0\n", "Afghan Hound: 1\n", "African Hunting Dog: 2\n", "Airedale: 3\n", "American Staffordshire Terrier: 4\n", "Appenzeller: 5\n", "Australian Terrier: 6\n", "Basenji: 7\n", "Basset: 8\n", "Beagle: 9\n", "Bedlington Terrier: 10\n", "Bernese Mountain Dog: 11\n", "Black And Tan Coonhound: 12\n", "Blenheim Spaniel: 13\n", "Bloodhound: 14\n", "Bluetick: 15\n", "Border Collie: 16\n", "Border Terrier: 17\n", "Borzoi: 18\n", "Boston Bull: 19\n", "Bouvier Des Flandres: 20\n", "Boxer: 21\n", "Brabancon Griffon: 22\n", "Briard: 23\n", "Brittany Spaniel: 24\n", "Bull Mastiff: 25\n", "Cairn: 26\n", "Cardigan: 27\n", "Chesapeake Bay Retriever: 28\n", "Chihuahua: 29\n", "Chow: 30\n", "Clumber: 31\n", "Cocker Spaniel: 32\n", "Collie: 33\n", "Curly Coated Retriever: 34\n", "Dandie Dinmont: 35\n", "Dhole: 36\n", "Dingo: 37\n", "Doberman: 38\n", "English Foxhound: 39\n", "English Setter: 40\n", "English Springer: 41\n", "Entlebucher: 42\n", "Eskimo Dog: 43\n", "Flat Coated Retriever: 44\n", "French Bulldog: 45\n", "German Shepherd: 46\n", "German Short Haired Pointer: 47\n", "Giant Schnauzer: 48\n", "Golden Retriever: 49\n", "Gordon Setter: 50\n", "Great Dane: 51\n", "Great Pyrenees: 52\n", "Greater Swiss Mountain Dog: 53\n", "Groenendael: 54\n", "Ibizan Hound: 55\n", "Irish Setter: 56\n", "Irish Terrier: 57\n", "Irish Water Spaniel: 58\n", "Irish Wolfhound: 59\n", "Italian Greyhound: 60\n", "Japanese Spaniel: 61\n", "Keeshond: 62\n", "Kelpie: 63\n", "Kerry Blue Terrier: 64\n", "Komondor: 65\n", "Kuvasz: 66\n", "Labrador Retriever: 67\n", "Lakeland Terrier: 68\n", "Leonberg: 69\n", "Lhasa: 70\n", "Malamute: 71\n", "Malinois: 72\n", "Maltese Dog: 73\n", "Mexican Hairless: 74\n", "Miniature Pinscher: 75\n", "Miniature Poodle: 76\n", "Miniature Schnauzer: 77\n", "Newfoundland: 78\n", "Norfolk Terrier: 79\n", "Norwegian Elkhound: 80\n", "Norwich Terrier: 81\n", "Old English Sheepdog: 82\n", "Otterhound: 83\n", "Papillon: 84\n", "Pekinese: 85\n", "Pembroke: 86\n", "Pomeranian: 87\n", "Pug: 88\n", "Redbone: 89\n", "Rhodesian Ridgeback: 90\n", "Rottweiler: 91\n", "Saint Bernard: 92\n", "Saluki: 93\n", "Samoyed: 94\n", "Schipperke: 95\n", "Scotch Terrier: 96\n", "Scottish Deerhound: 97\n", "Sealyham Terrier: 98\n", "Shetland Sheepdog: 99\n", "Shih Tzu: 100\n", "Siberian Husky: 101\n", "Silky Terrier: 102\n", "Soft Coated Wheaten Terrier: 103\n", "Staffordshire Bullterrier: 104\n", "Standard Poodle: 105\n", "Standard Schnauzer: 106\n", "Sussex Spaniel: 107\n", "Tibetan Mastiff: 108\n", "Tibetan Terrier: 109\n", "Toy Poodle: 110\n", "Toy Terrier: 111\n", "Vizsla: 112\n", "Walker Hound: 113\n", "Weimaraner: 114\n", "Welsh Springer Spaniel: 115\n", "West Highland White Terrier: 116\n", "Whippet: 117\n", "Wire Haired Fox Terrier: 118\n", "Yorkshire Terrier: 119\n" ] } ], "source": [ "if CREATE_DATASET:\n", " ds = datasets.load_dataset(ORIGINAL_DATASET, token=os.getenv(\"HF_TOKEN\"), split=\"full\", trust_remote_code=True)\n", " ds = ds.remove_columns(REMOVE_COLUMNS).rename_columns(RENAME_COLUMNS)\n", "\n", " labels = ds.select_columns(\"label\").to_pandas().sort_values(\"label\").get(\"label\").unique().tolist()\n", " numbers = range(len(labels))\n", " label2int = dict(zip(labels, numbers))\n", " int2label = dict(zip(numbers, labels))\n", "\n", " for key, val in label2int.items():\n", " print(f\"{key}: {val}\")\n", "\n", " ds = ds.class_encode_column(\"label\")\n", " ds = ds.align_labels_with_mapping(label2int, \"label\")\n", "\n", " ds = ds.train_test_split(test_size=SPLIT, stratify_by_column = \"label\")\n", " #ds.push_to_hub(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"))\n", "\n", " CONFIG[\"label2int\"] = str(label2int)\n", " CONFIG[\"int2label\"] = str(int2label)\n", "\n", " # with open(\"output.toml\", \"w\") as toml_file:\n", " # toml.dump(toml.dumps(CONFIG), toml_file)\n", "\n", " #ds = datasets.load_dataset(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"), trust_remote_code=True, streaming=True)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", " warnings.warn(\n", "Could not find image processor class in the image processor config or the model config. Loading based on pattern matching with the model's feature extractor configuration. Please open a PR/issue to update `preprocessor_config.json` to use `image_processor_type` instead of `feature_extractor_type`. This warning will be removed in v4.40.\n", "Some weights of Swinv2ForImageClassification were not initialized from the model checkpoint at microsoft/swinv2-base-patch4-window16-256 and are newly initialized because the shapes did not match:\n", "- classifier.weight: found shape torch.Size([1000, 1024]) in the checkpoint and torch.Size([120, 1024]) in the model instantiated\n", "- classifier.bias: found shape torch.Size([1000]) in the checkpoint and torch.Size([120]) in the model instantiated\n", "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n", "max_steps is given, it will override any value given in num_train_epochs\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a476611547454ef08359b18f9122e993", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/1000 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 4.7518, 'grad_norm': 9.390625953674316, 'learning_rate': 4.9500000000000004e-05, 'epoch': 0.08}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8790a7299dba41f08047eb867a620e40", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 4.639115810394287, 'eval_accuracy': 0.07410106899902819, 'eval_f1': 0.053338767481424125, 'eval_precision': 0.06668646345851367, 'eval_recall': 0.07050091579227699, 'eval_runtime': 122.7601, 'eval_samples_per_second': 33.529, 'eval_steps_per_second': 1.051, 'epoch': 0.08}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 4.5585, 'grad_norm': 16.583328247070312, 'learning_rate': 4.9e-05, 'epoch': 0.16}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2d1989e313e24c889ce12f06eb6387c4", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 4.346254348754883, 'eval_accuracy': 0.19193391642371235, 'eval_f1': 0.14445541276201207, 'eval_precision': 0.18999966240710864, 'eval_recall': 0.1794198274691427, 'eval_runtime': 125.4121, 'eval_samples_per_second': 32.82, 'eval_steps_per_second': 1.029, 'epoch': 0.16}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 4.2377, 'grad_norm': 26.891368865966797, 'learning_rate': 4.85e-05, 'epoch': 0.23}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1670e0352d4a4e42b84d6e43726fefdf", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 3.8243072032928467, 'eval_accuracy': 0.3525267249757046, 'eval_f1': 0.31002515422438126, 'eval_precision': 0.41537451879077536, 'eval_recall': 0.33815280861269076, 'eval_runtime': 121.7465, 'eval_samples_per_second': 33.808, 'eval_steps_per_second': 1.06, 'epoch': 0.23}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 3.6654, 'grad_norm': 36.484336853027344, 'learning_rate': 4.8e-05, 'epoch': 0.31}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f6ab5c20d53e4f9b961fda0faf7ed68e", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 2.9276485443115234, 'eval_accuracy': 0.640913508260447, 'eval_f1': 0.6111447372819326, 'eval_precision': 0.6994107673804264, 'eval_recall': 0.6299850736069784, 'eval_runtime': 119.9978, 'eval_samples_per_second': 34.301, 'eval_steps_per_second': 1.075, 'epoch': 0.31}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 2.7617, 'grad_norm': 39.120765686035156, 'learning_rate': 4.75e-05, 'epoch': 0.39}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "94a2240afe624a2ebe8649ce43b156bc", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 1.7703156471252441, 'eval_accuracy': 0.8248299319727891, 'eval_f1': 0.8041716661861199, 'eval_precision': 0.8361251271357693, 'eval_recall': 0.8181542323069564, 'eval_runtime': 118.2837, 'eval_samples_per_second': 34.798, 'eval_steps_per_second': 1.091, 'epoch': 0.39}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 1.9475, 'grad_norm': 39.01482009887695, 'learning_rate': 4.7e-05, 'epoch': 0.47}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0ca6adbf62c74f90840087469c261dcb", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 1.043952465057373, 'eval_accuracy': 0.8862973760932945, 'eval_f1': 0.8780889702421721, 'eval_precision': 0.8924114337387474, 'eval_recall': 0.882146610947727, 'eval_runtime': 116.9676, 'eval_samples_per_second': 35.189, 'eval_steps_per_second': 1.103, 'epoch': 0.47}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 1.3629, 'grad_norm': 43.029022216796875, 'learning_rate': 4.6500000000000005e-05, 'epoch': 0.54}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "af9d01f55c914ca0bab82f3ae3941567", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.6490112543106079, 'eval_accuracy': 0.9098639455782312, 'eval_f1': 0.9031378990742644, 'eval_precision': 0.9191206744821958, 'eval_recall': 0.9061687520491638, 'eval_runtime': 117.6616, 'eval_samples_per_second': 34.982, 'eval_steps_per_second': 1.096, 'epoch': 0.54}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 1.0488, 'grad_norm': 39.756900787353516, 'learning_rate': 4.600000000000001e-05, 'epoch': 0.62}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "15b72c0511c34c4892b22af3d3aa30f0", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.4484623670578003, 'eval_accuracy': 0.9149659863945578, 'eval_f1': 0.9074605144391643, 'eval_precision': 0.9146605032717635, 'eval_recall': 0.9118267161714619, 'eval_runtime': 119.5898, 'eval_samples_per_second': 34.418, 'eval_steps_per_second': 1.079, 'epoch': 0.62}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.8477, 'grad_norm': 33.365509033203125, 'learning_rate': 4.55e-05, 'epoch': 0.7}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "113e272ba5454f859e9cef987ca0c638", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.3743549585342407, 'eval_accuracy': 0.9205539358600583, 'eval_f1': 0.9169219807550186, 'eval_precision': 0.9293988137338194, 'eval_recall': 0.9189619888825881, 'eval_runtime': 120.9735, 'eval_samples_per_second': 34.024, 'eval_steps_per_second': 1.066, 'epoch': 0.7}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.7184, 'grad_norm': 34.209716796875, 'learning_rate': 4.5e-05, 'epoch': 0.78}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "627a14cb020c4a77ba73f92cdfcaa8a2", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.3300754427909851, 'eval_accuracy': 0.9258989310009719, 'eval_f1': 0.9215361801462706, 'eval_precision': 0.9282778107282813, 'eval_recall': 0.9227499673950158, 'eval_runtime': 120.3629, 'eval_samples_per_second': 34.197, 'eval_steps_per_second': 1.072, 'epoch': 0.78}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.7149, 'grad_norm': 30.539337158203125, 'learning_rate': 4.4500000000000004e-05, 'epoch': 0.85}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f2f8b8fc76bb4cd9aa79a3c2e1762716", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2970269024372101, 'eval_accuracy': 0.9186103012633625, 'eval_f1': 0.9152438416028247, 'eval_precision': 0.9226596717426415, 'eval_recall': 0.9156450507816004, 'eval_runtime': 118.1418, 'eval_samples_per_second': 34.839, 'eval_steps_per_second': 1.092, 'epoch': 0.85}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.6429, 'grad_norm': 66.82299041748047, 'learning_rate': 4.4000000000000006e-05, 'epoch': 0.93}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3b9f408845014c45ac4724ba33a21fee", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2674591839313507, 'eval_accuracy': 0.9285714285714286, 'eval_f1': 0.9238129060193967, 'eval_precision': 0.9301368936281837, 'eval_recall': 0.9256311870951985, 'eval_runtime': 118.2453, 'eval_samples_per_second': 34.809, 'eval_steps_per_second': 1.091, 'epoch': 0.93}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5864, 'grad_norm': 33.499786376953125, 'learning_rate': 4.35e-05, 'epoch': 1.01}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5c5220c50a3542689623f7923b7e19af", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.260906845331192, 'eval_accuracy': 0.9290573372206026, 'eval_f1': 0.9258240260144658, 'eval_precision': 0.9338417051433888, 'eval_recall': 0.9271689104847066, 'eval_runtime': 113.4782, 'eval_samples_per_second': 36.271, 'eval_steps_per_second': 1.137, 'epoch': 1.01}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5414, 'grad_norm': 27.897539138793945, 'learning_rate': 4.3e-05, 'epoch': 1.09}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "974d2f0a759544b3ae1f20cd0d56e64b", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2644219696521759, 'eval_accuracy': 0.9161807580174927, 'eval_f1': 0.9122389605151222, 'eval_precision': 0.9211654018756885, 'eval_recall': 0.9155822994203213, 'eval_runtime': 113.8144, 'eval_samples_per_second': 36.164, 'eval_steps_per_second': 1.133, 'epoch': 1.09}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5323, 'grad_norm': 42.06348419189453, 'learning_rate': 4.25e-05, 'epoch': 1.17}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a9560d3b29354120a668f2a82581251f", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2454349249601364, 'eval_accuracy': 0.9280855199222546, 'eval_f1': 0.922547904522988, 'eval_precision': 0.9361557799152643, 'eval_recall': 0.9256003853911859, 'eval_runtime': 117.6285, 'eval_samples_per_second': 34.992, 'eval_steps_per_second': 1.097, 'epoch': 1.17}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5061, 'grad_norm': 27.641525268554688, 'learning_rate': 4.2e-05, 'epoch': 1.24}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "72904f84b88b4f8b957f68895478cc7d", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2481379508972168, 'eval_accuracy': 0.9268707482993197, 'eval_f1': 0.9234504572819081, 'eval_precision': 0.9308003097280835, 'eval_recall': 0.9250780783392921, 'eval_runtime': 118.0847, 'eval_samples_per_second': 34.856, 'eval_steps_per_second': 1.092, 'epoch': 1.24}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5898, 'grad_norm': 29.9394588470459, 'learning_rate': 4.15e-05, 'epoch': 1.32}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "058fe79d2fe24cf3ad6a5399acaaa419", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.23057658970355988, 'eval_accuracy': 0.934645286686103, 'eval_f1': 0.9324039888619194, 'eval_precision': 0.9388904263022082, 'eval_recall': 0.9331000934899664, 'eval_runtime': 118.2346, 'eval_samples_per_second': 34.812, 'eval_steps_per_second': 1.091, 'epoch': 1.32}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5277, 'grad_norm': 22.529125213623047, 'learning_rate': 4.1e-05, 'epoch': 1.4}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ef3f81cfed384185ade86ccb13896f17", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.21916857361793518, 'eval_accuracy': 0.9368318756073858, 'eval_f1': 0.9326511251722105, 'eval_precision': 0.9383714959002939, 'eval_recall': 0.9349716395661107, 'eval_runtime': 118.7182, 'eval_samples_per_second': 34.67, 'eval_steps_per_second': 1.087, 'epoch': 1.4}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4824, 'grad_norm': 36.2570915222168, 'learning_rate': 4.05e-05, 'epoch': 1.48}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "089d52cc63444a2c8cde2124e45caa15", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.21711421012878418, 'eval_accuracy': 0.9336734693877551, 'eval_f1': 0.929709056352932, 'eval_precision': 0.9374557958848866, 'eval_recall': 0.9311224774812498, 'eval_runtime': 119.027, 'eval_samples_per_second': 34.58, 'eval_steps_per_second': 1.084, 'epoch': 1.48}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4632, 'grad_norm': 22.403745651245117, 'learning_rate': 4e-05, 'epoch': 1.55}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "01e5da7e274a40d29c13929ed2494e9c", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.22438718378543854, 'eval_accuracy': 0.934645286686103, 'eval_f1': 0.9314573088004496, 'eval_precision': 0.9378662507720702, 'eval_recall': 0.9326384727705795, 'eval_runtime': 121.7252, 'eval_samples_per_second': 33.814, 'eval_steps_per_second': 1.06, 'epoch': 1.55}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4882, 'grad_norm': 19.468097686767578, 'learning_rate': 3.9500000000000005e-05, 'epoch': 1.63}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0281f400fb664087a3c2f50895bcb7f0", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2236798256635666, 'eval_accuracy': 0.9361030126336248, 'eval_f1': 0.9322983411373361, 'eval_precision': 0.9404104668252149, 'eval_recall': 0.9345130791697032, 'eval_runtime': 115.5911, 'eval_samples_per_second': 35.608, 'eval_steps_per_second': 1.116, 'epoch': 1.63}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4583, 'grad_norm': 29.652774810791016, 'learning_rate': 3.9000000000000006e-05, 'epoch': 1.71}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0d1e88ee9e994a8595b8920dbccb6600", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2227955460548401, 'eval_accuracy': 0.9327016520894071, 'eval_f1': 0.9288976376084872, 'eval_precision': 0.9372589912326925, 'eval_recall': 0.9304356780487182, 'eval_runtime': 118.2652, 'eval_samples_per_second': 34.803, 'eval_steps_per_second': 1.091, 'epoch': 1.71}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4692, 'grad_norm': 45.817378997802734, 'learning_rate': 3.85e-05, 'epoch': 1.79}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "15718cac9aaf476e83184921d6eb2aff", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20977580547332764, 'eval_accuracy': 0.935374149659864, 'eval_f1': 0.931613286271804, 'eval_precision': 0.9370143572286509, 'eval_recall': 0.9332420309524705, 'eval_runtime': 116.3014, 'eval_samples_per_second': 35.391, 'eval_steps_per_second': 1.109, 'epoch': 1.79}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.5407, 'grad_norm': 48.70719528198242, 'learning_rate': 3.8e-05, 'epoch': 1.86}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "367811b91762488a90f8d82e3b5e35d6", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.21022267639636993, 'eval_accuracy': 0.935617103984451, 'eval_f1': 0.9342051845781768, 'eval_precision': 0.9374551819177072, 'eval_recall': 0.9350949929613589, 'eval_runtime': 119.8444, 'eval_samples_per_second': 34.345, 'eval_steps_per_second': 1.076, 'epoch': 1.86}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4629, 'grad_norm': 40.25789260864258, 'learning_rate': 3.7500000000000003e-05, 'epoch': 1.94}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "638ffc2535074361b9c7f32ab25e0d87", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20446407794952393, 'eval_accuracy': 0.9378036929057337, 'eval_f1': 0.9348527011477886, 'eval_precision': 0.9395619022083945, 'eval_recall': 0.936717917602765, 'eval_runtime': 114.3207, 'eval_samples_per_second': 36.004, 'eval_steps_per_second': 1.128, 'epoch': 1.94}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4363, 'grad_norm': 34.60853958129883, 'learning_rate': 3.7e-05, 'epoch': 2.02}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6b5c279e63a74a0ca7d999a3116dc304", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20228153467178345, 'eval_accuracy': 0.9373177842565598, 'eval_f1': 0.9346485296103381, 'eval_precision': 0.9397930084364895, 'eval_recall': 0.9354963888099695, 'eval_runtime': 115.3383, 'eval_samples_per_second': 35.686, 'eval_steps_per_second': 1.118, 'epoch': 2.02}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4328, 'grad_norm': 26.99337387084961, 'learning_rate': 3.65e-05, 'epoch': 2.1}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b53ad317ab1a44699c22f32119cbc833", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20625373721122742, 'eval_accuracy': 0.935374149659864, 'eval_f1': 0.9319561975473203, 'eval_precision': 0.9360019214632094, 'eval_recall': 0.93430737851741, 'eval_runtime': 114.9885, 'eval_samples_per_second': 35.795, 'eval_steps_per_second': 1.122, 'epoch': 2.1}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3554, 'grad_norm': 28.036481857299805, 'learning_rate': 3.6e-05, 'epoch': 2.17}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5d74e2a9b5094d0a93eb68fb5564da50", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.19484364986419678, 'eval_accuracy': 0.9438775510204082, 'eval_f1': 0.9397775702488407, 'eval_precision': 0.9474960731219763, 'eval_recall': 0.9418466963494533, 'eval_runtime': 116.995, 'eval_samples_per_second': 35.181, 'eval_steps_per_second': 1.103, 'epoch': 2.17}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4024, 'grad_norm': 30.97524642944336, 'learning_rate': 3.55e-05, 'epoch': 2.25}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "fe6a83c4081645daa098b36014c35911", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.19847826659679413, 'eval_accuracy': 0.9387755102040817, 'eval_f1': 0.9372478002991185, 'eval_precision': 0.9397167553305189, 'eval_recall': 0.9376525555929388, 'eval_runtime': 113.5301, 'eval_samples_per_second': 36.255, 'eval_steps_per_second': 1.136, 'epoch': 2.25}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4006, 'grad_norm': 30.08006477355957, 'learning_rate': 3.5e-05, 'epoch': 2.33}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ea3e385421cd451eb7297c5c319781dd", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.2153274416923523, 'eval_accuracy': 0.9334305150631681, 'eval_f1': 0.9275387845824814, 'eval_precision': 0.9419875530424547, 'eval_recall': 0.9310524562810819, 'eval_runtime': 116.2218, 'eval_samples_per_second': 35.415, 'eval_steps_per_second': 1.11, 'epoch': 2.33}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3935, 'grad_norm': 26.754928588867188, 'learning_rate': 3.45e-05, 'epoch': 2.41}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f54d46999e934ae7bd92203e0723b29d", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20206879079341888, 'eval_accuracy': 0.9392614188532555, 'eval_f1': 0.9345899675258124, 'eval_precision': 0.9415653519418664, 'eval_recall': 0.9368182103451178, 'eval_runtime': 114.9203, 'eval_samples_per_second': 35.816, 'eval_steps_per_second': 1.123, 'epoch': 2.41}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3591, 'grad_norm': 18.381698608398438, 'learning_rate': 3.4000000000000007e-05, 'epoch': 2.49}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a939a26c314c4bc48a1a37c17fea7592", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.21262311935424805, 'eval_accuracy': 0.934645286686103, 'eval_f1': 0.9310688457336352, 'eval_precision': 0.9403388539780413, 'eval_recall': 0.9332890437488752, 'eval_runtime': 115.8495, 'eval_samples_per_second': 35.529, 'eval_steps_per_second': 1.114, 'epoch': 2.49}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4058, 'grad_norm': 38.42707824707031, 'learning_rate': 3.35e-05, 'epoch': 2.56}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "50d0c42c4f8a415595c696781b01847b", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20197580754756927, 'eval_accuracy': 0.9378036929057337, 'eval_f1': 0.9356625337908084, 'eval_precision': 0.9393282055887032, 'eval_recall': 0.935787907740436, 'eval_runtime': 115.4582, 'eval_samples_per_second': 35.649, 'eval_steps_per_second': 1.117, 'epoch': 2.56}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.396, 'grad_norm': 29.439712524414062, 'learning_rate': 3.3e-05, 'epoch': 2.64}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0462c202c3dc4b22a53d4c822d2705d7", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20382580161094666, 'eval_accuracy': 0.9370748299319728, 'eval_f1': 0.9338700635095457, 'eval_precision': 0.9410414254819953, 'eval_recall': 0.9357427719978543, 'eval_runtime': 113.0645, 'eval_samples_per_second': 36.404, 'eval_steps_per_second': 1.141, 'epoch': 2.64}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4157, 'grad_norm': 30.86858367919922, 'learning_rate': 3.2500000000000004e-05, 'epoch': 2.72}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "48e3c7dae1ca4c43b188b4a124923773", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.20911905169487, 'eval_accuracy': 0.9331875607385811, 'eval_f1': 0.9287535942840445, 'eval_precision': 0.9351518924076643, 'eval_recall': 0.9307581587262745, 'eval_runtime': 114.6445, 'eval_samples_per_second': 35.902, 'eval_steps_per_second': 1.125, 'epoch': 2.72}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.4222, 'grad_norm': 29.99662208557129, 'learning_rate': 3.2000000000000005e-05, 'epoch': 2.8}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "109e55a7b44a44b9a482037011296482", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.1933327168226242, 'eval_accuracy': 0.9392614188532555, 'eval_f1': 0.9372313674271271, 'eval_precision': 0.9398983217337015, 'eval_recall': 0.9377663643140918, 'eval_runtime': 114.7869, 'eval_samples_per_second': 35.858, 'eval_steps_per_second': 1.124, 'epoch': 2.8}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3521, 'grad_norm': 30.95831298828125, 'learning_rate': 3.15e-05, 'epoch': 2.87}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d6ea2392bbb14a9ca7ee10bd152d377e", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.198385551571846, 'eval_accuracy': 0.9397473275024295, 'eval_f1': 0.9380846555670623, 'eval_precision': 0.9429846718188393, 'eval_recall': 0.9388009151105176, 'eval_runtime': 115.1456, 'eval_samples_per_second': 35.746, 'eval_steps_per_second': 1.12, 'epoch': 2.87}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3925, 'grad_norm': 39.25502395629883, 'learning_rate': 3.1e-05, 'epoch': 2.95}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7312e1a6d9e84c36afd247a2f2c1b37e", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.18743416666984558, 'eval_accuracy': 0.9382896015549077, 'eval_f1': 0.9347460787377938, 'eval_precision': 0.9389896925557485, 'eval_recall': 0.9357984136549564, 'eval_runtime': 113.3981, 'eval_samples_per_second': 36.297, 'eval_steps_per_second': 1.138, 'epoch': 2.95}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3475, 'grad_norm': 34.49732208251953, 'learning_rate': 3.05e-05, 'epoch': 3.03}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e5b85ef8da594a2f8cf915433ba23db8", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.19942405819892883, 'eval_accuracy': 0.9382896015549077, 'eval_f1': 0.9364100359103614, 'eval_precision': 0.9410069422883035, 'eval_recall': 0.9376210497900824, 'eval_runtime': 115.7969, 'eval_samples_per_second': 35.545, 'eval_steps_per_second': 1.114, 'epoch': 3.03}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3526, 'grad_norm': 34.14906311035156, 'learning_rate': 3e-05, 'epoch': 3.11}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a1c980fe777f4de392fbe12a110ecdcd", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.1941181868314743, 'eval_accuracy': 0.9390184645286687, 'eval_f1': 0.9351668156232781, 'eval_precision': 0.9402405362825343, 'eval_recall': 0.9372908916182126, 'eval_runtime': 112.8197, 'eval_samples_per_second': 36.483, 'eval_steps_per_second': 1.143, 'epoch': 3.11}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.351, 'grad_norm': 25.905424118041992, 'learning_rate': 2.95e-05, 'epoch': 3.18}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "630981b183234e758971e712e999028d", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.18932673335075378, 'eval_accuracy': 0.9416909620991254, 'eval_f1': 0.940318085045109, 'eval_precision': 0.9438062512440089, 'eval_recall': 0.9409543473093137, 'eval_runtime': 114.6924, 'eval_samples_per_second': 35.887, 'eval_steps_per_second': 1.125, 'epoch': 3.18}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{'loss': 0.3549, 'grad_norm': 26.349733352661133, 'learning_rate': 2.9e-05, 'epoch': 3.26}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b4bf00320dee42bbad21874c2a2cf471", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/129 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "{'eval_loss': 0.19598565995693207, 'eval_accuracy': 0.9390184645286687, 'eval_f1': 0.936971760890017, 'eval_precision': 0.9409831330401592, 'eval_recall': 0.938080489222113, 'eval_runtime': 118.5544, 'eval_samples_per_second': 34.718, 'eval_steps_per_second': 1.088, 'epoch': 3.26}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", " warnings.warn(\n" ] } ], "source": [ "metrics = {metric: evaluate.load(metric) for metric in METRICS}\n", "\n", "\n", "# for lr in [5e-3, 5e-4, 5e-5]: # 5e-5\n", "# for batch in [64]: # 32\n", "# for model_name in [\"google/vit-base-patch16-224\", \"microsoft/swinv2-base-patch4-window16-256\", \"google/siglip-base-patch16-224\"]: # \"facebook/dinov2-base\"\n", "\n", "lr = 5e-4\n", "batch = 32\n", "model_name = \"microsoft/swinv2-base-patch4-window16-256\"\n", "\n", "image_processor = AutoImageProcessor.from_pretrained(model_name)\n", "model = AutoModelForImageClassification.from_pretrained(\n", "model_name,\n", "num_labels=len(label2int),\n", "id2label=int2label,\n", "label2id=label2int,\n", "ignore_mismatched_sizes=True,\n", ")\n", "\n", "# Then, in your transformations:\n", "def train_transform(examples, num_ops=10, magnitude=9, num_magnitude_bins=31):\n", "\n", " transformation = v2.Compose(\n", " [\n", " v2.RandAugment(\n", " num_ops=num_ops,\n", " magnitude=magnitude,\n", " num_magnitude_bins=num_magnitude_bins,\n", " )\n", " ]\n", " )\n", " # Ensure each image has three dimensions (in this case, ensure it's RGB)\n", " examples[\"pixel_values\"] = [\n", " image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n", " ]\n", " # Apply transformations\n", " examples[\"pixel_values\"] = [\n", " image_processor(transformation(image), return_tensors=\"pt\")[\n", " \"pixel_values\"\n", " ].squeeze()\n", " for image in examples[\"pixel_values\"]\n", " ]\n", " return examples\n", "\n", "\n", "def test_transform(examples):\n", " # Ensure each image is RGB\n", " examples[\"pixel_values\"] = [\n", " image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n", " ]\n", " # Apply processing\n", " examples[\"pixel_values\"] = [\n", " image_processor(image, return_tensors=\"pt\")[\"pixel_values\"].squeeze()\n", " for image in examples[\"pixel_values\"]\n", " ]\n", " return examples\n", "\n", "\n", "def compute_metrics(eval_pred):\n", " predictions, labels = eval_pred\n", " # predictions = np.argmax(logits, axis=-1)\n", " results = {}\n", " for key, val in metrics.items():\n", " if \"accuracy\" == key:\n", " result = next(\n", " iter(val.compute(predictions=predictions, references=labels).items())\n", " )\n", " if \"accuracy\" != key:\n", " result = next(\n", " iter(\n", " val.compute(\n", " predictions=predictions, references=labels, average=\"macro\"\n", " ).items()\n", " )\n", " )\n", " results[result[0]] = result[1]\n", " return results\n", "\n", "\n", "def collate_fn(examples):\n", " pixel_values = torch.stack([example[\"pixel_values\"] for example in examples])\n", " labels = torch.tensor([example[\"label\"] for example in examples])\n", " return {\"pixel_values\": pixel_values, \"labels\": labels}\n", "\n", "\n", "def preprocess_logits_for_metrics(logits, labels):\n", " \"\"\"\n", " Original Trainer may have a memory leak.\n", " This is a workaround to avoid storing too many tensors that are not needed.\n", " \"\"\"\n", " pred_ids = torch.argmax(logits, dim=-1)\n", " return pred_ids\n", "\n", "ds[\"train\"].set_transform(train_transform)\n", "ds[\"test\"].set_transform(test_transform)\n", "\n", "training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", "training_args.per_device_train_batch_size = batch\n", "training_args.per_device_eval_batch_size = batch\n", "training_args.hub_model_id = f\"amaye15/{model_name.replace('/','-')}-batch{batch}-lr{lr}-standford-dogs\"\n", "\n", "mlflow.start_run(run_name=f\"{model_name.replace('/','-')}-batch{batch}-lr{lr}\")\n", "\n", "trainer = Trainer(\n", " model=model,\n", " args=training_args,\n", " train_dataset=ds[\"train\"],\n", " eval_dataset=ds[\"test\"],\n", " tokenizer=image_processor,\n", " data_collator=collate_fn,\n", " compute_metrics=compute_metrics,\n", " # callbacks=[early_stopping_callback],\n", " preprocess_logits_for_metrics=preprocess_logits_for_metrics,\n", ")\n", "\n", "# Train the model\n", "trainer.train()\n", "\n", "trainer.push_to_hub()\n", "\n", "mlflow.end_run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mlflow.end_run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", "\n", "# image_processor = AutoImageProcessor.from_pretrained(MODELS)\n", "# model = AutoModelForImageClassification.from_pretrained(\n", "# MODELS,\n", "# num_labels=len(CONFIG[\"label2int\"]),\n", "# id2label=CONFIG[\"label2int\"],\n", "# label2id=CONFIG[\"int2label\"],\n", "# ignore_mismatched_sizes=True,\n", "# )\n", "\n", "\n", "# training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", "\n", "# trainer = Trainer(\n", "# model=model,\n", "# args=training_args,\n", "# train_dataset=ds[\"train\"],\n", "# eval_dataset=ds[\"test\"],\n", "# tokenizer=image_processor,\n", "# data_collator=collate_fn,\n", "# compute_metrics=compute_metrics,\n", "# # callbacks=[early_stopping_callback],\n", "# preprocess_logits_for_metrics=preprocess_logits_for_metrics,\n", "# )\n", "\n", "# # Train the model\n", "# trainer.train()\n", "\n", "# mlflow.end_run()" ] } ], "metadata": { "kernelspec": { "display_name": "env", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }