{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.\n", " warnings.warn(\n", "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet34_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet34_Weights.DEFAULT` to get the most up-to-date weights.\n", " warnings.warn(msg)\n" ] } ], "source": [ "#id first_training\n", "#caption Results from the first training\n", "# CLICK ME\n", "#|export\n", "from fastai.vision.all import *\n", "path = untar_data(URLs.PETS)/'images'\n", "\n", "def is_cat(x): return x[0].isupper()\n", "dls = ImageDataLoaders.from_name_func(\n", " path, get_image_files(path), \n", " valid_pct=0.2, \n", " seed=42,\n", " label_func=is_cat, \n", " item_tfms=Resize(224)\n", ")\n", "\n", "learn = vision_learner(dls, resnet34, metrics=error_rate)\n", "learn.fine_tune(1)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7714f88d5b1a4e198c60d4303a7dbf50", "version_major": 2, "version_minor": 0 }, "text/plain": [ "FileUpload(value=(), description='Upload')" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "\n", "from ipywidgets import widgets\n", "from IPython.display import display\n", "uploader = widgets.FileUpload()\n", "display(uploader)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "#|export\n", "# For the book, we can't actually click an upload button, so we fake it\n", "uploader = SimpleNamespace(data = ['../data/interim/th-1.webp'])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "