From c41593c177a09fd134a4cd6a87eafaddc2b053fb Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Thu, 23 Nov 2023 11:40:34 +0100 Subject: [PATCH 1/3] WIP Move OpenAI examples to their own folder --- fastai/README.md | 1 + fastai/train-example.py | 44 -- .../fastai/fastai-hello-world/README.md | 0 .../fastai-hello-world/fastai_hello_world.py | 40 + .../fastai-hello-world/requirements.txt | 2 + .../fastai/notebooks/fastai_hello_world.ipynb | 634 +++++++++++++++ notebooks/fastai.ipynb | 732 ------------------ 7 files changed, 677 insertions(+), 776 deletions(-) create mode 100644 fastai/README.md delete mode 100644 fastai/train-example.py create mode 100644 integrations/model-training/fastai/fastai-hello-world/README.md create mode 100644 integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py create mode 100644 integrations/model-training/fastai/fastai-hello-world/requirements.txt create mode 100644 integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb delete mode 100644 notebooks/fastai.ipynb diff --git a/fastai/README.md b/fastai/README.md new file mode 100644 index 00000000..769e20eb --- /dev/null +++ b/fastai/README.md @@ -0,0 +1 @@ +All of the fastai examples has been moved here: https://github.com/comet-ml/comet-examples/tree/master/integrations/model-training/fastai/. diff --git a/fastai/train-example.py b/fastai/train-example.py deleted file mode 100644 index 532d6146..00000000 --- a/fastai/train-example.py +++ /dev/null @@ -1,44 +0,0 @@ -## MNIST Example in fastai - -## Note: this uses fastai version 1.0.38 -## pip install fastai==1.0.38 - -from comet_ml import Experiment - -import fastai -import fastai.vision -import glob -import os - -# The model, also known as wrn_22: -model = fastai.vision.models.WideResNet(num_groups=3, - N=3, - num_classes=10, - k=6, - drop_p=0.) - -## Get the MNIST_TINY dataset: -path = fastai.datasets.untar_data(fastai.datasets.URLs.MNIST_TINY) -print("data path:", path) - -## Still too many for a CPU, so we trim it down to 10 in each category: -dirname = os.path.dirname(path) -for group in ["mnist_tiny/train/3/*.png", - "mnist_tiny/train/7/*.png", - "mnist_tiny/valid/3/*.png", - "mnist_tiny/valid/7/*.png"]: - for filename in glob.glob(os.path.join(dirname, group))[10:]: - os.remove(filename) - -experiment = Experiment(project_name="fastai") - -## Now we get the image data from the folder: -data = fastai.vision.ImageDataBunch.from_folder(path, bs=10) # bs: batch size - -if data.device.type == 'cpu': - learn = fastai.basic_train.Learner(data, model, metrics=fastai.metrics.accuracy) -else: # GPU: - learn = fastai.basic_train.Learner(data, model, metrics=fastai.metrics.accuracy).to_fp16() - -with experiment.train(): - learn.fit_one_cycle(10, 3e-3, wd=0.4, div_factor=10, pct_start=0.5) diff --git a/integrations/model-training/fastai/fastai-hello-world/README.md b/integrations/model-training/fastai/fastai-hello-world/README.md new file mode 100644 index 00000000..e69de29b diff --git a/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py b/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py new file mode 100644 index 00000000..2ccd4e34 --- /dev/null +++ b/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py @@ -0,0 +1,40 @@ +# coding: utf-8 +import comet_ml + +from fastai.vision.all import ( + Categorize, + Datasets, + GrandparentSplitter, + IntToFloatTensor, + PILImageBW, + ToTensor, + URLs, + error_rate, + get_image_files, + parent_label, + resnet18, + untar_data, + vision_learner, +) + +EPOCHS = 5 + +comet_ml.init(project_name="comet-examples-fastai-hello-world") +experiment = comet_ml.Experiment() + +path = untar_data(URLs.MNIST_TINY) + +items = get_image_files(path) +tds = Datasets( + items, + [PILImageBW.create, [parent_label, Categorize()]], + splits=GrandparentSplitter()(items), +) +dls = tds.dataloaders(after_item=[ToTensor(), IntToFloatTensor()]) + +learn = vision_learner(dls, resnet18, pretrained=True, metrics=error_rate) + +with experiment.train(): + learn.fit_one_cycle(EPOCHS) + +experiment.end() diff --git a/integrations/model-training/fastai/fastai-hello-world/requirements.txt b/integrations/model-training/fastai/fastai-hello-world/requirements.txt new file mode 100644 index 00000000..10f5d232 --- /dev/null +++ b/integrations/model-training/fastai/fastai-hello-world/requirements.txt @@ -0,0 +1,2 @@ +comet_ml +fastai diff --git a/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb b/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb new file mode 100644 index 00000000..2a0f5e1e --- /dev/null +++ b/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb @@ -0,0 +1,634 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "8LE43szDmKdp" + }, + "source": [ + "\n", + "\n", + "# MNIST Example in fastai\n", + "\n", + "This Jupyter notebook demonstrates using the **fastai** (version 1.0.38) deep learning framework with [comet.ml](https://www.comet.ml).\n", + "\n", + "In this example, we load a fastai model, called WideResNet, and train it on a small part of the MNIST_TINY dataset.\n", + "\n", + "fastai is a framework built on top of the torch Python library.\n", + "\n", + "To find out more, you might find these links helpful:\n", + "\n", + "* http://www.fast.ai/\n", + "* http://docs.fast.ai/\n", + "* http://www.fast.ai/2018/08/10/fastai-diu-imagenet/\n", + "* https://en.wikipedia.org/wiki/MNIST_database\n", + "* http://jupyter.org/\n", + "\n", + "Let's get started!\n", + "\n", + "# 0. Installation\n", + "\n", + "This example uses fastai version 1.0.38. You can install a specific version of fastai (which should also install the correct version of torch) with this command at the terminal:\n", + "\n", + "```\n", + "python -m pip install fastai==1.0.38\n", + "```\n", + "\n", + "Once you have fastai and torch installed, we are ready to import them." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "xiNzBttOmKdr", + "outputId": "7929b2f0-5961-4f11-92cd-35fc6f8a5acd" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: fastai in /usr/local/lib/python3.10/dist-packages (2.7.13)\n", + "Collecting comet_ml\n", + " Downloading comet_ml-3.35.3-py3-none-any.whl (586 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m586.4/586.4 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: pip in /usr/local/lib/python3.10/dist-packages (from fastai) (23.1.2)\n", + "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from fastai) (23.2)\n", + "Requirement already satisfied: fastdownload<2,>=0.0.5 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.0.7)\n", + "Requirement already satisfied: fastcore<1.6,>=1.5.29 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.5.29)\n", + "Requirement already satisfied: torchvision>=0.11 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.16.0+cu118)\n", + "Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from fastai) (3.7.1)\n", + "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from fastai) (1.5.3)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from fastai) (2.31.0)\n", + "Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from fastai) (6.0.1)\n", + "Requirement already satisfied: fastprogress>=0.2.4 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.0.3)\n", + "Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from fastai) (9.4.0)\n", + "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from fastai) (1.2.2)\n", + "Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from fastai) (1.11.3)\n", + "Requirement already satisfied: spacy<4 in /usr/local/lib/python3.10/dist-packages (from fastai) (3.6.1)\n", + "Requirement already satisfied: torch<2.2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from fastai) (2.1.0+cu118)\n", + "Requirement already satisfied: jsonschema!=3.1.0,>=2.6.0 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (4.19.2)\n", + "Requirement already satisfied: psutil>=5.6.3 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (5.9.5)\n", + "Collecting python-box<7.0.0 (from comet_ml)\n", + " Downloading python_box-6.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m11.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting requests-toolbelt>=0.8.0 (from comet_ml)\n", + " Downloading requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m54.5/54.5 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting semantic-version>=2.8.0 (from comet_ml)\n", + " Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", + "Collecting sentry-sdk>=1.1.0 (from comet_ml)\n", + " Downloading sentry_sdk-1.36.0-py2.py3-none-any.whl (249 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m249.2/249.2 kB\u001b[0m \u001b[31m17.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting simplejson (from comet_ml)\n", + " Downloading simplejson-3.19.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.9/137.9 kB\u001b[0m \u001b[31m14.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from comet_ml) (1.16.0)\n", + "Requirement already satisfied: urllib3>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (2.0.7)\n", + "Collecting websocket-client<1.4.0,>=0.55.0 (from comet_ml)\n", + " Downloading websocket_client-1.3.3-py3-none-any.whl (54 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m54.3/54.3 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: wrapt>=1.11.2 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (1.14.1)\n", + "Collecting wurlitzer>=1.0.2 (from comet_ml)\n", + " Downloading wurlitzer-3.0.3-py3-none-any.whl (7.3 kB)\n", + "Collecting everett[ini]<3.2.0,>=1.0.1 (from comet_ml)\n", + " Downloading everett-3.1.0-py2.py3-none-any.whl (35 kB)\n", + "Collecting dulwich!=0.20.33,>=0.20.6 (from comet_ml)\n", + " Downloading dulwich-0.21.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (512 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m512.2/512.2 kB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: rich>=13.3.2 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (13.7.0)\n", + "Collecting configobj (from everett[ini]<3.2.0,>=1.0.1->comet_ml)\n", + " Downloading configobj-5.0.8-py2.py3-none-any.whl (36 kB)\n", + "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (23.1.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (2023.11.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (0.31.0)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (0.12.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (2023.7.22)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13.3.2->comet_ml) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13.3.2->comet_ml) (2.16.1)\n", + "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.12)\n", + "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.5)\n", + "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.10)\n", + "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.8)\n", + "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.9)\n", + "Requirement already satisfied: thinc<8.2.0,>=8.1.8 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (8.1.12)\n", + "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.1.2)\n", + "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.4.8)\n", + "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.10)\n", + "Requirement already satisfied: typer<0.10.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.9.0)\n", + "Requirement already satisfied: pathy>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.10.3)\n", + "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (6.4.0)\n", + "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (4.66.1)\n", + "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.23.5)\n", + "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.10.13)\n", + "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.1.2)\n", + "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (67.7.2)\n", + "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.3.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.13.1)\n", + "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (4.5.0)\n", + "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (1.12)\n", + "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.2.1)\n", + "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2023.6.0)\n", + "Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2.1.0)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.2.0)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (4.44.3)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.4.5)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (3.1.1)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->fastai) (2023.3.post1)\n", + "Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (1.3.2)\n", + "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (3.2.0)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=13.3.2->comet_ml) (0.1.2)\n", + "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /usr/local/lib/python3.10/dist-packages (from thinc<8.2.0,>=8.1.8->spacy<4->fastai) (0.7.11)\n", + "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from thinc<8.2.0,>=8.1.8->spacy<4->fastai) (0.1.3)\n", + "Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.10/dist-packages (from typer<0.10.0,>=0.3.0->spacy<4->fastai) (8.1.7)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->spacy<4->fastai) (2.1.3)\n", + "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch<2.2,>=1.10->fastai) (1.3.0)\n", + "Installing collected packages: everett, wurlitzer, websocket-client, simplejson, sentry-sdk, semantic-version, python-box, dulwich, configobj, requests-toolbelt, comet_ml\n", + " Attempting uninstall: websocket-client\n", + " Found existing installation: websocket-client 1.6.4\n", + " Uninstalling websocket-client-1.6.4:\n", + " Successfully uninstalled websocket-client-1.6.4\n", + " Attempting uninstall: python-box\n", + " Found existing installation: python-box 7.1.1\n", + " Uninstalling python-box-7.1.1:\n", + " Successfully uninstalled python-box-7.1.1\n", + "Successfully installed comet_ml-3.35.3 configobj-5.0.8 dulwich-0.21.6 everett-3.1.0 python-box-6.1.0 requests-toolbelt-1.0.0 semantic-version-2.10.0 sentry-sdk-1.36.0 simplejson-3.19.2 websocket-client-1.3.3 wurlitzer-3.0.3\n" + ] + } + ], + "source": [ + "%pip install -U fastai comet_ml" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "CMD8itjWmKdt" + }, + "source": [ + "## 1. Imports\n", + "\n", + "First, we import the comet_ml library, followed by the fastai library, and others if needed. The only requirement here is that **comet_ml be imported first**. If you forget, just restart the kernel, and import them in the proper order." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "62Tk_v45mKdu" + }, + "outputs": [], + "source": [ + "## Import this first:\n", + "import comet_ml\n", + "\n", + "from fastai.vision.all import *" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "vnNnawcJmKdv" + }, + "outputs": [], + "source": [ + "EPOCHS = 5" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "rBpIQV3hmKdv" + }, + "source": [ + "# 3. Comet Experiment" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ucE282OimKdw", + "outputId": "be595e74-99b0-4068-e043-259e5aef96a8" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Please paste your Comet API key from https://www.comet.com/api/my/settings/\n", + "(api key may not show as you type)\n", + "Comet API key: ··········\n" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Valid Comet API Key saved in /root/.comet.config (set COMET_CONFIG to change where it is saved).\n", + "\u001b[1;38;5;214mCOMET WARNING:\u001b[0m As you are running in a Jupyter environment, you will need to call `experiment.end()` when finished to ensure all metrics and code are logged before exiting.\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Couldn't find a Git repository in '/content' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Experiment is live on comet.com https://www.comet.com/lothiraldan-old/comet-examples-fastai-hello-world/60114263260d4cb491c30e4c45730b82\n", + "\n" + ] + } + ], + "source": [ + "# Create Comet Experiment\n", + "comet_ml.init(project_name=\"comet-examples-fastai-hello-world\")\n", + "experiment = comet_ml.Experiment()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9dDHu5wkmKdw" + }, + "source": [ + "## 2. Dataset" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZII9-P-NmKdx" + }, + "source": [ + "As a simple demo, we'll start with the the MNIST_TINY dataset, In fastai, we use the `datasets.untar_data` function to download and uncompress the data:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 38 + }, + "id": "sUpCpfH7mKdx", + "outputId": "cabd445c-4102-4872-c16e-c9af435a83db" + }, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " \n", + " 100.54% [344064/342207 00:00<00:00]\n", + "
\n", + " " + ] + }, + "metadata": {} + } + ], + "source": [ + "path = untar_data(URLs.MNIST_TINY)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Giiv4pnymKdy" + }, + "source": [ + "The path returned by the untar_data function shows where the data was saved. Using the shell `!` magic, we can explore the dataset in more detail:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "h9Qa5t3fmKdz", + "outputId": "a9d364d4-ad84-4f25-82c3-ec585d884ea6" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.10/dist-packages/fastai/torch_core.py:263: UserWarning: 'has_mps' is deprecated, please use 'torch.backends.mps.is_built()'\n", + " return getattr(torch, 'has_mps', False)\n" + ] + } + ], + "source": [ + "items = get_image_files(path)\n", + "tds = Datasets(\n", + " items,\n", + " [PILImageBW.create, [parent_label, Categorize()]],\n", + " splits=GrandparentSplitter()(items),\n", + ")\n", + "dls = tds.dataloaders(after_item=[ToTensor(), IntToFloatTensor()])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "8eEbaCh6mKd0" + }, + "source": [ + "## 3. Model\n", + "\n", + "In this example, we will use the pre-designed WideresNet from fastai. The model is also known as wrn_22." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "R8JJhlrumKd0", + "outputId": "f7b63acc-c55c-4367-8dd7-3d934739215c" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "Downloading: \"https://download.pytorch.org/models/resnet18-f37072fd.pth\" to /root/.cache/torch/hub/checkpoints/resnet18-f37072fd.pth\n", + "100%|██████████| 44.7M/44.7M [00:00<00:00, 107MB/s]\n" + ] + } + ], + "source": [ + "learn = vision_learner(dls, resnet18, pretrained=True, metrics=error_rate)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "A-0Pft9GmKd1" + }, + "source": [ + "That's it! Often, you would probably build your own model, or adjust a default model. To see more on model building in fastai, see:\n", + "\n", + "* http://files.fast.ai/models/\n", + "* http://course.fast.ai/" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "q-LxaKnwmKd2" + }, + "source": [ + "## 5. Training\n", + "\n", + "In fastai, we can train differently depending on if we are running CPU or a GPU. To test, we can use the `data.device.type` property. This will create a fastai `Learner`:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "GyIBFMOZmKd3" + }, + "source": [ + "Now we are ready to train the model. To tell Comet about the details, we put the call to `fit` or `fit_one_cylce` inside an indented block under `experiment.train()`:" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 206 + }, + "id": "uNzBOFIUmKd3", + "outputId": "174f0f33-1dcc-42e4-e610-d449545d8080" + }, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
epochtrain_lossvalid_losserror_ratetime
01.1180090.5184350.29327600:07
10.7340610.3038410.13733900:08
20.5380980.2239630.08869800:07
30.4187930.1972360.07725300:08
40.3423830.1738150.07439200:07
" + ] + }, + "metadata": {} + } + ], + "source": [ + "with experiment.train():\n", + " learn.fit_one_cycle(EPOCHS)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hKIrsCOGmKd3" + }, + "source": [ + "## 7. Finish" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "do2WvU2AmKd3" + }, + "source": [ + "Finall, we are ready to tell Comet that our experiment is complete. You don't need to do this is a script that ends. But in Jupyter, we need to indicate that the experiment is finished. We do that with the `experiment.end()` method:" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "HDteaKMtmKd3", + "outputId": "3b9c0829-97d0-4521-ca34-b99fedd90866" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Comet.ml Experiment Summary\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Data:\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m display_summary_level : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m url : https://www.comet.com/lothiraldan-old/comet-examples-fastai-hello-world/60114263260d4cb491c30e4c45730b82\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Metrics [count] (min, max):\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m train_loss [11] : (0.07387722283601761, 1.4785162210464478)\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Uploads:\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m environment details : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m filename : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m installed packages : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m model graph : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m notebook : 2\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m os packages : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m source_code : 1\n", + "\u001b[1;38;5;39mCOMET INFO:\u001b[0m \n" + ] + } + ], + "source": [ + "experiment.end()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hx2bmd3dmKd4" + }, + "source": [ + "That's it! If you have any questions, please visit us on https://cometml.slack.com" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.6.6" + }, + "colab": { + "provenance": [] + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/notebooks/fastai.ipynb b/notebooks/fastai.ipynb deleted file mode 100644 index b68e479d..00000000 --- a/notebooks/fastai.ipynb +++ /dev/null @@ -1,732 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "# MNIST Example in fastai\n", - "\n", - "This Jupyter notebook demonstrates using the **fastai** (version 1.0.38) deep learning framework with [comet.ml](https://www.comet.ml).\n", - "\n", - "In this example, we load a fastai model, called WideResNet, and train it on a small part of the MNIST_TINY dataset.\n", - "\n", - "fastai is a framework built on top of the torch Python library. \n", - "\n", - "To find out more, you might find these links helpful:\n", - "\n", - "* http://www.fast.ai/\n", - "* http://docs.fast.ai/\n", - "* http://www.fast.ai/2018/08/10/fastai-diu-imagenet/\n", - "* https://en.wikipedia.org/wiki/MNIST_database\n", - "* http://jupyter.org/\n", - "\n", - "Let's get started!\n", - "\n", - "# 0. Installation\n", - "\n", - "This example uses fastai version 1.0.38. You can install a specific version of fastai (which should also install the correct version of torch) with this command at the terminal:\n", - "\n", - "```\n", - "python -m pip install fastai==1.0.38\n", - "```\n", - "\n", - "Once you have fastai and torch installed, we are ready to import them." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Imports\n", - "\n", - "First, we import the comet_ml library, followed by the fastai library, and others if needed. The only requirement here is that **comet_ml be imported first**. If you forget, just restart the kernel, and import them in the proper order." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "## Import this first:\n", - "from comet_ml import Experiment\n", - "\n", - "## Import the deep learning framework:\n", - "import fastai\n", - "import fastai.vision\n", - "\n", - "## Additional libraries for this example:\n", - "import glob\n", - "import os" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Dataset" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As a simple demo, we'll start with the the MNIST_TINY dataset, In fastai, we use the `datasets.untar_data` function to download and uncompress the data:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "data path: /home/dblank/.fastai/data/mnist_tiny\n" - ] - } - ], - "source": [ - "path = fastai.datasets.untar_data(fastai.datasets.URLs.MNIST_TINY)\n", - "print(\"data path:\", path)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The path returned by the untar_data function shows where the data was saved. Using the shell `!` magic, we can explore the dataset in more detail:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "715.png 7463.png 8360.png 9141.png\t9303.png\r\n", - "7288.png 7626.png 8957.png 9192.png\t9637.png\r\n" - ] - } - ], - "source": [ - "! ls ~/.fastai/data/mnist_tiny/train/3/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "By poking around here, we can see that there are two categories `3` and `7` and each category has about 2,000 examples." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That is still too many for a CPU, so we trim it down to 10 in each category:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "dirname = os.path.dirname(path)\n", - "for group in [\"mnist_tiny/train/3/*.png\",\n", - " \"mnist_tiny/train/7/*.png\",\n", - " \"mnist_tiny/valid/3/*.png\",\n", - " \"mnist_tiny/valid/7/*.png\"]:\n", - " for filename in glob.glob(os.path.join(dirname, group))[10:]:\n", - " os.remove(filename)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, we check again to see if we have just 10 images:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "715.png 7463.png 8360.png 9141.png\t9303.png\r\n", - "7288.png 7626.png 8957.png 9192.png\t9637.png\r\n" - ] - } - ], - "source": [ - "! ls ~/.fastai/data/mnist_tiny/train/3/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To see these images, we can use some tools from the IPython library:" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import Image, display" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's see what the training set looks like for the 3 and 7 categories:" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA2klEQVR4nGNgGLRAeN7n///+/9utgU3y6L9//x7ve/fvjQimXNff9/IcbEzS7/45YMhpfHtnAzb8BRbJ+CNiYDrjHxZJNk4wpfni32I2HC7m3PzvjjRWGT3Xrmv//jlhk+KZ8OsfCOxVwCLZ9u/r0lrTgCf/yrEZGqgEoiL/vebC4SAGBoHH/3xwSjLM/7cPt6Tuvy/yOCWl/v1zxSlZ9++jELoYC9SNPHf+daPLMe85zMjAwMRptObfZ010SZe//3Zs3LgPGEJ/QjGt8v0ACrvLj5Y74nQN1QAAP0VaWbYzqAQAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA8UlEQVR4nGNgGJzA3Nra6+/fv/8XWVuroMsFffwNBn+B+LgumtyT3wjJ32ekUMwE6Xt0ZbqQkP2VK7d+/1ZFllQ5vv3LVWsopxhNkkFXNhIml/sFXRIOWPPe//6cz4ZFRtLPr/z37/fZ2HRxrwa79mUIppTPoeNQrzw9JIsumQwMn7uHjmS2H7r59621NKpk0u/pbXZglum537+LUSXlfHhgTIOHvy9qYPcNEFz7/dsSRUBNFY9k0n5xGDPxLbpk1OfbM0VAwOgaUK6NE9WinPewKAPGUAC6M5LmwiQ/YMgxMAhZWqYvOHDH0tIUpz+oAwC9BpCwP7H6swAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA6klEQVR4nGNgGLzAuLDw/N//f++lokvIlj58+O4PEPz98+fnQzTJUIg4lMhHlfT59ufPh/tFISEh3UDJOjSt5X/W2sPNwOWqDX//fujBKiMcuhhoZzI2KcttF8EOqpTE1JUNd+1ZAXTJlUheOc2PJrkKGDh/N/XY9zz9+/f/CjRJpWt//+yyADJEN/75+9kIVVItwsKcB25BK7qdUAb7JqCkObqkP4TRDnTVGVTfWP79ewBkKjCEgA7KQtXI1vTn79bQ1Idgr3gzo7lWFu7Pr2Xy6IHAtRAi+el+JboUCBS8BUru88ImRV0AABG0pfAQeL/bAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA4ElEQVR4nGNgGHDQNvHf/393lJmwSNlP/PcXDFSwSMb9+ffr5kcckgyBfT7sDbgkgaAGKLeYC7uc2fO/f4/xYJfjevn37wF7rFJaSXf//n2ti0VGIe/qh79ArzySx5STmw/yIMif82QxJDf++/fv547qA8AQcgJyHVAkpfr25NoxMEgCtW4Bck2wuQkmiRVkASVTUETspGAs5tV//24VRJH81wdjdf/9+x7Nun8/94RJOIWFdZ779/ejP5pFIN89+Qr257E2dFdEnIfE8d+TE+0w3cge3gIEMtxsuDxBPwAAMXt8orqc7JQAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAuUlEQVR4nGNgGKqAqfDfv///WjmwyTEW/AWDLGySy4ASG4Ku/t2JRS7g999PKfwMhX+/OWFKuv06oA6kCv8+FcCiVYYXSGg8/luO08VJf/9m4JLjuPl3CS45roV/r7NgERddsrHA//Df3ezYNEVCQgC7hfwT583rdp23mROnWxkYrvrgkzzOjEfyLytOOc/3L7B5BQS4Y9/+zcchZ3Xp799urKaqTLv97u0MOzas2o7/7XHlw+1QEgEAuwlLnI31qloAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA00lEQVR4nGNgGJRAqnD//79/3xphlbT88+fvnz9/3i62xCKpc/jwEbcUoIqXS42xmy0csvDtnz+fonHZbQSU/eOP02nH/v79L41VxiCs+RvQYiySG44efQxy8p9WNkzJh3/A/vk5EZuZkyCS93G5xv/A379/1+GS5dkK1L6YE4es8EbsroUA409YJP1h4bLyz98sdMleWLjI/v2/Al0y7u+TRDDD58/f5RiWWTx/f7S84ujRV3/+WmE6peoZJMb/fJDA4lDJgr37CvYWFNjj8gm1AAB9dnOy21nUyQAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA50lEQVR4nGNgGJwgraNDPLSj4/Hxf/8/duihynEc+4sEnhiiSLb+RQGPkWVtXoKErl7ftq1rjfM6IHMGkuSsFfpAICoG5kwBSloiSQpxIdhLP/79e0sEq6uZlwH1/bHAKme+Ayj3swSbFHvtC6Dc0zIsUkx1+0Bu/qqARU7xAMSPv7faY0pmw4PgWwZWyce9vfuB1A8DDCvLawxZgH6p//H37xomrH5hgISQIS5Jd6BkEw45lj6gpDKqWN5JqCsmAOUeSaDI5X7/+yoGSKtdAHnGFVVjGjDg/rx9+/YzSG65DC73UAcAAI7mnZmOJtcJAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA6klEQVR4nGNgGGjAKlH2+f/fZmxS2pab/rw+d/7NYyNMuZRv37en6DAwNP7ZyY4mpXb+yyUtMEvu8R8xNMnpfy7BhJoxJBd914Ix3f52oklaO8OZbn/QJZEAXsmCPwm4JXdgOAgC1LrCJFb9Pc0NF5guiGzdn79/LlghBP7GINjCi7b//ZOCZNT8U5LIJpf+ua2K4IX9OSuKJMlc+kcXweM++PcyL5Js3l89JJ7gnj+lCMdLbULWCXTG7T/nLKFsh1V/ViGbw8CgeuDvl/OFEy6cP3/+x981qHJAexXn/QF58c+Jyd4cDAMJALQqXDBHGWEfAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAwUlEQVR4nGNgGEAgFhw8f+XVqw2C2CTP/YOA59hk5/17t3Xr1k///h3CIslSJQwkJU79+xuI02rNf/8m4ZRs+/cvEZec+a9/z9mwynCbFnz4968Nu7Y1IK884cAuuQwk+asduyRn5urzQNlYXA7icH/z7yYuSQYGv3+/7HBKyv/7Nw2f5BYsolLMIMrp37+JGHIGj/5NluTjc77575sGhmT8v3///4FxB6apWl8gkn+xyAEjqyKo/8OKObo4nUofAACkGGFaoVnXtwAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAz0lEQVR4nM2RIReCMBSF+RFkrVCH2f/gqp2qVI2arawTxUyFTLVjBOqMbLiHyg7vHZrBu7Bzds/HfffhOP8pASq00qoVPvK46uyRG+S2hnnKRwm3VuflxFwwxjzPNfcW6JqTYH8VRALIXpHcoxxz75hb34Y8OJmLvKT6cs0Oc1yPXBuQafaxUT6wOTE/H6iApUXeclPDVnggC5stpXOmIwyLnuxOoC8y5SGEJD/MyIaiole2aTkZaPI/1RUNm0hLXkgRj7E4TrumPrHZGr/SC2Yysve3/OfsAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAxElEQVR4nGNgGJJA4l8GO4TlNoEXXZJ5379tsSCG4JW/hRhaU7/+/Xl+asn+B/9eSGIarHP6799/f4HYE5u1grH1O4/++5eG012T/77BKWf58zema2Ag4++72FjrWGslTCmFjv///v0D4Z2caFK8RR+Brr1+rrjYUxxdjmHi3y9//y3BEIaAheUNf5/w43CMEu/dfztxOjXx798QnJKT/27EKcfw7O8CnHK6X/+54pSs+LuVDafk6b8JuK3891cPtySJAACJW1LwQ3vd7gAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA2klEQVR4nGNgGIZA7tltRQiLPyHBFE0y6t/fJAXLgkn79v389/cOF4qcwrl/f4EASmxBlYwEi7+8tLdOU/7f3zRUG1/8XSIgIMDNCmQf/3efA0XS798/byhT4sv/ThQ5iXt/D0KZbLv+vhBAdc7fj85Q5oy/f81R/aGeD/UjS+v3v/0MOIDty79X2XDIKT/799sch5zQqn9/O3DIcS7++2+bBA7J2L9/D3PgkAv4+veJMg45lWv//kXhkOPa+/dvOwsOybZ/f9tw+bDy9792XHLmN/5+weUJ7AAAEiNg+iSCKdoAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAuElEQVR4nGNgGK5g3n91BgY9PSwyTEarvvyzn3zty1dFTEmjv3///vsLItTRpQTsnsAkdzCjybncBIq/nd3qdP/vX3F0jZ3//v9cysHAoPzg30EMC70urzMC0Yv+vsLmWDBw//h3Ei45hot/Lwngkiv697cTlxzXxf/rcBq6/O/PCFxykh/+LsWpsenv32BccgKv/17HqTHg378EXHIyN//+MsMlGfn3bwlOGy/+/YAzcJLwBA42AAAadFU7QTVI2gAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAhklEQVR4nGNgGH6AidUjMtIjYfX3l+poMox+Gy7/A4K/v//+e8aNJun7/++nDeXe3jaaAe93o5tpW+EAZVn/w5BEAOt/M3FLVv/TxC15/rsQbslHB3DLkS/J9RyPpPk/vJKT8ElG4pPUwy2Z+S8Xt2QXPsnF/0JwS957I4hTTvDlEdwa0QAA+hI1MRkxgA8AAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAuklEQVR4nGNgGH7g8/4dO2rttbW1q3pZ0eVYzv8Dgv8g4p8MumT4vySLjGXH1k5a8O+rGLrkyneCEIbFvx0YVl55wAFhlP/rxZA8eAfqjL5/B9HlXH/+kQYzDH78g1kAB0Yv06Gspn/T2NG18rBAaLVvj1gw7ISBxH+LccoxRP4rxCnHuO5fJE5Jo38PRHFKVv5rwG3l7n+ZOOU4nl/F7RHvf6twm/rvOUZcwoHBv724NTb9W4lbEh0AACiJRD8v4XXFAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAoUlEQVR4nGNgGIaAQ7TTTkhIqP7vGnZMyZp/MBCJIRf2FSj86eTJh9gkLwDl2owYGIr+fXPAIvknWYgBJPkQ08p5/36C6aJ/6zElWZY1g+nH/7Jxeojz1Q99nJKr/n3GKcdw7d91nHI2X//V4JT0+/9PAqfkrn/TGXHJWf/914vbyn//PPFJiuOUjP63E0tkQsGmf/NxyuGXrPlniFsSDQAAc7JKpClSdBQAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA1ElEQVR4nGNgGNqAIyQap5zP4n9v5FCFMr4uB5KK9v1f//77dx9N/fR/X/fs2fP939/VEb//TUKT7PkHBG82J4swGP/56ogmyV+yNdNPAsRa828Zbsee/jcfj+QXfTAthSrMzMDMxBb97blz9baF11Y/uwaXKJ4zZ87ROUe3/IOA86eAAC55/d//fyAEBMdmp5qwoRjp6G7AGqVswyr9750hTufk/avA7dYL/0xwyul+xi3JMfffeTZckgL//p3CJQeSLMQpyXb8twpOSQYLO9xyJAEAjgNg8t+T8AgAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAo0lEQVR4nGNgGH7AcPX/DTgl5/39++fHj1tlKljk5v75CwFf7xZoo0u+BorXV09dC5JPRJfc8ffvRlYGBjbJ1r9/r6FLZv79uwLMYNvy9zG6pMALqCTDyr9vlNFloz/bwiT/ZmC4V5cDTHm9+ftCFIt3wGDDX0w7kSUbcclxH8DiTxgw/fv3mRweyRM4rdT7/DcapyTbjp+BOCVNMUOW5pIoAAA77VVfXHcKRQAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAn0lEQVR4nGNgGJrA4/HeUHlXaSasktpX/4HAhVXx2GQ5xDUTdBs3/1uE23SBf3m4JS3wScb908AtufwBJ27JXauxCHLvW54fETFh+79ZEeH66JIc9ff/fX7X825deLiNOqZeXjVpSe+fEbhtrPjNh1OO7c4s3BrN/8Xhllx+ghennNz3Htwa7X774ZRjWXkVt0blf8txS0oemYBbkjQAABnLM4hoOje3AAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAAvElEQVR4nGNgGImATbi1dc6/f9eCMaW42o7++wsGc9ClZPwO/f3779fNm48wJLnaX4G0fPNh4Er6+7cVRY5zNlDmwbE2VwYGv79/D3ChSvZsibBRYAOy7F/9XayBw72ce/8u5sEhx33372UuHHIMjn/fWeOSs/75yQKXnMPPnya45Lhe/F2IS8700N9NuOQYlv19YYhLLujDM5wWCl1+aoZLTrDubwNOCw3/TmDHJSdw+LESTo0znmljEQUA6ZBPtyGAQIYAAAAASUVORK5CYII=\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "dirname = os.path.dirname(path)\n", - "for group in [\"mnist_tiny/train/3/*.png\", \n", - " \"mnist_tiny/train/7/*.png\"]:\n", - " for filename in glob.glob(os.path.join(dirname, group)):\n", - " display(Image(filename))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So, all of the files under `mnist_tiny/train/3/` are pictures of 3's, and `mnist_tiny/train/7/` are pictures of 7's.\n", - "\n", - "Now we get the image data from the folder. To train a dataset in fastai, we must create a `DataBunch`. In this case, we can use `ImageDataBunch` in the `fastai.vision` library. We pick 10 as the batch size (`bs`) because there are only 10 images in each category." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "data = fastai.vision.ImageDataBunch.from_folder(path, bs=10) # bs: batch size" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's better for this simple test. Now we can create a model, and train the network:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Model\n", - "\n", - "In this example, we will use the pre-designed WideresNet from fastai. The model is also known as wrn_22." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "model = fastai.vision.models.WideResNet(num_groups=3,\n", - " N=3,\n", - " num_classes=10,\n", - " k=6,\n", - " drop_p=0.)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's it! Often, you would probably build your own model, or adjust a default model. To see more on model building in fastai, see:\n", - "\n", - "* http://files.fast.ai/models/\n", - "* http://course.fast.ai/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Experiment" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In order for comet.ml to log your experiment and results, you need to create an Experiment instance. To do this, you'll need two items:\n", - "\n", - "* a Comet `api_key`\n", - "* a `project_name`\n", - "\n", - "You can find your Comet api_key when you log in to https://www.comet.ml and click on your project. You should see a screen that looks similar to:\n", - "\n", - "![comet login screen](comet-key.png)\n", - "\n", - "Click on the API key to copy the key to your clipboard. \n", - "\n", - "It is recommended that you put your COMET_API_KEY in a `.env` key in the current directory. You can do that using the following code. Put it in a cell, replace the `...` with your key, and then delete the cell. That way your key stays private.\n", - "\n", - "```ipython\n", - "%%writefile .env\n", - "\n", - "COMET_API_KEY=...\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It is also recommended that you use your project_name in the cell, so you can match the results with this code. You can make up a new name, or add this experiment to a project that already exists." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "COMET INFO: Experiment is live on comet.ml https://www.comet.ml/cometpublic/comet-notebooks/d21f94a1c71841d2961da1e6ddb5ab20\n", - "\n" - ] - } - ], - "source": [ - "experiment = Experiment(project_name=\"comet_notebooks\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you get the error that ends with:\n", - "\n", - "
\n",
-    "ValueError: Comet.ml requires an API key. Please provide as the first argument to Experiment(api_key) or as an environment variable named COMET_API_KEY \n",
-    "
\n", - "\n", - "then that means that either you don't have an `.env` file in this directory, or the key is invalid.\n", - "\n", - "Otherwise, you should see the message:\n", - "\n", - "
\n",
-    "COMET INFO: Experiment is live on comet.ml https://www.comet.ml/...\n",
-    "
\n", - "\n", - "If you click the URL, then a new page will open up. But, even better, you can execute the following line to see the experiment in the current notebook:" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "experiment.display()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "By the way, the line `experiment.display()` works when you are at the console too. It will open up a window in your browser.\n", - "\n", - "Now, we are ready for training!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 5. Training\n", - "\n", - "In fastai, we can train differently depending on if we are running CPU or a GPU. To test, we can use the `data.device.type` property. This will create a fastai `Learner`:" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "if data.device.type == 'cpu':\n", - " learn = fastai.basic_train.Learner(data, model, metrics=fastai.metrics.accuracy)\n", - "else: # GPU:\n", - " learn = fastai.basic_train.Learner(data, model, metrics=fastai.metrics.accuracy).to_fp16()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we are ready to train the model. To tell Comet about the details, we put the call to `fit` or `fit_one_cylce` inside an indented block under `experiment.train()`:" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total time: 00:10\n", - "epoch train_loss valid_loss accuracy\n", - "1 2.331475 2.306675 0.000000 (00:05)\n", - "2 1.933559 2.272467 0.000000 (00:05)\n", - "\n" - ] - } - ], - "source": [ - "with experiment.train():\n", - " learn.fit_one_cycle(2, 3e-3, wd=0.4, div_factor=10, pct_start=0.5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 6. Logging" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In fastai, Comet will automatically log:\n", - "\n", - "* the model description\n", - "* the training loss\n", - "* the training validation\n", - "* the source code\n", - "\n", - "To log other items manually, you can use any of the following:\n", - "\n", - "* `experiment.log_html(HTML_STRING)`\n", - "* `experiment.html_log_url(URL_STRING)`\n", - "* `experiment.image(FILENAME)`\n", - "* `experiment.log_dataset_hash(DATASET)`\n", - "* `experiment.log_other(KEY, VALUE)`\n", - "* `experiment.log_metric(NAME, VALUE)`\n", - "* `experiment.log_parameter(PARAMETER, VALUE)`\n", - "* `experiment.log_figure(NAME, FIGURE)`\n", - "\n", - "For complete details, please see: \n", - "\n", - "https://www.comet.ml/docs/python-sdk/Experiment/#experiment" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 7. Finish" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finall, we are ready to tell Comet that our experiment is complete. You don't need to do this is a script that ends. But in Jupyter, we need to indicate that the experiment is finished. We do that with the `experiment.end()` method:" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "COMET INFO: Uploading stats to Comet before program termination (may take several seconds)\n", - "COMET INFO: Experiment is live on comet.ml https://www.comet.ml/cometpublic/comet-notebooks/d21f94a1c71841d2961da1e6ddb5ab20\n", - "\n" - ] - } - ], - "source": [ - "experiment.end()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's it! If you have any questions, please visit us on https://cometml.slack.com" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.6.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From a2c7da43c56f9f0f173ff12608f9e7e6edb291a1 Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Mon, 15 Jan 2024 16:47:12 +0100 Subject: [PATCH 2/3] Update text and add Readme --- .../fastai/fastai-hello-world/README.md | 30 ++ .../fastai-hello-world/fastai_hello_world.py | 3 +- .../fastai/notebooks/fastai_hello_world.ipynb | 432 +++--------------- 3 files changed, 82 insertions(+), 383 deletions(-) diff --git a/integrations/model-training/fastai/fastai-hello-world/README.md b/integrations/model-training/fastai/fastai-hello-world/README.md index e69de29b..d9a4c15a 100644 --- a/integrations/model-training/fastai/fastai-hello-world/README.md +++ b/integrations/model-training/fastai/fastai-hello-world/README.md @@ -0,0 +1,30 @@ +# FastAI integration with Comet.ml + +[fastai](https://github.com/fastai/fastai) is a deep learning library which provides practitioners with high-level components that can quickly and easily provide state-of-the-art results in standard deep learning domains, and provides researchers with low-level components that can be mixed and matched to build new approaches. + +Instrument fastai with Comet to start managing experiments, create dataset versions and track hyperparameters for faster and easier reproducibility and collaboration. + +## Documentation + +For more information on using and configuring the fastai integration, see: [https://www.comet.com/docs/v2/integrations/ml-frameworks/fastai/](https://www.comet.com/docs/v2/integrations/ml-frameworks/fastai/?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai) + +## See it + +Take a look at this [public Comet Project](https://www.comet.com/examples/comet-examples-fastai-hello-world/view/new/panels?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai). + +## Setup + +Install dependencies + +```bash +python -m pip install -r requirements.txt +``` + +## Run the example + +This example is fine-tuning a pre-trained resnet 28 model on the Mnist Tiny dataset for 5 epochs: + + +```bash +python fastai-hello-world.py +``` diff --git a/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py b/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py index 2ccd4e34..0cf64ed4 100644 --- a/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py +++ b/integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py @@ -34,7 +34,6 @@ learn = vision_learner(dls, resnet18, pretrained=True, metrics=error_rate) -with experiment.train(): - learn.fit_one_cycle(EPOCHS) +learn.fit_one_cycle(EPOCHS) experiment.end() diff --git a/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb b/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb index 2a0f5e1e..47619542 100644 --- a/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb +++ b/integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb @@ -6,40 +6,34 @@ "id": "8LE43szDmKdp" }, "source": [ - "\n", - "\n", - "# MNIST Example in fastai\n", - "\n", - "This Jupyter notebook demonstrates using the **fastai** (version 1.0.38) deep learning framework with [comet.ml](https://www.comet.ml).\n", - "\n", - "In this example, we load a fastai model, called WideResNet, and train it on a small part of the MNIST_TINY dataset.\n", - "\n", - "fastai is a framework built on top of the torch Python library.\n", - "\n", - "To find out more, you might find these links helpful:\n", - "\n", - "* http://www.fast.ai/\n", - "* http://docs.fast.ai/\n", - "* http://www.fast.ai/2018/08/10/fastai-diu-imagenet/\n", - "* https://en.wikipedia.org/wiki/MNIST_database\n", - "* http://jupyter.org/\n", - "\n", - "Let's get started!\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[Comet](https://www.comet.com/site/products/ml-experiment-tracking/?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai) is an MLOps Platform that is designed to help Data Scientists and Teams build better models faster! Comet provides tooling to track, Explain, Manage, and Monitor your models in a single place! It works with Jupyter Notebooks and Scripts and most importantly it's 100% free to get started!\n", "\n", - "# 0. Installation\n", + "[fastai](https://github.com/fastai/fastai) is a deep learning library which provides practitioners with high-level components that can quickly and easily provide state-of-the-art results in standard deep learning domains, and provides researchers with low-level components that can be mixed and matched to build new approaches.\n", "\n", - "This example uses fastai version 1.0.38. You can install a specific version of fastai (which should also install the correct version of torch) with this command at the terminal:\n", + "[Find more information about our integration with FastAI](https://www.comet.ml/docs/v2/integrations/ml-frameworks/fastai/?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai)\n", "\n", - "```\n", - "python -m pip install fastai==1.0.38\n", - "```\n", + "Curious about how Comet can help you build better models, faster? Find out more about [Comet](https://www.comet.com/site/products/ml-experiment-tracking/?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai) and our [other integrations](https://www.comet.com/docs/v2/integrations/overview/?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai)\n", "\n", - "Once you have fastai and torch installed, we are ready to import them." + "Get a preview for what's to come. Check out a completed experiment created from this notebook [here](https://www.comet.com/examples/comet-examples-fastai-hello-world-notebook/95862aa394984c748750ac491e02b83a?utm_source=comet-examples&utm_medium=referral&utm_campaign=github_repo_2023&utm_content=fastai)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 0. Installation" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -47,123 +41,7 @@ "id": "xiNzBttOmKdr", "outputId": "7929b2f0-5961-4f11-92cd-35fc6f8a5acd" }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Requirement already satisfied: fastai in /usr/local/lib/python3.10/dist-packages (2.7.13)\n", - "Collecting comet_ml\n", - " Downloading comet_ml-3.35.3-py3-none-any.whl (586 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m586.4/586.4 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: pip in /usr/local/lib/python3.10/dist-packages (from fastai) (23.1.2)\n", - "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from fastai) (23.2)\n", - "Requirement already satisfied: fastdownload<2,>=0.0.5 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.0.7)\n", - "Requirement already satisfied: fastcore<1.6,>=1.5.29 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.5.29)\n", - "Requirement already satisfied: torchvision>=0.11 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.16.0+cu118)\n", - "Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from fastai) (3.7.1)\n", - "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from fastai) (1.5.3)\n", - "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from fastai) (2.31.0)\n", - "Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from fastai) (6.0.1)\n", - "Requirement already satisfied: fastprogress>=0.2.4 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.0.3)\n", - "Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from fastai) (9.4.0)\n", - "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from fastai) (1.2.2)\n", - "Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from fastai) (1.11.3)\n", - "Requirement already satisfied: spacy<4 in /usr/local/lib/python3.10/dist-packages (from fastai) (3.6.1)\n", - "Requirement already satisfied: torch<2.2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from fastai) (2.1.0+cu118)\n", - "Requirement already satisfied: jsonschema!=3.1.0,>=2.6.0 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (4.19.2)\n", - "Requirement already satisfied: psutil>=5.6.3 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (5.9.5)\n", - "Collecting python-box<7.0.0 (from comet_ml)\n", - " Downloading python_box-6.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m11.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting requests-toolbelt>=0.8.0 (from comet_ml)\n", - " Downloading requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m54.5/54.5 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting semantic-version>=2.8.0 (from comet_ml)\n", - " Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", - "Collecting sentry-sdk>=1.1.0 (from comet_ml)\n", - " Downloading sentry_sdk-1.36.0-py2.py3-none-any.whl (249 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m249.2/249.2 kB\u001b[0m \u001b[31m17.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting simplejson (from comet_ml)\n", - " Downloading simplejson-3.19.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.9/137.9 kB\u001b[0m \u001b[31m14.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from comet_ml) (1.16.0)\n", - "Requirement already satisfied: urllib3>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (2.0.7)\n", - "Collecting websocket-client<1.4.0,>=0.55.0 (from comet_ml)\n", - " Downloading websocket_client-1.3.3-py3-none-any.whl (54 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m54.3/54.3 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: wrapt>=1.11.2 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (1.14.1)\n", - "Collecting wurlitzer>=1.0.2 (from comet_ml)\n", - " Downloading wurlitzer-3.0.3-py3-none-any.whl (7.3 kB)\n", - "Collecting everett[ini]<3.2.0,>=1.0.1 (from comet_ml)\n", - " Downloading everett-3.1.0-py2.py3-none-any.whl (35 kB)\n", - "Collecting dulwich!=0.20.33,>=0.20.6 (from comet_ml)\n", - " Downloading dulwich-0.21.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (512 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m512.2/512.2 kB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: rich>=13.3.2 in /usr/local/lib/python3.10/dist-packages (from comet_ml) (13.7.0)\n", - "Collecting configobj (from everett[ini]<3.2.0,>=1.0.1->comet_ml)\n", - " Downloading configobj-5.0.8-py2.py3-none-any.whl (36 kB)\n", - "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (23.1.0)\n", - "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (2023.11.1)\n", - "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (0.31.0)\n", - "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema!=3.1.0,>=2.6.0->comet_ml) (0.12.0)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.3.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (2023.7.22)\n", - "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13.3.2->comet_ml) (3.0.0)\n", - "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13.3.2->comet_ml) (2.16.1)\n", - "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.12)\n", - "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.5)\n", - "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.10)\n", - "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.8)\n", - "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.9)\n", - "Requirement already satisfied: thinc<8.2.0,>=8.1.8 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (8.1.12)\n", - "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.1.2)\n", - "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.4.8)\n", - "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.10)\n", - "Requirement already satisfied: typer<0.10.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.9.0)\n", - "Requirement already satisfied: pathy>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.10.3)\n", - "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (6.4.0)\n", - "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (4.66.1)\n", - "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.23.5)\n", - "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.10.13)\n", - "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.1.2)\n", - "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (67.7.2)\n", - "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.3.0)\n", - "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.13.1)\n", - "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (4.5.0)\n", - "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (1.12)\n", - "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.2.1)\n", - "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2023.6.0)\n", - "Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2.1.0)\n", - "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.2.0)\n", - "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (0.12.1)\n", - "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (4.44.3)\n", - "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.4.5)\n", - "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (3.1.1)\n", - "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (2.8.2)\n", - "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->fastai) (2023.3.post1)\n", - "Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (1.3.2)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (3.2.0)\n", - "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=13.3.2->comet_ml) (0.1.2)\n", - "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /usr/local/lib/python3.10/dist-packages (from thinc<8.2.0,>=8.1.8->spacy<4->fastai) (0.7.11)\n", - "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from thinc<8.2.0,>=8.1.8->spacy<4->fastai) (0.1.3)\n", - "Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.10/dist-packages (from typer<0.10.0,>=0.3.0->spacy<4->fastai) (8.1.7)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->spacy<4->fastai) (2.1.3)\n", - "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch<2.2,>=1.10->fastai) (1.3.0)\n", - "Installing collected packages: everett, wurlitzer, websocket-client, simplejson, sentry-sdk, semantic-version, python-box, dulwich, configobj, requests-toolbelt, comet_ml\n", - " Attempting uninstall: websocket-client\n", - " Found existing installation: websocket-client 1.6.4\n", - " Uninstalling websocket-client-1.6.4:\n", - " Successfully uninstalled websocket-client-1.6.4\n", - " Attempting uninstall: python-box\n", - " Found existing installation: python-box 7.1.1\n", - " Uninstalling python-box-7.1.1:\n", - " Successfully uninstalled python-box-7.1.1\n", - "Successfully installed comet_ml-3.35.3 configobj-5.0.8 dulwich-0.21.6 everett-3.1.0 python-box-6.1.0 requests-toolbelt-1.0.0 semantic-version-2.10.0 sentry-sdk-1.36.0 simplejson-3.19.2 websocket-client-1.3.3 wurlitzer-3.0.3\n" - ] - } - ], + "outputs": [], "source": [ "%pip install -U fastai comet_ml" ] @@ -181,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "id": "62Tk_v45mKdu" }, @@ -195,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "id": "vnNnawcJmKdv" }, @@ -210,12 +88,12 @@ "id": "rBpIQV3hmKdv" }, "source": [ - "# 3. Comet Experiment" + "# 2. Comet Experiment" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -223,31 +101,10 @@ "id": "ucE282OimKdw", "outputId": "be595e74-99b0-4068-e043-259e5aef96a8" }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Please paste your Comet API key from https://www.comet.com/api/my/settings/\n", - "(api key may not show as you type)\n", - "Comet API key: ··········\n" - ] - }, - { - "output_type": "stream", - "name": "stderr", - "text": [ - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Valid Comet API Key saved in /root/.comet.config (set COMET_CONFIG to change where it is saved).\n", - "\u001b[1;38;5;214mCOMET WARNING:\u001b[0m As you are running in a Jupyter environment, you will need to call `experiment.end()` when finished to ensure all metrics and code are logged before exiting.\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Couldn't find a Git repository in '/content' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Experiment is live on comet.com https://www.comet.com/lothiraldan-old/comet-examples-fastai-hello-world/60114263260d4cb491c30e4c45730b82\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "# Create Comet Experiment\n", - "comet_ml.init(project_name=\"comet-examples-fastai-hello-world\")\n", + "comet_ml.init(project_name=\"comet-examples-fastai-hello-world-notebook\")\n", "experiment = comet_ml.Experiment()" ] }, @@ -257,7 +114,7 @@ "id": "9dDHu5wkmKdw" }, "source": [ - "## 2. Dataset" + "# 3. Dataset" ] }, { @@ -271,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -280,52 +137,7 @@ "id": "sUpCpfH7mKdx", "outputId": "cabd445c-4102-4872-c16e-c9af435a83db" }, - "outputs": [ - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "\n", - "\n" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "\n", - "
\n", - " \n", - " 100.54% [344064/342207 00:00<00:00]\n", - "
\n", - " " - ] - }, - "metadata": {} - } - ], + "outputs": [], "source": [ "path = untar_data(URLs.MNIST_TINY)" ] @@ -336,12 +148,12 @@ "id": "Giiv4pnymKdy" }, "source": [ - "The path returned by the untar_data function shows where the data was saved. Using the shell `!` magic, we can explore the dataset in more detail:" + "The path returned by the untar_data function shows where the data was saved." ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -349,16 +161,7 @@ "id": "h9Qa5t3fmKdz", "outputId": "a9d364d4-ad84-4f25-82c3-ec585d884ea6" }, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "/usr/local/lib/python3.10/dist-packages/fastai/torch_core.py:263: UserWarning: 'has_mps' is deprecated, please use 'torch.backends.mps.is_built()'\n", - " return getattr(torch, 'has_mps', False)\n" - ] - } - ], + "outputs": [], "source": [ "items = get_image_files(path)\n", "tds = Datasets(\n", @@ -375,14 +178,14 @@ "id": "8eEbaCh6mKd0" }, "source": [ - "## 3. Model\n", + "# 4. Model\n", "\n", - "In this example, we will use the pre-designed WideresNet from fastai. The model is also known as wrn_22." + "In this example, we will use the pre-designed Resnet18 from fastai." ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -390,32 +193,11 @@ "id": "R8JJhlrumKd0", "outputId": "f7b63acc-c55c-4367-8dd7-3d934739215c" }, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "Downloading: \"https://download.pytorch.org/models/resnet18-f37072fd.pth\" to /root/.cache/torch/hub/checkpoints/resnet18-f37072fd.pth\n", - "100%|██████████| 44.7M/44.7M [00:00<00:00, 107MB/s]\n" - ] - } - ], + "outputs": [], "source": [ "learn = vision_learner(dls, resnet18, pretrained=True, metrics=error_rate)" ] }, - { - "cell_type": "markdown", - "metadata": { - "id": "A-0Pft9GmKd1" - }, - "source": [ - "That's it! Often, you would probably build your own model, or adjust a default model. To see more on model building in fastai, see:\n", - "\n", - "* http://files.fast.ai/models/\n", - "* http://course.fast.ai/" - ] - }, { "cell_type": "markdown", "metadata": { @@ -433,12 +215,12 @@ "id": "GyIBFMOZmKd3" }, "source": [ - "Now we are ready to train the model. To tell Comet about the details, we put the call to `fit` or `fit_one_cylce` inside an indented block under `experiment.train()`:" + "Now we are ready to train the model. To tell Comet about the details, we put the call to `fit` or `fit_one_cylce`:" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -447,97 +229,9 @@ "id": "uNzBOFIUmKd3", "outputId": "174f0f33-1dcc-42e4-e610-d449545d8080" }, - "outputs": [ - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "\n", - "\n" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
epochtrain_lossvalid_losserror_ratetime
01.1180090.5184350.29327600:07
10.7340610.3038410.13733900:08
20.5380980.2239630.08869800:07
30.4187930.1972360.07725300:08
40.3423830.1738150.07439200:07
" - ] - }, - "metadata": {} - } - ], + "outputs": [], "source": [ - "with experiment.train():\n", - " learn.fit_one_cycle(EPOCHS)" + "learn.fit_one_cycle(EPOCHS)" ] }, { @@ -546,7 +240,7 @@ "id": "hKIrsCOGmKd3" }, "source": [ - "## 7. Finish" + "# 6. Finish" ] }, { @@ -560,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -568,31 +262,7 @@ "id": "HDteaKMtmKd3", "outputId": "3b9c0829-97d0-4521-ca34-b99fedd90866" }, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Comet.ml Experiment Summary\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Data:\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m display_summary_level : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m url : https://www.comet.com/lothiraldan-old/comet-examples-fastai-hello-world/60114263260d4cb491c30e4c45730b82\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Metrics [count] (min, max):\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m train_loss [11] : (0.07387722283601761, 1.4785162210464478)\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Uploads:\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m environment details : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m filename : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m installed packages : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m model graph : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m notebook : 2\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m os packages : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m source_code : 1\n", - "\u001b[1;38;5;39mCOMET INFO:\u001b[0m \n" - ] - } - ], + "outputs": [], "source": [ "experiment.end()" ] @@ -608,8 +278,11 @@ } ], "metadata": { + "colab": { + "provenance": [] + }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -623,12 +296,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" - }, - "colab": { - "provenance": [] + "version": "3.10.12" } }, "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file + "nbformat_minor": 4 +} From eea291cbe221a14208a9d8cc5d503bae973e64e4 Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Mon, 15 Jan 2024 16:51:13 +0100 Subject: [PATCH 3/3] Add fastai to the test build --- .github/workflows/test-examples.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index c99e5c27..2b0857f0 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -21,6 +21,7 @@ jobs: - integrations/model-evaluation/gradio/notebooks/Gradio_and_Comet.ipynb - integrations/model-evaluation/gradio/notebooks/Logging_Model_Inferences_with_Comet_and_Gradio.ipynb - integrations/model-optimization/ray-tune/notebooks/Comet_and_Ray.ipynb + - integrations/model-training/fastai/notebooks/fastai_hello_world.ipynb - integrations/model-training/hugging_face/notebooks/Comet_with_Hugging_Face_Trainer.ipynb - integrations/model-training/keras/notebooks/Comet_with_Keras.ipynb - integrations/model-training/lightgbm/notebooks/Comet_and_LightGBM.ipynb @@ -99,6 +100,8 @@ jobs: os: [ubuntu-latest] python-version: ["3.10"] example: + - {script: "integrations/model-optimization/optuna/optuna-hello-world/optuna-hello-world.py", arg: ""} + - {script: "integrations/model-training/fastai/fastai-hello-world/fastai_hello_world.py", arg: ""} - {script: "integrations/model-training/hugging_face/transformers-distilbert-fine-tuning/transformers-distilbert-fine-tuning.py", arg: ""} - {script: "integrations/model-training/keras/keras-mnist-dnn/keras-mnist-dnn.py", arg: ""} - {script: "integrations/model-training/mlflow/mlflow-hello-world/mlflow-hello-world.py", arg: "run"} @@ -112,7 +115,6 @@ jobs: - {script: "integrations/workflow-orchestration/metaflow/metaflow-hello-world/helloworld.py", arg: "run"} - {script: "integrations/workflow-orchestration/metaflow/metaflow-model-evaluation/metaflow-model-evaluation.py", arg: "run --max-workers 1 --n_samples 100"} - {script: "integrations/workflow-orchestration/metaflow/metaflow-regression/metaflow-regression-example.py", arg: "run"} - - {script: "integrations/model-optimization/optuna/optuna-hello-world/optuna-hello-world.py", arg: ""} env: SCRIPT_TO_TEST: ${{ matrix.example.script }} steps: