{"id":34553349,"url":"https://github.com/fastai/timmdocs","last_synced_at":"2025-12-24T08:18:17.440Z","repository":{"id":38972540,"uuid":"331079471","full_name":"fastai/timmdocs","owner":"fastai","description":"Documentation for Ross Wightman's timm image model library","archived":false,"fork":false,"pushed_at":"2024-04-17T03:44:30.000Z","size":6687,"stargazers_count":310,"open_issues_count":20,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-23T15:03:33.090Z","etag":null,"topics":["deep-learning","fastai","machine-learning","pytorch"],"latest_commit_sha":null,"homepage":"https://timm.fast.ai","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-19T18:56:46.000Z","updated_at":"2025-04-14T07:56:12.000Z","dependencies_parsed_at":"2022-07-16T15:17:05.002Z","dependency_job_id":"70713877-81f4-402b-b26d-9405437df609","html_url":"https://github.com/fastai/timmdocs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fastai/timmdocs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastai%2Ftimmdocs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastai%2Ftimmdocs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastai%2Ftimmdocs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastai%2Ftimmdocs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastai","download_url":"https://codeload.github.com/fastai/timmdocs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastai%2Ftimmdocs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27998479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","fastai","machine-learning","pytorch"],"created_at":"2025-12-24T08:18:13.520Z","updated_at":"2025-12-24T08:18:17.434Z","avatar_url":"https://github.com/fastai.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n- [Pytorch Image Models (timm)](#pytorch-image-models-timm)\n  - [Install](#install)\n  - [How to use](#how-to-use)\n    - [Create a model](#create-a-model)\n    - [List Models with Pretrained Weights](#list-models-with-pretrained-weights)\n    - [Search for model architectures by Wildcard](#search-for-model-architectures-by-wildcard)\n    - [Fine-tune timm model in fastai](#fine-tune-timm-model-in-fastai)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Pytorch Image Models (timm)\n\u003e `timm` is a deep-learning library created by \u003ca href='https://twitter.com/wightmanr'\u003eRoss Wightman\u003c/a\u003e and is a collection of SOTA computer vision models, layers, utilities, optimizers, schedulers, data-loaders, augmentations and also training/validating scripts with ability to reproduce ImageNet training results. \n\n\n## Install\n\n```\npip install timm\n```\n\nOr for an editable install, \n\n```\ngit clone https://github.com/rwightman/pytorch-image-models\ncd pytorch-image-models \u0026\u0026 pip install -e .\n```\n\n## How to use\n\n### Create a model\n\n```python\nimport timm \nimport torch\n\nmodel = timm.create_model('resnet34')\nx     = torch.randn(1, 3, 224, 224)\nmodel(x).shape\n```\n\n\n\n\n    torch.Size([1, 1000])\n\n\n\nIt is that simple to create a model using `timm`. The `create_model` function is a factory method that can be used to create over 300 models that are part of the `timm` library.\n\nTo create a pretrained model, simply pass in `pretrained=True`.\n\n```python\npretrained_resnet_34 = timm.create_model('resnet34', pretrained=True)\n```\n\n    Downloading: \"https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth\" to /home/tmabraham/.cache/torch/hub/checkpoints/resnet34-43635321.pth\n\n\nTo create a model with a custom number of classes, simply pass in `num_classes=\u003cnumber_of_classes\u003e`.\n\n```python\nimport timm \nimport torch\n\nmodel = timm.create_model('resnet34', num_classes=10)\nx     = torch.randn(1, 3, 224, 224)\nmodel(x).shape\n```\n\n\n\n\n    torch.Size([1, 10])\n\n\n\n### List Models with Pretrained Weights\n\n\n`timm.list_models()` returns a complete list of available models in `timm`. To have a look at a complete list of pretrained models, pass in `pretrained=True` in `list_models`.\n\n```python\navail_pretrained_models = timm.list_models(pretrained=True)\nlen(avail_pretrained_models), avail_pretrained_models[:5]\n```\n\n\n\n\n    (592,\n     ['adv_inception_v3',\n      'bat_resnext26ts',\n      'beit_base_patch16_224',\n      'beit_base_patch16_224_in22k',\n      'beit_base_patch16_384'])\n\n\n\nThere are a total of **271** models with pretrained weights currently available in `timm`!\n\n### Search for model architectures by Wildcard\n\nIt is also possible to search for model architectures using Wildcard as below:\n\n```python\nall_densenet_models = timm.list_models('*densenet*')\nall_densenet_models\n```\n\n\n\n\n    ['densenet121',\n     'densenet121d',\n     'densenet161',\n     'densenet169',\n     'densenet201',\n     'densenet264',\n     'densenet264d_iabn',\n     'densenetblur121d',\n     'tv_densenet121']\n\n\n\n### Fine-tune timm model in fastai\n\nThe [fastai](https://docs.fast.ai) library has support for fine-tuning models from timm:\n\n```python\nfrom fastai.vision.all import *\n\npath = untar_data(URLs.PETS)/'images'\ndls = ImageDataLoaders.from_name_func(\n    path, get_image_files(path), valid_pct=0.2,\n    label_func=lambda x: x[0].isupper(), item_tfms=Resize(224))\n    \n# if a string is passed into the model argument, it will now use timm (if it is installed)\nlearn = vision_learner(dls, 'vit_tiny_patch16_224', metrics=error_rate)\n\nlearn.fine_tune(1)\n```\n\n\n\n\u003cstyle\u003e\n    /* Turns off some styling */\n    progress {\n        /* gets rid of default border in Firefox and Opera. */\n        border: none;\n        /* Needs to be in here for Safari polyfill so background images work as expected. */\n        background-size: auto;\n    }\n    .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n        background: #F44336;\n    }\n\u003c/style\u003e\n\n\n\n\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: left;\"\u003e\n      \u003cth\u003eepoch\u003c/th\u003e\n      \u003cth\u003etrain_loss\u003c/th\u003e\n      \u003cth\u003evalid_loss\u003c/th\u003e\n      \u003cth\u003eerror_rate\u003c/th\u003e\n      \u003cth\u003etime\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0.201583\u003c/td\u003e\n      \u003ctd\u003e0.024980\u003c/td\u003e\n      \u003ctd\u003e0.006766\u003c/td\u003e\n      \u003ctd\u003e00:08\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\n\n\u003cstyle\u003e\n    /* Turns off some styling */\n    progress {\n        /* gets rid of default border in Firefox and Opera. */\n        border: none;\n        /* Needs to be in here for Safari polyfill so background images work as expected. */\n        background-size: auto;\n    }\n    .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n        background: #F44336;\n    }\n\u003c/style\u003e\n\n\n\n\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: left;\"\u003e\n      \u003cth\u003eepoch\u003c/th\u003e\n      \u003cth\u003etrain_loss\u003c/th\u003e\n      \u003cth\u003evalid_loss\u003c/th\u003e\n      \u003cth\u003eerror_rate\u003c/th\u003e\n      \u003cth\u003etime\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0.040622\u003c/td\u003e\n      \u003ctd\u003e0.024036\u003c/td\u003e\n      \u003ctd\u003e0.005413\u003c/td\u003e\n      \u003ctd\u003e00:10\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastai%2Ftimmdocs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastai%2Ftimmdocs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastai%2Ftimmdocs/lists"}