{
  "id": "task_libraries:image-classification/python",
  "path": "/exapedia/python-image-classification-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python image classification libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python image classification libraries assign one or more labels to an image with a trained neural network. Most start from a model pretrained on a large dataset and fine-tune it on a smaller set of labeled images. These libraries let apps and AI agents sort photos and documents by what they show."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python image classification libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F125"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F127"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#torchvision",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F144"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#keras",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#timm",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#ultralytics",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F202"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#open-clip-torch",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F223"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F232"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tf-keras",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F244"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F253"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F248"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#vit-pytorch",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F265"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F266"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F274"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F269"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F267"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#transformers",
          "label": [
            {
              "t": "text",
              "text": "Transformers"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F126"
        },
        {
          "t": "text",
          "text": ", a count that covers every model task in the library."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Pretrained classifier factory",
            "TensorFlow training"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F125"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F133"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F134"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#torchvision",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F144"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#keras",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#timm",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#ultralytics",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F202"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#open-clip-torch",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F223"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F233"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tf-keras",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F244"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F254"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F255"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#vit-pytorch",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F265"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F275"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F276"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "transformers",
          "name": [
            {
              "t": "fact",
              "fact": "F125"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/transformers"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/transformers"
            },
            {
              "label": "Docs",
              "href": "https://huggingface.co/docs/transformers/en/tasks/image_classification"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F11"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F127"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/transformers/en/tasks/image_classification",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F125"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/docling-project/docling",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F142"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def predict_batch(\n    self, input_batch: List[ImageClassificationEngineInput]\n) -> List[ImageClassificationEngineOutput]:\n    \"\"\"Run inference on a batch of inputs.\"\"\"\n    import torch\n\n    if not input_batch:\n        return []\n    if self._model is None or self._processor is None or self._device is None:\n        raise RuntimeError(\"Engine not initialized. Call initialize() first.\")\n\n    images = [item.image.convert(\"RGB\") for item in input_batch]\n    inputs = self._processor(images=images, return_tensors=\"pt\").to(\n        self._device, self._model.dtype\n    )\n\n    with torch.inference_mode():\n        outputs = self._model(**inputs)  # type: ignore[operator]\n        probs_batch = torch.softmax(outputs.logits, dim=-1)\n\n    batch_outputs: List[ImageClassificationEngineOutput] = []\n    for input_item, probs_vector in zip(input_batch, probs_batch):\n        # Use topk for efficiency when top_k is specified\n        if self.options.top_k is not None:\n            k = min(self.options.top_k, len(probs_vector))\n            scores, labels = torch.topk(probs_vector, k=k)\n        else:\n            scores, labels = torch.sort(probs_vector, descending=True)\n\n        batch_outputs.append(\n            self._build_output(\n                input_item=input_item,\n                labels=labels.tolist(),\n                scores=scores.tolist(),\n            )\n        )\n\n    return batch_outputs\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/docling-project/docling/blob/8f351cbf7b09dcbf23fe0162ab49a90ec531e421/docling/models/inference_engines/image_classification/transformers_engine.py#L174-L211",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F141"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20transformers%20for%20whole-image%20classification%20with%20real%20native%20pretrained%20models%2C%20matching%20input%20transforms%20and%20class%20labels&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F125"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from transformers import pipeline\n\nclassifier = pipeline(\"image-classification\", model=\"google/vit-base-patch16-224\")\nprint(classifier(\"image.jpg\"))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/transformers/en/tasks/image_classification",
                  "label": [
                    {
                      "t": "text",
                      "text": "vit.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F130"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "torchvision",
          "name": [
            {
              "t": "fact",
              "fact": "F144"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/pytorch/vision"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/torchvision"
            },
            {
              "label": "Docs",
              "href": "https://docs.pytorch.org/vision/stable/models.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F31"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.pytorch.org/vision/stable/models.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F144"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F32"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F33"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F34"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F35"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F36"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F37"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/ultralytics/ultralytics",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F161"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def classify_transforms(\n    size: tuple[int, int] | int = 224,\n    mean: tuple[float, float, float] = DEFAULT_MEAN,\n    std: tuple[float, float, float] = DEFAULT_STD,\n    interpolation: str = \"BILINEAR\",\n    crop_fraction: float | None = None,\n):\n    \"\"\"Create a composition of image transforms for classification tasks.\n\n    This function generates a sequence of torchvision transforms suitable for preprocessing images for classification\n    models during evaluation or inference. The transforms include resizing, center cropping, conversion to tensor, and\n    normalization.\n\n    Args:\n        size (tuple[int, int] | int): The target size for the transformed image. If an int, it defines the shortest\n            edge. If a tuple, it defines (height, width).\n        mean (tuple[float, float, float]): Mean values for each RGB channel used in normalization.\n        std (tuple[float, float, float]): Standard deviation values for each RGB channel used in normalization.\n        interpolation (str): Interpolation method of either 'NEAREST', 'BILINEAR' or 'BICUBIC'.\n        crop_fraction (float | None): Deprecated, will be removed in a future version.\n\n    Returns:\n        (torchvision.transforms.Compose): A composition of torchvision transforms.\n\n    Examples:\n        >>> from PIL import Image\n        >>> from ultralytics.data.augment import classify_transforms\n        >>> transforms = classify_transforms(size=224)\n        >>> img = Image.open(\"path/to/image.jpg\")\n        >>> transformed_img = transforms(img)\n    \"\"\"\n    import torchvision.transforms as T  # scope for faster 'import ultralytics'\n\n    scale_size = size if isinstance(size, (tuple, list)) and len(size) == 2 else (size, size)\n\n    if crop_fraction:\n        deprecation_warn(\"crop_fraction\")\n\n    # Square target uses the scalar shortest-edge mode (preserves aspect); non-square resizes to the exact (h, w).\n    resize = scale_size[0] if scale_size[0] == scale_size[1] else scale_size\n    tfl = [\n        T.Resize(resize, interpolation=getattr(T.InterpolationMode, interpolation)),\n        T.CenterCrop(size),\n        T.ToTensor(),\n        T.Normalize(mean=torch.tensor(mean), std=torch.tensor(std)),\n    ]\n    return T.Compose(tfl)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/ultralytics/ultralytics/blob/4d254d8141e49dd85009e1ec7657ab3c4ee8c150/ultralytics/data/augment.py#L2920-L2966",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F160"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20torchvision%20for%20whole-image%20classification%20with%20real%20native%20pretrained%20models%2C%20matching%20input%20transforms%20and%20class%20labels&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F144"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from PIL import Image\nfrom torchvision.models import resnet50, ResNet50_Weights\n\nweights = ResNet50_Weights.DEFAULT\nmodel = resnet50(weights=weights).eval()\nimage = weights.transforms()(Image.open(\"image.jpg\").convert(\"RGB\")).unsqueeze(0)\nprint(model(image).argmax(1))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.pytorch.org/vision/stable/models.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "models.rst"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F149"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "keras",
          "name": [
            {
              "t": "fact",
              "fact": "F163"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/keras-team/keras"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/keras"
            },
            {
              "label": "Docs",
              "href": "https://keras.io/api/applications/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F170"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://keras.io/api/applications/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F163"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/keras-io",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F181"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def make_model(input_shape, num_classes):\n    inputs = keras.Input(shape=input_shape)\n\n    # Entry block\n    x = layers.Rescaling(1.0 / 255)(inputs)\n    x = layers.Conv2D(128, 3, strides=2, padding=\"same\")(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n\n    previous_block_activation = x  # Set aside residual\n\n    for size in [256, 512, 728]:\n        x = layers.Activation(\"relu\")(x)\n        x = layers.SeparableConv2D(size, 3, padding=\"same\")(x)\n        x = layers.BatchNormalization()(x)\n\n        x = layers.Activation(\"relu\")(x)\n        x = layers.SeparableConv2D(size, 3, padding=\"same\")(x)\n        x = layers.BatchNormalization()(x)\n\n        x = layers.MaxPooling2D(3, strides=2, padding=\"same\")(x)\n\n        # Project residual\n        residual = layers.Conv2D(size, 1, strides=2, padding=\"same\")(\n            previous_block_activation\n        )\n        x = layers.add([x, residual])  # Add back residual\n        previous_block_activation = x  # Set aside next residual\n\n    x = layers.SeparableConv2D(1024, 3, padding=\"same\")(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n\n    x = layers.GlobalAveragePooling2D()(x)\n    if num_classes == 2:\n        units = 1\n    else:\n        units = num_classes\n\n    x = layers.Dropout(0.25)(x)\n    # We specify activation=None so as to return logits\n    outputs = layers.Dense(units, activation=None)(x)\n    return keras.Model(inputs, outputs)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/keras-io/blob/f5891b3cd4df69f6bd5a3c26ea92310f3a973626/examples/vision/image_classification_from_scratch.py#L236-L278",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=keras%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F163"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import keras\nimport numpy as np\nfrom keras.applications.resnet50 import preprocess_input, decode_predictions\n\nmodel = keras.applications.ResNet50(weights=\"imagenet\")\nimage = keras.utils.load_img(\"image.jpg\", target_size=(224, 224))\ninputs = preprocess_input(np.expand_dims(keras.utils.img_to_array(image), 0))\nprint(decode_predictions(model.predict(inputs), top=3)[0])\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://keras.io/api/applications/",
                  "label": [
                    {
                      "t": "text",
                      "text": "index.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F168"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "timm",
          "name": [
            {
              "t": "fact",
              "fact": "F183"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/pytorch-image-models"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/timm"
            },
            {
              "label": "Docs",
              "href": "https://huggingface.co/docs/timm/en/quickstart"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F81"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/timm/en/quickstart",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F82"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F83"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F84"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F85"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F86"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F87"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F88"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/huggingface/api-inference-community",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F200"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __call__(self, inputs: Image.Image) -> List[Dict[str, Any]]:\n    \"\"\"\n    Args:\n        inputs (:obj:`PIL.Image`):\n            The raw image representation as PIL.\n            No transformation made whatsoever from the input. Make all necessary transformations here.\n    Return:\n        A :obj:`list`:. The list contains items that are dicts should be liked {\"label\": \"XXX\", \"score\": 0.82}\n            It is preferred if the returned list is in decreasing `score` order\n    \"\"\"\n    im = inputs.convert(\"RGB\")\n    inputs = self.transform(im).unsqueeze(0)\n\n    with torch.no_grad():\n        out = self.model(inputs)\n\n    probabilities = out.squeeze(0).softmax(dim=0)\n    values, indices = torch.topk(probabilities, self.top_k)\n\n    labels = [\n        {\n            \"label\": self.dataset_info.index_to_description(i, detailed=True),\n            \"score\": v.item(),\n        }\n        for i, v in zip(indices, values)\n    ]\n    return labels\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/huggingface/api-inference-community/blob/2fd0029ce344ab6cc75ead904bfce2d220b054de/docker_images/timm/app/pipelines/image_classification.py#L44-L70",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F199"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20timm%20for%20whole-image%20classification%20with%20real%20native%20pretrained%20models%2C%20matching%20input%20transforms%20and%20class%20labels&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import timm\nfrom PIL import Image\nfrom timm.data import resolve_data_config\nfrom timm.data.transforms_factory import create_transform\n\nmodel = timm.create_model(\"mobilenetv3_large_100\", pretrained=True).eval()\ntransform = create_transform(**resolve_data_config(model.pretrained_cfg))\nimage = transform(Image.open(\"image.jpg\").convert(\"RGB\")).unsqueeze(0)\nprint(model(image).argmax(1))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/timm/en/quickstart",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F188"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "ultralytics",
          "name": [
            {
              "t": "fact",
              "fact": "F202"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/ultralytics/ultralytics"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/ultralytics"
            },
            {
              "label": "Docs",
              "href": "https://docs.ultralytics.com/tasks/classify/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F209"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F205"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.ultralytics.com/tasks/classify/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F202"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F222"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/HumanSignal/label-studio-ml-backend",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F221"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def predict_regions(self, path) -> List[Dict]:\n    results = self.model.predict(path)\n    self.debug_plot(results[0].plot())\n    return self.create_choices(results, path)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/HumanSignal/label-studio-ml-backend/blob/5d160d6b736a1fc8faecb10b6ffe86f1fc228f44/label_studio_ml/examples/yolo/control_models/choices.py#L27-L30",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F220"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=ultralytics%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F202"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from ultralytics import YOLO\n\nmodel = YOLO(\"yolo26n-cls.pt\")\nprint(model(\"image.jpg\")[0].probs.top1)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.ultralytics.com/tasks/classify/",
                  "label": [
                    {
                      "t": "text",
                      "text": "classify.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F207"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "open-clip-torch",
          "name": [
            {
              "t": "fact",
              "fact": "F223"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/mlfoundations/open_clip"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/open-clip-torch"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F230"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F232"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/mlfoundations/open_clip",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F223"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F243"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/LAION-AI/CLIP_benchmark",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F242"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def run_classification(model, classifier, dataloader, device, amp=True):\n    \"\"\"\n    Run zero-shot classifcation\n\n    model: torch.nn.Module\n        CLIP-like model with `encode_image` and `encode_text`\n\n    classifier: torch.Tensor\n        obtained from the function `zero_shot_classifier`\n\n    dataloader: torch.utils.data.Dataloader \n\n    Returns\n    -------\n    (pred, true)  where\n        - pred (N, C) are the logits\n        - true (N,) are the actual classes\n    \"\"\"\n    pred = []\n    true = []\n    nb = 0\n    with torch.no_grad():\n        for images, target in tqdm(dataloader):\n            images = images.to(device)\n            target = target.to(device)\n\n            with torch.autocast(device, enabled=amp):\n                # predict\n                image_features = model.encode_image(images)\n                image_features = F.normalize(image_features, dim=-1)\n                logits = 100. * image_features @ classifier\n\n            true.append(target.cpu())\n            pred.append(logits.float().cpu())\n\n    pred = torch.cat(pred)\n    true = torch.cat(true)\n    return pred, true\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/LAION-AI/CLIP_benchmark/blob/574461d2e9c566d6282bd4217f1eeb1ad7ead47f/clip_benchmark/metrics/zeroshot_classification.py#L85-L122",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F241"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=open-clip-torch%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F223"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import torch\nfrom PIL import Image\nimport open_clip\n\nmodel, _, preprocess = open_clip.create_model_and_transforms(\"ViT-B-32\", pretrained=\"laion2b_s34b_b79k\")\nmodel.eval()\ntext = open_clip.get_tokenizer(\"ViT-B-32\")([\"a dog\", \"a cat\"])\nimage = preprocess(Image.open(\"image.jpg\")).unsqueeze(0)\nwith torch.no_grad():\n    print(model.get_logits(image, text)[0].softmax(-1))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/mlfoundations/open_clip",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F228"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "tf-keras",
          "name": [
            {
              "t": "fact",
              "fact": "F244"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/keras-team/tf-keras"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/tf-keras"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F251"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F253"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F247"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/tf-keras",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F244"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F263"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F264"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/tensorflow/probability",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F263"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _vggconv_block(x, filters, kernel, stride, kernel_posterior_fn):\n  \"\"\"Network block for VGG.\"\"\"\n  out = tfp.layers.Convolution2DFlipout(\n      filters,\n      kernel,\n      padding='same',\n      kernel_posterior_fn=kernel_posterior_fn)(x)\n  out = tf_keras.layers.BatchNormalization()(out)\n  out = tf_keras.layers.Activation('relu')(out)\n\n  out = tfp.layers.Convolution2DFlipout(\n      filters,\n      kernel,\n      padding='same',\n      kernel_posterior_fn=kernel_posterior_fn)(out)\n  out = tf_keras.layers.BatchNormalization()(out)\n  out = tf_keras.layers.Activation('relu')(out)\n\n  out = tf_keras.layers.MaxPooling2D(\n      pool_size=(2, 2), strides=stride)(out)\n  return out\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/tensorflow/probability/blob/df8c454f10495cc8584d0540e202911b61bce312/tensorflow_probability/examples/models/bayesian_vgg.py#L82-L102",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F262"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=tf-keras%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F244"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import tf_keras as keras\nfrom tf_keras.applications.resnet50 import preprocess_input, decode_predictions\n\nmodel = keras.applications.ResNet50(weights=\"imagenet\")\nimage = keras.utils.load_img(\"image.jpg\", target_size=(224, 224))\ninputs = preprocess_input(keras.utils.img_to_array(image)[None, ...])\nprint(decode_predictions(model.predict(inputs), top=3)[0])\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/tf-keras/blob/v2.21.0/tf_keras/applications/resnet.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "resnet.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F249"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "vit-pytorch",
          "name": [
            {
              "t": "fact",
              "fact": "F265"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/lucidrains/vit-pytorch"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/vit-pytorch"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F272"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F266"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F274"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F268"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F267"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/lucidrains/vit-pytorch",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F265"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F284"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F285"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/allenai/satlas",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F284"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def forward(self, image_list, targets=None, selected_task=None):\n    images = torch.stack(image_list, dim=0)\n    logits = self.backbone(images)\n\n    outputs = []\n    losses = []\n\n    for task_idx, task in enumerate(self.tasks):\n        cur_logits = logits[:, self.task_output_offsets[task_idx]:self.task_output_offsets[task_idx+1]]\n\n        if task['type'] == 'classification':\n            cur_outputs = torch.nn.functional.softmax(cur_logits, dim=1)\n\n            if targets is not None:\n                cur_valid = torch.stack([target[task_idx]['valid'] for target in targets], dim=0)\n                cur_targets = torch.cat([target[task_idx]['label'] for target in targets], dim=0).to(torch.long)\n                loss = torch.nn.functional.cross_entropy(cur_logits, cur_targets, reduction='none') * cur_valid\n                losses.append(loss.mean())\n        elif task['type'] == 'multi-label-classification':\n            cur_outputs = torch.sigmoid(cur_logits)\n\n            if targets is not None:\n                cur_valid = torch.stack([target[task_idx]['valid'] for target in targets], dim=0)\n                cur_targets = torch.stack([target[task_idx]['labels'] for target in targets], dim=0).to(torch.float32)\n                loss = torch.nn.functional.binary_cross_entropy_with_logits(cur_logits, cur_targets.squeeze(), reduction='none') * cur_valid\n                losses.append(loss.mean())\n\n        outputs.append(cur_outputs)\n\n    if len(losses) > 0:\n        losses = torch.stack(losses, dim=0)\n    else:\n        losses = torch.tensor(0, device=images.device, dtype=torch.float32)\n\n    return outputs, losses\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/allenai/satlas/blob/c8b9aa5d4acdd3e4f58eb7cbb28ac18bb12c985f/satlas/model/classify.py#L93-L127",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F283"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=vit-pytorch%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F265"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import torch\nfrom vit_pytorch import ViT\n\nmodel = ViT(image_size=256, patch_size=32, num_classes=1000, dim=1024, depth=6, heads=16, mlp_dim=2048)\nprint(model(torch.randn(1, 3, 256, 256)).shape)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/lucidrains/vit-pytorch",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F270"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python image classification library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#timm",
          "label": [
            {
              "t": "text",
              "text": "timm"
            }
          ]
        },
        {
          "t": "text",
          "text": " and "
        },
        {
          "t": "link",
          "href": "#torchvision",
          "label": [
            {
              "t": "text",
              "text": "TorchVision"
            }
          ]
        },
        {
          "t": "text",
          "text": " suit PyTorch projects that start from pretrained image classifiers. "
        },
        {
          "t": "link",
          "href": "#transformers",
          "label": [
            {
              "t": "text",
              "text": "Transformers"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits checkpoints from the Hugging Face Hub. "
        },
        {
          "t": "link",
          "href": "#ultralytics",
          "label": [
            {
              "t": "text",
              "text": "Ultralytics"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits YOLO training and export with little setup."
        }
      ]
    },
    {
      "q": "What is timm?",
      "a": [
        {
          "t": "link",
          "href": "#timm",
          "label": [
            {
              "t": "text",
              "text": "timm"
            }
          ]
        },
        {
          "t": "text",
          "text": " is a large registry of PyTorch image models and pretrained weights. Each model comes with its own preprocessing and classifier metadata."
        }
      ]
    },
    {
      "q": "What is TorchVision?",
      "a": [
        {
          "t": "link",
          "href": "#torchvision",
          "label": [
            {
              "t": "text",
              "text": "TorchVision"
            }
          ]
        },
        {
          "t": "text",
          "text": " is the PyTorch library of image models, pretrained weights, and image transforms."
        }
      ]
    },
    {
      "q": "What is OpenCLIP?",
      "a": [
        {
          "t": "link",
          "href": "#open-clip-torch",
          "label": [
            {
              "t": "text",
              "text": "OpenCLIP"
            }
          ]
        },
        {
          "t": "text",
          "text": " is an open reproduction of CLIP that embeds images and text in one space. It classifies images zero-shot by comparing them to a list of candidate labels."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, transformers",
      "display": "118.0M",
      "asOf": "2026-11-17"
    },
    "F3": {
      "label": "License, transformers",
      "display": "Apache 2.0 License",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, transformers",
      "display": "5.23.0, Nov 2026",
      "asOf": "2026-11-13"
    },
    "F5": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-13"
    },
    "F6": {
      "label": "Repository stars, transformers",
      "display": "169.1K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Pretrained classifiers, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Custom label training, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Model-matched preprocessing, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Install, transformers",
      "display": "pip install transformers",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "What it does, transformers",
      "display": "Classifies images with pretrained models and configurable image processors.",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "strengths lead, transformers",
      "display": "Scores new labels without training",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths, transformers",
      "display": "Use zero-shot-image-classification with a compatible image-text checkpoint.",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths lead, transformers",
      "display": "Chooses image preprocessing backends",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths, transformers",
      "display": "Select torchvision or PIL with the image processor’s backend option.",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "limitations lead, transformers",
      "display": "ViT can rescale inputs twice",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations, transformers",
      "display": "Set do_rescale=False for images already between zero and one.",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations lead, transformers",
      "display": "PIL preprocessing is CPU-only",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations, transformers",
      "display": "Select the torchvision backend when preprocessing must run on a GPU.",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Quickstart, transformers",
      "display": "import requests\nimport torch\nfrom PIL import Image\n\nfrom transformers import AutoImageProcessor, AutoModelForImageClassification\n\n\nimage_processor = AutoImageProcessor.from_pretrained(\n    \"google/vit-base-patch16-224\",\n    use_fast=True,\n)\nmodel = AutoModelForImageClassification.from_pretrained(\n    \"google/vit-base-patch16-224\",\n    device_map=\"auto\",\n    attn_implementation=\"sdpa\"\n)\nurl = \"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg\"\nimage = Image.open(requests.get(url, stream=True).raw)\ninputs = image_processor(image, return_tensors=\"pt\").to(model.device)\n\nwith torch.no_grad():\n  logits = model(**inputs).logits\npredicted_class_id = logits.argmax(dim=-1).item()\n\nclass_labels = model.config.id2label\npredicted_class_label = class_labels[predicted_class_id]\nprint(f\"The predicted class label is: {predicted_class_label}\")\n",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Library name, torchvision",
      "display": "TorchVision",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Monthly downloads, torchvision",
      "display": "17.7M",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "License, torchvision",
      "display": "BSD",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Package release, torchvision",
      "display": "0.29.2, Oct 2026",
      "asOf": "2026-10-28"
    },
    "F25": {
      "label": "Package release date, torchvision",
      "display": "Oct 2026",
      "asOf": "2026-10-28"
    },
    "F26": {
      "label": "Repository stars, torchvision",
      "display": "18.0K",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Pretrained classifiers, torchvision",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Custom label training, torchvision",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F29": {
      "label": "Model-matched preprocessing, torchvision",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Install, torchvision",
      "display": "pip install torchvision",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "What it does, torchvision",
      "display": "Provides image-classification models, pretrained weights, and image transforms.",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "strengths lead, torchvision",
      "display": "Bundles preprocessing with each weight",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "strengths, torchvision",
      "display": "Use the weight transforms to match the model’s expected input.",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "strengths lead, torchvision",
      "display": "Provides label names with weights",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "strengths, torchvision",
      "display": "Read the predicted class name from the weight metadata.",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "limitations lead, torchvision",
      "display": "Input transforms vary between weights",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "limitations, torchvision",
      "display": "Match preprocessing to the exact model and weight version.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "limitations lead, torchvision",
      "display": "Training and inference modes differ",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "limitations, torchvision",
      "display": "Call eval before classifying with a pretrained model.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "Quickstart, torchvision",
      "display": "from torchvision.io import decode_image\nfrom torchvision.models import resnet50, ResNet50_Weights\n\nimg = decode_image(\"test/assets/encode_jpeg/grace_hopper_517x606.jpg\")\n\n# Step 1: Initialize model with the best available weights\nweights = ResNet50_Weights.DEFAULT\nmodel = resnet50(weights=weights)\nmodel.eval()\n\n# Step 2: Initialize the inference transforms\npreprocess = weights.transforms()\n\n# Step 3: Apply inference preprocessing transforms\nbatch = preprocess(img).unsqueeze(0)\n\n# Step 4: Use the model and print the predicted category\nprediction = model(batch).squeeze(0).softmax(0)\nclass_id = prediction.argmax().item()\nscore = prediction[class_id].item()\ncategory_name = weights.meta[\"categories\"][class_id]\nprint(f\"{category_name}: {100 * score:.1f}%\")\n",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "Project function, torchvision",
      "display": "def classify_transforms(\n    size: tuple[int, int] | int = 224,\n    mean: tuple[float, float, float] = DEFAULT_MEAN,\n    std: tuple[float, float, float] = DEFAULT_STD,\n    interpolation: str = \"BILINEAR\",\n    crop_fraction: float | None = None,\n):\n    \"\"\"Create a composition of image transforms for classification tasks.\n\n    This function generates a sequence of torchvision transforms suitable for preprocessing images for classification\n    models during evaluation or inference. The transforms include resizing, center cropping, conversion to tensor, and\n    normalization.\n\n    Args:\n        size (tuple[int, int] | int): The target size for the transformed image. If an int, it defines the shortest\n            edge. If a tuple, it defines (height, width).\n        mean (tuple[float, float, float]): Mean values for each RGB channel used in normalization.\n        std (tuple[float, float, float]): Standard deviation values for each RGB channel used in normalization.\n        interpolation (str): Interpolation method of either 'NEAREST', 'BILINEAR' or 'BICUBIC'.\n        crop_fraction (float | None): Deprecated, will be removed in a future version.\n\n    Returns:\n        (torchvision.transforms.Compose): A composition of torchvision transforms.\n\n    Examples:\n        >>> from PIL import Image\n        >>> from ultralytics.data.augment import classify_transforms\n        >>> transforms = classify_transforms(size=224)\n        >>> img = Image.open(\"path/to/image.jpg\")\n        >>> transformed_img = transforms(img)\n    \"\"\"\n    import torchvision.transforms as T  # scope for faster 'import ultralytics'\n\n    scale_size = size if isinstance(size, (tuple, list)) and len(size) == 2 else (size, size)\n\n    if crop_fraction:\n        deprecation_warn(\"crop_fraction\")\n\n    # Square target uses the scalar shortest-edge mode (preserves aspect); non-square resizes to the exact (h, w).\n    resize = scale_size[0] if scale_size[0] == scale_size[1] else scale_size\n    tfl = [\n        T.Resize(resize, interpolation=getattr(T.InterpolationMode, interpolation)),\n        T.CenterCrop(size),\n        T.ToTensor(),\n        T.Normalize(mean=torch.tensor(mean), std=torch.tensor(std)),\n    ]\n    return T.Compose(tfl)\n",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "Project function reference, torchvision",
      "display": "augment.py · classify_transforms()",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "Project repository, torchvision",
      "display": "ultralytics/ultralytics",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "Project stars, ultralytics/ultralytics",
      "display": "63.5K",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Project push date, ultralytics/ultralytics",
      "display": "Nov 2026",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Library name, tensorflow",
      "display": "TensorFlow",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Monthly downloads, tensorflow",
      "display": "12.3M",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "License, tensorflow",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Package release, tensorflow",
      "display": "2.21.0, Mar 2026",
      "asOf": "2026-03-06"
    },
    "F50": {
      "label": "Package release date, tensorflow",
      "display": "Mar 2026",
      "asOf": "2026-03-06"
    },
    "F51": {
      "label": "Repository stars, tensorflow",
      "display": "201.6K",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Pretrained classifiers, tensorflow",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Custom label training, tensorflow",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Model-matched preprocessing, tensorflow",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Install, tensorflow",
      "display": "pip install tensorflow",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "What it does, tensorflow",
      "display": "Builds and trains image classifiers through TensorFlow’s Keras APIs.",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "strengths lead, tensorflow",
      "display": "Ships pretrained classification applications",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "strengths, tensorflow",
      "display": "Load ResNet50 with ImageNet weights through tf.keras.applications.",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "strengths lead, tensorflow",
      "display": "Freezes backbones for transfer learning",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "strengths, tensorflow",
      "display": "Freeze the pretrained model while training a new classification head.",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "limitations lead, tensorflow",
      "display": "ResNet preprocessing changes color order",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "limitations, tensorflow",
      "display": "Convert RGB inputs to BGR with the matching preprocess_input function.",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "limitations lead, tensorflow",
      "display": "Trainability changes require recompiling",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "limitations, tensorflow",
      "display": "Recompile the model after changing any layer’s trainable setting.",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "Quickstart, tensorflow",
      "display": "# TensorFlow and tf.keras\nimport tensorflow as tf\n\n# Helper libraries\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nprint(tf.__version__)\n\nfashion_mnist = tf.keras.datasets.fashion_mnist\n\n(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()\n\nclass_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',\n               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']\n\ntrain_images = train_images / 255.0\n\ntest_images = test_images / 255.0\n\nmodel = tf.keras.Sequential([\n    tf.keras.layers.Flatten(input_shape=(28, 28)),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dense(10)\n])\n\nmodel.compile(optimizer='adam',\n              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n              metrics=['accuracy'])\n\nmodel.fit(train_images, train_labels, epochs=10)\n\ntest_loss, test_acc = model.evaluate(test_images,  test_labels, verbose=2)\n\nprint('\\nTest accuracy:', test_acc)\n\nprobability_model = tf.keras.Sequential([model, \n                                         tf.keras.layers.Softmax()])\n\npredictions = probability_model.predict(test_images)\n\npredictions[0]\n\nnp.argmax(predictions[0])\n",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "Project function, tensorflow",
      "display": "def load_images(image_paths, image_size, verbose=True):\n    '''\n    Function for loading images into numpy arrays for passing to model.predict\n    inputs:\n        image_paths: list of image paths to load\n        image_size: size into which images should be resized\n        verbose: show all of the image path and sizes loaded\n\n    outputs:\n        loaded_images: loaded images on which keras model can run predictions\n        loaded_image_indexes: paths of images which the function is able to process\n\n    '''\n    loaded_images = []\n    loaded_image_paths = []\n\n    if isdir(image_paths):\n        parent = abspath(image_paths)\n        image_paths = [join(parent, f) for f in listdir(image_paths) if isfile(join(parent, f))]\n    elif isfile(image_paths):\n        image_paths = [image_paths]\n\n    for img_path in image_paths:\n        try:\n            if verbose:\n                print(img_path, \"size:\", image_size)\n            image = keras.preprocessing.image.load_img(img_path, target_size=image_size)\n            image = keras.preprocessing.image.img_to_array(image)\n            image /= 255\n            loaded_images.append(image)\n            loaded_image_paths.append(img_path)\n        except Exception as ex:\n            print(\"Image Load Failure: \", img_path, ex)\n\n    return np.asarray(loaded_images), loaded_image_paths\n",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "Project function reference, tensorflow",
      "display": "predict.py · load_images()",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Project repository, tensorflow",
      "display": "GantMan/nsfw_model",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Project stars, GantMan/nsfw_model",
      "display": "2.1K",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Project push date, GantMan/nsfw_model",
      "display": "Feb 2024",
      "asOf": "2024-02-26"
    },
    "F71": {
      "label": "Library name, timm",
      "display": "timm",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Monthly downloads, timm",
      "display": "11.5M",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "License, timm",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Package release, timm",
      "display": "1.0.31, Nov 2026",
      "asOf": "2026-11-03"
    },
    "F75": {
      "label": "Package release date, timm",
      "display": "Nov 2026",
      "asOf": "2026-11-03"
    },
    "F76": {
      "label": "Repository stars, timm",
      "display": "37.3K",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Pretrained classifiers, timm",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F78": {
      "label": "Custom label training, timm",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Model-matched preprocessing, timm",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Install, timm",
      "display": "pip install timm",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "What it does, timm",
      "display": "Loads pretrained PyTorch image classifiers and supplies their data transforms.",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "strengths lead, timm",
      "display": "Selects pretrained models by name",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "strengths, timm",
      "display": "Use create_model to load a named classifier with pretrained weights.",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "strengths lead, timm",
      "display": "Replaces the classifier for finetuning",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "strengths, timm",
      "display": "Set num_classes when adapting a pretrained model to new labels.",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "limitations lead, timm",
      "display": "New models start in training",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "limitations, timm",
      "display": "Call eval before using the model for inference.",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "limitations lead, timm",
      "display": "Custom datasets need training code",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "limitations, timm",
      "display": "Write a PyTorch training loop or adapt timm’s training script.",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "Quickstart, timm",
      "display": "from urllib.request import urlopen\nfrom PIL import Image\nimport timm\nimport torch\n\nimg = Image.open(urlopen(\n    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'\n))\n\nmodel = timm.create_model('resnet50.a1_in1k', pretrained=True)\nmodel = model.eval()\n\n# get model specific transforms (normalization, resize)\ndata_config = timm.data.resolve_model_data_config(model)\ntransforms = timm.data.create_transform(**data_config, is_training=False)\n\noutput = model(transforms(img).unsqueeze(0))  # unsqueeze single image into batch of 1\n\ntop5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)\n",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "Project function, timm",
      "display": "def __init__(self, model_id: str):\n    self.model = timm.create_model(f\"hf_hub:{model_id}\", pretrained=True)\n    self.transform = create_transform(\n        **resolve_model_data_config(self.model, use_test_size=True)\n    )\n    self.top_k = min(self.model.num_classes, 5)\n    self.model.eval()\n\n    self.dataset_info = None\n    label_names = self.model.pretrained_cfg.get(\"label_names\", None)\n    label_descriptions = self.model.pretrained_cfg.get(\"label_descriptions\", None)\n\n    if label_names is None:\n        # if no labels added to config, use imagenet labeller in timm\n        imagenet_subset = infer_imagenet_subset(self.model)\n        if imagenet_subset:\n            self.dataset_info = ImageNetInfo(imagenet_subset)\n        else:\n            # fallback label names\n            label_names = [f\"LABEL_{i}\" for i in range(self.model.num_classes)]\n\n    if self.dataset_info is None:\n        self.dataset_info = CustomDatasetInfo(\n            label_names=label_names,\n            label_descriptions=label_descriptions,\n        )\n",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "Project function reference, timm",
      "display": "image_classification.py · __init__()",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "Project repository, timm",
      "display": "huggingface/api-inference-community",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Project stars, huggingface/api-inference-community",
      "display": "174",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Project push date, huggingface/api-inference-community",
      "display": "May 2026",
      "asOf": "2026-05-26"
    },
    "F96": {
      "label": "Developer need",
      "display": "Using weights with matching transforms",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Why choose torchvision",
      "display": "bundled weight-specific preprocessing",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need in introduction",
      "display": "using weights with matching transforms",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "When to consider transformers",
      "display": "candidate labels should be supplied at inference time",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need",
      "display": "Changing a named classifier for finetuning",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Why choose timm",
      "display": "a replaceable classification head",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need in introduction",
      "display": "changing a named classifier for finetuning",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "When to consider tensorflow",
      "display": "a Keras transfer-learning workflow is preferred",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need",
      "display": "Scoring supplied labels without retraining",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Why choose transformers",
      "display": "compatible zero-shot image-text checkpoints",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Developer need in introduction",
      "display": "scoring supplied labels without retraining",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "When to consider torchvision",
      "display": "explicit TorchVision weight transforms fit the model",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Developer need",
      "display": "Training with frozen pretrained features",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Why choose tensorflow",
      "display": "Keras transfer-learning workflow",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Developer need in introduction",
      "display": "training with frozen pretrained features",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "When to consider timm",
      "display": "adapting a named PyTorch classifier is preferred",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "Page introduction",
      "display": "Python image classification libraries let machine-learning developers assign labels to images.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Does image classification locate every object?",
      "display": "Image classification assigns a class to an image; the object-detection task answers a different question.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: How does TorchVision choose the correct preprocessing?",
      "display": "Each weight exposes its matching preprocessing transforms; model families and weight versions can differ.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Where do TorchVision predicted label names come from?",
      "display": "Use the categories in the selected weights metadata.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Can TorchVision train a new classifier head?",
      "display": "Replace the final layer and train it for the new task while keeping earlier weights fixed.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Is timm create_model ready for inference immediately?",
      "display": "Its returned model starts in training mode; switch to eval for inference.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Does changing timm num_classes train new labels?",
      "display": "Changing the classifier is a setup step; adapt the training script or write a training loop for the dataset.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Can a generic timm transform replace the model configuration?",
      "display": "Use the model data configuration: pretrained models can require different image transforms.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Can Transformers classify labels absent from a training dataset?",
      "display": "A compatible zero-shot image-text model can score supplied candidate labels without additional labeled training data.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Should ViT rescale pixel values already between zero and one?",
      "display": "Set do_rescale=False for those images to avoid applying the default rescaling again.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: Does the Transformers PIL image processor use a GPU?",
      "display": "The PIL backend is CPU-only; the torchvision backend supports GPU preprocessing.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Does ResNet preprocessing preserve RGB channel order?",
      "display": "Its preprocess_input converts RGB to BGR and centers channels using ImageNet values.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: What happens after changing TensorFlow layer trainability?",
      "display": "Recompile the model after changing trainable settings so the changes take effect.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Monthly downloads, transformers",
      "display": "120.5M",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "License, transformers",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Package release, transformers",
      "display": "5.23.0",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Install, transformers",
      "display": "pip install \"transformers[torch]\" pillow",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Quickstart, transformers",
      "display": "from transformers import pipeline\n\nclassifier = pipeline(\"image-classification\", model=\"google/vit-base-patch16-224\")\nprint(classifier(\"image.jpg\"))\n",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Repository stars, transformers",
      "display": "169.2K",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Pretrained classifier factory, transformers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "TensorFlow training, transformers",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Native classification role, transformers",
      "display": "Checkpoint-driven image-classification models and processors in a broad PyTorch model framework.",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Training backends, transformers",
      "display": "PyTorch for selected v5; TF/Flax sunset.",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Pretrained assets and label space, transformers",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Host and model prerequisites, transformers",
      "display": "Python>=3.11,compatible PyTorch,Pillow,local image.jpg,and downloadable image-classification checkpoint/processor. Explicit named pretrained checkpoint replaces guide-specific fine-tuned output directory; network/cache availability required.",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Exact external integration contract, transformers",
      "display": "Model image-classification output.logits has [batch,num_labels] shape. Host applies softmax then topk/sort and returns Docling ImageClassificationEngineOutput with numeric label IDs and floating scores via _build_output. These are single-label normalized scores,not a calibrated confidence guarantee or class-name strings.",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Project function, transformers",
      "display": "def predict_batch(\n    self, input_batch: List[ImageClassificationEngineInput]\n) -> List[ImageClassificationEngineOutput]:\n    \"\"\"Run inference on a batch of inputs.\"\"\"\n    import torch\n\n    if not input_batch:\n        return []\n    if self._model is None or self._processor is None or self._device is None:\n        raise RuntimeError(\"Engine not initialized. Call initialize() first.\")\n\n    images = [item.image.convert(\"RGB\") for item in input_batch]\n    inputs = self._processor(images=images, return_tensors=\"pt\").to(\n        self._device, self._model.dtype\n    )\n\n    with torch.inference_mode():\n        outputs = self._model(**inputs)  # type: ignore[operator]\n        probs_batch = torch.softmax(outputs.logits, dim=-1)\n\n    batch_outputs: List[ImageClassificationEngineOutput] = []\n    for input_item, probs_vector in zip(input_batch, probs_batch):\n        # Use topk for efficiency when top_k is specified\n        if self.options.top_k is not None:\n            k = min(self.options.top_k, len(probs_vector))\n            scores, labels = torch.topk(probs_vector, k=k)\n        else:\n            scores, labels = torch.sort(probs_vector, descending=True)\n\n        batch_outputs.append(\n            self._build_output(\n                input_item=input_item,\n                labels=labels.tolist(),\n                scores=scores.tolist(),\n            )\n        )\n\n    return batch_outputs\n",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Project source file, transformers",
      "display": "docling/models/inference_engines/image_classification/transformers_engine.py",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Project full_name, transformers",
      "display": "docling-project/docling",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Project stargazers_count, transformers",
      "display": "70.8K",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Library name, torchvision",
      "display": "TorchVision",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Monthly downloads, torchvision",
      "display": "18.1M",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "License, torchvision",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Package release, torchvision",
      "display": "0.29.2",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Package release date, torchvision",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Install, torchvision",
      "display": "pip install torch torchvision pillow",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Quickstart, torchvision",
      "display": "from PIL import Image\nfrom torchvision.models import resnet50, ResNet50_Weights\n\nweights = ResNet50_Weights.DEFAULT\nmodel = resnet50(weights=weights).eval()\nimage = weights.transforms()(Image.open(\"image.jpg\").convert(\"RGB\")).unsqueeze(0)\nprint(model(image).argmax(1))\n",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Repository stars, torchvision",
      "display": "18.0K",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Pretrained classifier factory, torchvision",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "TensorFlow training, torchvision",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Native classification role, torchvision",
      "display": "PyTorch-maintained image model builders,weight-specific preprocessing,and vision transforms.",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Training backends, torchvision",
      "display": "PyTorch.",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Pretrained assets and label space, torchvision",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Host and model prerequisites, torchvision",
      "display": "Compatible matching Torch/TorchVision wheel,Pillow,local RGB image,and downloadable pretrained weights. Returns ImageNet class ID,not decoded class name or calibrated confidence.",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Exact external integration contract, torchvision",
      "display": "Returns callable composed preprocessing,not classification predictions. For RGB inputs this produces channel-first normalized tensors with requested crop dimensions. Tensor mean/std creation is Torch peer code,not additional TorchVision-native operations.",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Project function, torchvision",
      "display": "def classify_transforms(\n    size: tuple[int, int] | int = 224,\n    mean: tuple[float, float, float] = DEFAULT_MEAN,\n    std: tuple[float, float, float] = DEFAULT_STD,\n    interpolation: str = \"BILINEAR\",\n    crop_fraction: float | None = None,\n):\n    \"\"\"Create a composition of image transforms for classification tasks.\n\n    This function generates a sequence of torchvision transforms suitable for preprocessing images for classification\n    models during evaluation or inference. The transforms include resizing, center cropping, conversion to tensor, and\n    normalization.\n\n    Args:\n        size (tuple[int, int] | int): The target size for the transformed image. If an int, it defines the shortest\n            edge. If a tuple, it defines (height, width).\n        mean (tuple[float, float, float]): Mean values for each RGB channel used in normalization.\n        std (tuple[float, float, float]): Standard deviation values for each RGB channel used in normalization.\n        interpolation (str): Interpolation method of either 'NEAREST', 'BILINEAR' or 'BICUBIC'.\n        crop_fraction (float | None): Deprecated, will be removed in a future version.\n\n    Returns:\n        (torchvision.transforms.Compose): A composition of torchvision transforms.\n\n    Examples:\n        >>> from PIL import Image\n        >>> from ultralytics.data.augment import classify_transforms\n        >>> transforms = classify_transforms(size=224)\n        >>> img = Image.open(\"path/to/image.jpg\")\n        >>> transformed_img = transforms(img)\n    \"\"\"\n    import torchvision.transforms as T  # scope for faster 'import ultralytics'\n\n    scale_size = size if isinstance(size, (tuple, list)) and len(size) == 2 else (size, size)\n\n    if crop_fraction:\n        deprecation_warn(\"crop_fraction\")\n\n    # Square target uses the scalar shortest-edge mode (preserves aspect); non-square resizes to the exact (h, w).\n    resize = scale_size[0] if scale_size[0] == scale_size[1] else scale_size\n    tfl = [\n        T.Resize(resize, interpolation=getattr(T.InterpolationMode, interpolation)),\n        T.CenterCrop(size),\n        T.ToTensor(),\n        T.Normalize(mean=torch.tensor(mean), std=torch.tensor(std)),\n    ]\n    return T.Compose(tfl)\n",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Project source file, torchvision",
      "display": "ultralytics/data/augment.py",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Project full_name, torchvision",
      "display": "ultralytics/ultralytics",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Project stargazers_count, torchvision",
      "display": "63.6K",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Library name, keras",
      "display": "Keras",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Monthly downloads, keras",
      "display": "12.1M",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "License, keras",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Package release, keras",
      "display": "3.15.1",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Package release date, keras",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Install, keras",
      "display": "pip install keras tensorflow pillow numpy",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Quickstart, keras",
      "display": "import keras\nimport numpy as np\nfrom keras.applications.resnet50 import preprocess_input, decode_predictions\n\nmodel = keras.applications.ResNet50(weights=\"imagenet\")\nimage = keras.utils.load_img(\"image.jpg\", target_size=(224, 224))\ninputs = preprocess_input(np.expand_dims(keras.utils.img_to_array(image), 0))\nprint(decode_predictions(model.predict(inputs), top=3)[0])\n",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Official description, keras",
      "display": "Provides Keras with multiple backends.",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Quickstart source file, keras",
      "display": "templates/api/applications/index.md",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Repository stars, keras",
      "display": "64.4K",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Pretrained classifier factory, keras",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "TensorFlow training, keras",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Native classification role, keras",
      "display": "Multi-backend high-level model authoring/training plus pretrained image Applications.",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Training backends, keras",
      "display": "TensorFlow,JAX,or PyTorch,selected before import/configuration.",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Pretrained assets and label space, keras",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Host and model prerequisites, keras",
      "display": "Python>=3.11; select/install a supported TensorFlow,JAX,or Torch backend before importing Keras. This recipe explicitly installs TensorFlow plus Pillow. Local image,weights cache/network needed.",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Project function, keras",
      "display": "def make_model(input_shape, num_classes):\n    inputs = keras.Input(shape=input_shape)\n\n    # Entry block\n    x = layers.Rescaling(1.0 / 255)(inputs)\n    x = layers.Conv2D(128, 3, strides=2, padding=\"same\")(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n\n    previous_block_activation = x  # Set aside residual\n\n    for size in [256, 512, 728]:\n        x = layers.Activation(\"relu\")(x)\n        x = layers.SeparableConv2D(size, 3, padding=\"same\")(x)\n        x = layers.BatchNormalization()(x)\n\n        x = layers.Activation(\"relu\")(x)\n        x = layers.SeparableConv2D(size, 3, padding=\"same\")(x)\n        x = layers.BatchNormalization()(x)\n\n        x = layers.MaxPooling2D(3, strides=2, padding=\"same\")(x)\n\n        # Project residual\n        residual = layers.Conv2D(size, 1, strides=2, padding=\"same\")(\n            previous_block_activation\n        )\n        x = layers.add([x, residual])  # Add back residual\n        previous_block_activation = x  # Set aside next residual\n\n    x = layers.SeparableConv2D(1024, 3, padding=\"same\")(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n\n    x = layers.GlobalAveragePooling2D()(x)\n    if num_classes == 2:\n        units = 1\n    else:\n        units = num_classes\n\n    x = layers.Dropout(0.25)(x)\n    # We specify activation=None so as to return logits\n    outputs = layers.Dense(units, activation=None)(x)\n    return keras.Model(inputs, outputs)\n",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Project source file, keras",
      "display": "examples/vision/image_classification_from_scratch.py",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Project full_name, keras",
      "display": "keras-team/keras-io",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Project stargazers_count, keras",
      "display": "3.0K",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Library name, timm",
      "display": "timm",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Monthly downloads, timm",
      "display": "11.8M",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "License, timm",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Package release, timm",
      "display": "1.0.31",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Package release date, timm",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Install, timm",
      "display": "pip install timm pillow",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Quickstart, timm",
      "display": "import timm\nfrom PIL import Image\nfrom timm.data import resolve_data_config\nfrom timm.data.transforms_factory import create_transform\n\nmodel = timm.create_model(\"mobilenetv3_large_100\", pretrained=True).eval()\ntransform = create_transform(**resolve_data_config(model.pretrained_cfg))\nimage = transform(Image.open(\"image.jpg\").convert(\"RGB\")).unsqueeze(0)\nprint(model(image).argmax(1))\n",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Repository stars, timm",
      "display": "37.3K",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Pretrained classifier factory, timm",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "TensorFlow training, timm",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Native classification role, timm",
      "display": "Large PyTorch image model/weight registry with model-specific preprocessing and classifier metadata.",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Training backends, timm",
      "display": "PyTorch.",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Pretrained assets and label space, timm",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Host and model prerequisites, timm",
      "display": "Python>=3.10,compatible Torch/TorchVision,Pillow,local image,and pretrained weights/cache. Model-specific transform required; class ID output.",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Exact external integration contract, timm",
      "display": "Native model returns [1,num_classes] logits for a classifier with nonzero head. Host softmax/topk converts them into list dictionaries {label:string,score:float}; dataset_info returns a label description string. Model/label metadata must agree and class count must be positive. Torch math and torchvision transform invocation are peer operations,not additional timm calls.",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Project function, timm",
      "display": "def __call__(self, inputs: Image.Image) -> List[Dict[str, Any]]:\n    \"\"\"\n    Args:\n        inputs (:obj:`PIL.Image`):\n            The raw image representation as PIL.\n            No transformation made whatsoever from the input. Make all necessary transformations here.\n    Return:\n        A :obj:`list`:. The list contains items that are dicts should be liked {\"label\": \"XXX\", \"score\": 0.82}\n            It is preferred if the returned list is in decreasing `score` order\n    \"\"\"\n    im = inputs.convert(\"RGB\")\n    inputs = self.transform(im).unsqueeze(0)\n\n    with torch.no_grad():\n        out = self.model(inputs)\n\n    probabilities = out.squeeze(0).softmax(dim=0)\n    values, indices = torch.topk(probabilities, self.top_k)\n\n    labels = [\n        {\n            \"label\": self.dataset_info.index_to_description(i, detailed=True),\n            \"score\": v.item(),\n        }\n        for i, v in zip(indices, values)\n    ]\n    return labels\n",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Project source file, timm",
      "display": "docker_images/timm/app/pipelines/image_classification.py",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Project full_name, timm",
      "display": "huggingface/api-inference-community",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Project stargazers_count, timm",
      "display": "174",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Library name, ultralytics",
      "display": "Ultralytics",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Monthly downloads, ultralytics",
      "display": "5.1M",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "License, ultralytics",
      "display": "AGPL-3.0",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Package release, ultralytics",
      "display": "8.4.215",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Package release date, ultralytics",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Install, ultralytics",
      "display": "pip install ultralytics",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Quickstart, ultralytics",
      "display": "from ultralytics import YOLO\n\nmodel = YOLO(\"yolo26n-cls.pt\")\nprint(model(\"image.jpg\")[0].probs.top1)\n",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Official description, ultralytics",
      "display": "Runs YOLO models for detection, segmentation, classification, pose estimation, and tracking.",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Quickstart source file, ultralytics",
      "display": "docs/en/tasks/classify.md",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Repository stars, ultralytics",
      "display": "63.6K",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Pretrained classifier factory, ultralytics",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "TensorFlow training, ultralytics",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Native classification role, ultralytics",
      "display": "Task-oriented YOLO image-classification training,prediction,and export workflows.",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Training backends, ultralytics",
      "display": "PyTorch native training; separate exports/deployment backends are different roles.",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Pretrained assets and label space, ultralytics",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Host and model prerequisites, ultralytics",
      "display": "Compatible Torch/Ultralytics runtime,local image,and downloadable classification weights. Uses native supported classification checkpoint; result is top class ID.",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Exact external integration contract, ultralytics",
      "display": "Returns host Label Studio choices regions from classification Results. The first result plot is an annotated numpy image for debug output. Nonempty valid image path,classification checkpoint,label_map,original model/cache loader,and compatible image/Torch runtime are prerequisites. Generic YOLO detection boxes are not substituted for class scores.",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Project function, ultralytics",
      "display": "def predict_regions(self, path) -> List[Dict]:\n    results = self.model.predict(path)\n    self.debug_plot(results[0].plot())\n    return self.create_choices(results, path)\n",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Project source file, ultralytics",
      "display": "label_studio_ml/examples/yolo/control_models/choices.py",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Project full_name, ultralytics",
      "display": "HumanSignal/label-studio-ml-backend",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Project stargazers_count, ultralytics",
      "display": "1.1K",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Library name, open-clip-torch",
      "display": "OpenCLIP",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Monthly downloads, open-clip-torch",
      "display": "2.2M",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "License, open-clip-torch",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Package release, open-clip-torch",
      "display": "4.2.2",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Package release date, open-clip-torch",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Install, open-clip-torch",
      "display": "pip install open-clip-torch pillow",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Quickstart, open-clip-torch",
      "display": "import torch\nfrom PIL import Image\nimport open_clip\n\nmodel, _, preprocess = open_clip.create_model_and_transforms(\"ViT-B-32\", pretrained=\"laion2b_s34b_b79k\")\nmodel.eval()\ntext = open_clip.get_tokenizer(\"ViT-B-32\")([\"a dog\", \"a cat\"])\nimage = preprocess(Image.open(\"image.jpg\")).unsqueeze(0)\nwith torch.no_grad():\n    print(model.get_logits(image, text)[0].softmax(-1))\n",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Official description, open-clip-torch",
      "display": "Reproduces contrastive language-image pretraining (CLIP) in the open.",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Quickstart source file, open-clip-torch",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Repository stars, open-clip-torch",
      "display": "14.3K",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Pretrained classifier factory, open-clip-torch",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "TensorFlow training, open-clip-torch",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Native classification role, open-clip-torch",
      "display": "Image/text shared embeddings and candidate-label zero-shot image classification.",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Training backends, open-clip-torch",
      "display": "PyTorch.",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Pretrained assets and label space, open-clip-torch",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Host and model prerequisites, open-clip-torch",
      "display": "Python>=3.9,current OpenCLIP requires PyTorch>=2.6,Pillow,local image,and downloadable matching model/weights/tokenizer. CPU-default setup avoids unexplained CUDA context. Scores are over the supplied two text candidates.",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Exact external integration contract, open-clip-torch",
      "display": "Returns concatenated CPU float raw scaled-cosine logits [N,C] and CPU targets[N] for scoped single-label dataset. Host uses fixed factor100 rather than learned temperature and does not softmax here; these are not calibrated probabilities. Embedding dimension and class-weight matrix must agree. Torch/F.normalize/math/concatenation are peers,not counted as OpenCLIP SDK calls.",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Project function, open-clip-torch",
      "display": "def run_classification(model, classifier, dataloader, device, amp=True):\n    \"\"\"\n    Run zero-shot classifcation\n\n    model: torch.nn.Module\n        CLIP-like model with `encode_image` and `encode_text`\n\n    classifier: torch.Tensor\n        obtained from the function `zero_shot_classifier`\n\n    dataloader: torch.utils.data.Dataloader \n\n    Returns\n    -------\n    (pred, true)  where\n        - pred (N, C) are the logits\n        - true (N,) are the actual classes\n    \"\"\"\n    pred = []\n    true = []\n    nb = 0\n    with torch.no_grad():\n        for images, target in tqdm(dataloader):\n            images = images.to(device)\n            target = target.to(device)\n\n            with torch.autocast(device, enabled=amp):\n                # predict\n                image_features = model.encode_image(images)\n                image_features = F.normalize(image_features, dim=-1)\n                logits = 100. * image_features @ classifier\n\n            true.append(target.cpu())\n            pred.append(logits.float().cpu())\n\n    pred = torch.cat(pred)\n    true = torch.cat(true)\n    return pred, true\n",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Project source file, open-clip-torch",
      "display": "clip_benchmark/metrics/zeroshot_classification.py",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Project full_name, open-clip-torch",
      "display": "LAION-AI/CLIP_benchmark",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Project stargazers_count, open-clip-torch",
      "display": "819",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Library name, tf-keras",
      "display": "TF-Keras",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Monthly downloads, tf-keras",
      "display": "2.1M",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "License, tf-keras",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Package release, tf-keras",
      "display": "2.21.0",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Package release date, tf-keras",
      "display": "Mar 2026",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Install, tf-keras",
      "display": "pip install \"tf-keras==2.21.0\" pillow",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Quickstart, tf-keras",
      "display": "import tf_keras as keras\nfrom tf_keras.applications.resnet50 import preprocess_input, decode_predictions\n\nmodel = keras.applications.ResNet50(weights=\"imagenet\")\nimage = keras.utils.load_img(\"image.jpg\", target_size=(224, 224))\ninputs = preprocess_input(keras.utils.img_to_array(image)[None, ...])\nprint(decode_predictions(model.predict(inputs), top=3)[0])\n",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Official description, tf-keras",
      "display": "Provides deep learning for humans.",
      "asOf": "2026-11-20"
    },
    "F252": {
      "label": "Quickstart source file, tf-keras",
      "display": "tf_keras/applications/resnet.py",
      "asOf": "2026-11-20"
    },
    "F253": {
      "label": "Repository stars, tf-keras",
      "display": "88",
      "asOf": "2026-11-20"
    },
    "F254": {
      "label": "Pretrained classifier factory, tf-keras",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F255": {
      "label": "TensorFlow training, tf-keras",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F256": {
      "label": "Native classification role, tf-keras",
      "display": "Separately maintained TensorFlow-only Keras2 implementation for compatibility-dependent workflows.",
      "asOf": "2026-11-20"
    },
    "F257": {
      "label": "Training backends, tf-keras",
      "display": "TensorFlow-only standalone Keras2; selected2.21 requires TensorFlow2.21.",
      "asOf": "2026-11-20"
    },
    "F258": {
      "label": "Pretrained assets and label space, tf-keras",
      "display": "Native supported factory can initialize image/vision-language model weights from named pretrained assets. OpenCLIP needs candidate text/class weights for classification; closed-set heads and training-data labels vary. Download availability and model licenses remain separate.",
      "asOf": "2026-11-20"
    },
    "F259": {
      "label": "Host and model prerequisites, tf-keras",
      "display": "Python>=3.10,TensorFlow~=2.21 supplied by selected tf-keras,plus Pillow/local image/network for pretrained weights. Direct standalone tf_keras import prevents silently choosing Keras3; optional TFP not needed for this basic first call.",
      "asOf": "2026-11-20"
    },
    "F260": {
      "label": "Exact external integration contract, tf-keras",
      "display": "Returns the pooled symbolic Keras2 tensor for an actual Bayesian VGG classifier block. Full source bayesian_vgg feeds successive blocks,flatten,and a class-count DenseFlipout layer into tf_keras.Model. This is model construction,not completed training or class probabilities. Compatible TFP Flipout layer base,posterior function,input shape,and strides required; mixing Keras3 Layer objects is not implied compatible.",
      "asOf": "2026-11-20"
    },
    "F261": {
      "label": "Project function, tf-keras",
      "display": "def _vggconv_block(x, filters, kernel, stride, kernel_posterior_fn):\n  \"\"\"Network block for VGG.\"\"\"\n  out = tfp.layers.Convolution2DFlipout(\n      filters,\n      kernel,\n      padding='same',\n      kernel_posterior_fn=kernel_posterior_fn)(x)\n  out = tf_keras.layers.BatchNormalization()(out)\n  out = tf_keras.layers.Activation('relu')(out)\n\n  out = tfp.layers.Convolution2DFlipout(\n      filters,\n      kernel,\n      padding='same',\n      kernel_posterior_fn=kernel_posterior_fn)(out)\n  out = tf_keras.layers.BatchNormalization()(out)\n  out = tf_keras.layers.Activation('relu')(out)\n\n  out = tf_keras.layers.MaxPooling2D(\n      pool_size=(2, 2), strides=stride)(out)\n  return out\n",
      "asOf": "2026-11-20"
    },
    "F262": {
      "label": "Project source file, tf-keras",
      "display": "tensorflow_probability/examples/models/bayesian_vgg.py",
      "asOf": "2026-11-20"
    },
    "F263": {
      "label": "Project full_name, tf-keras",
      "display": "tensorflow/probability",
      "asOf": "2026-11-20"
    },
    "F264": {
      "label": "Project stargazers_count, tf-keras",
      "display": "4.4K",
      "asOf": "2026-11-20"
    },
    "F265": {
      "label": "Library name, vit-pytorch",
      "display": "vit-pytorch",
      "asOf": "2026-11-20"
    },
    "F266": {
      "label": "Monthly downloads, vit-pytorch",
      "display": "552.8K",
      "asOf": "2026-11-20"
    },
    "F267": {
      "label": "License, vit-pytorch",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F268": {
      "label": "Package release, vit-pytorch",
      "display": "1.26.14",
      "asOf": "2026-11-20"
    },
    "F269": {
      "label": "Package release date, vit-pytorch",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F270": {
      "label": "Install, vit-pytorch",
      "display": "pip install vit-pytorch",
      "asOf": "2026-11-20"
    },
    "F271": {
      "label": "Quickstart, vit-pytorch",
      "display": "import torch\nfrom vit_pytorch import ViT\n\nmodel = ViT(image_size=256, patch_size=32, num_classes=1000, dim=1024, depth=6, heads=16, mlp_dim=2048)\nprint(model(torch.randn(1, 3, 256, 256)).shape)\n",
      "asOf": "2026-11-20"
    },
    "F272": {
      "label": "Official description, vit-pytorch",
      "display": "Implements the Vision Transformer (ViT) in PyTorch.",
      "asOf": "2026-11-20"
    },
    "F273": {
      "label": "Quickstart source file, vit-pytorch",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F274": {
      "label": "Repository stars, vit-pytorch",
      "display": "25.6K",
      "asOf": "2026-11-20"
    },
    "F275": {
      "label": "Pretrained classifier factory, vit-pytorch",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F276": {
      "label": "TensorFlow training, vit-pytorch",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F277": {
      "label": "Native classification role, vit-pytorch",
      "display": "Explicit configurable ViT architecture construction and training,without native named pretrained registry.",
      "asOf": "2026-11-20"
    },
    "F278": {
      "label": "Training backends, vit-pytorch",
      "display": "PyTorch.",
      "asOf": "2026-11-20"
    },
    "F279": {
      "label": "Pretrained assets and label space, vit-pytorch",
      "display": "Compared native ViT constructor builds a randomly initialized architecture,not a bundled named pretrained classifier/weight registry. User state_dict or separate third-party checkpoints remain possible; no blanket inability to use learned weights.",
      "asOf": "2026-11-20"
    },
    "F280": {
      "label": "Host and model prerequisites, vit-pytorch",
      "display": "Compatible Torch runtime. This is the official randomly initialized model/input-shape first forward call,not a useful pretrained image prediction. Train/load compatible learned weights before semantic classification.",
      "asOf": "2026-11-20"
    },
    "F281": {
      "label": "Exact external integration contract, vit-pytorch",
      "display": "Native ViT forward returns [batch,num_outputs] logits. Host slices per-task heads,applies softmax or sigmoid,and optionally computes Torch CE/BCE losses; returns(outputs,losses). Model constructed here has random initialization unless compatible learned state is separately loaded. Torch computations are peer operations.",
      "asOf": "2026-11-20"
    },
    "F282": {
      "label": "Project function, vit-pytorch",
      "display": "def forward(self, image_list, targets=None, selected_task=None):\n    images = torch.stack(image_list, dim=0)\n    logits = self.backbone(images)\n\n    outputs = []\n    losses = []\n\n    for task_idx, task in enumerate(self.tasks):\n        cur_logits = logits[:, self.task_output_offsets[task_idx]:self.task_output_offsets[task_idx+1]]\n\n        if task['type'] == 'classification':\n            cur_outputs = torch.nn.functional.softmax(cur_logits, dim=1)\n\n            if targets is not None:\n                cur_valid = torch.stack([target[task_idx]['valid'] for target in targets], dim=0)\n                cur_targets = torch.cat([target[task_idx]['label'] for target in targets], dim=0).to(torch.long)\n                loss = torch.nn.functional.cross_entropy(cur_logits, cur_targets, reduction='none') * cur_valid\n                losses.append(loss.mean())\n        elif task['type'] == 'multi-label-classification':\n            cur_outputs = torch.sigmoid(cur_logits)\n\n            if targets is not None:\n                cur_valid = torch.stack([target[task_idx]['valid'] for target in targets], dim=0)\n                cur_targets = torch.stack([target[task_idx]['labels'] for target in targets], dim=0).to(torch.float32)\n                loss = torch.nn.functional.binary_cross_entropy_with_logits(cur_logits, cur_targets.squeeze(), reduction='none') * cur_valid\n                losses.append(loss.mean())\n\n        outputs.append(cur_outputs)\n\n    if len(losses) > 0:\n        losses = torch.stack(losses, dim=0)\n    else:\n        losses = torch.tensor(0, device=images.device, dtype=torch.float32)\n\n    return outputs, losses\n",
      "asOf": "2026-11-20"
    },
    "F283": {
      "label": "Project source file, vit-pytorch",
      "display": "satlas/model/classify.py",
      "asOf": "2026-11-20"
    },
    "F284": {
      "label": "Project full_name, vit-pytorch",
      "display": "allenai/satlas",
      "asOf": "2026-11-20"
    },
    "F285": {
      "label": "Project stargazers_count, vit-pytorch",
      "display": "291",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python image classification libraries TorchVision timm Transformers TensorFlow code examples pretrained classifiers preprocessing custom labels",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
