SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.01293 · NeurIPS · 2023

LoCoOp: Few-Shot Out-of-Distribution Detection via Prompt Learning

Atsuyuki Miyai, Qing Yu, Go Irie, Kiyoharu Aizawa

arXiv · PDF · Open in the Atlas

Code that ran

9 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 6 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2306.01293.json · badge: /api/ran/2306.01293.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
AtsuMiyai/LoCoOp canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
basic_clean Ran
ran; our contract draft was wrong, not the code
AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py
pointer only (licence: MIT); the stored copy get_code serves, from ltpwy/MSCI, is pointer only (licence: NONE) · get_code("98f385d847636a3e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from ltpwy/MSCI, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

entropy_select_topk Ran
ran; our contract draft was wrong, not the code
AtsuMiyai/LoCoOp/trainers/locoop.py
pointer only (licence: MIT); the stored copy get_code serves, from tmlr-group/SCT, is pointer only (licence: NONE) · get_code("65319c2dbd4ac5e8")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from tmlr-group/SCT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

fpr_and_fdr_at_recall Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
AtsuMiyai/LoCoOp/utils/detection_util.py
pointer only (licence: MIT); the stored copy get_code serves, from liujunzhuo/FineCops-Ref, is pointer only (licence: NONE) · get_code("3853ecdb6fc74451")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from liujunzhuo/FineCops-Ref, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_measures Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
AtsuMiyai/LoCoOp/utils/detection_util.py
pointer only (licence: MIT); the stored copy get_code serves, from tmlr-group/SCT, is pointer only (licence: NONE) · get_code("24570af601666d85")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from tmlr-group/SCT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_pairs Ran
ran; our contract draft was wrong, not the code
AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py
code served (permissive licence) · get_code("d919ae32e5e4e616")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned set. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function get_pairs takes a word parameter
# A word is represented as a tuple of symbols (variable-length strings)
# The function iterates through the word and creates pairs of consecutive symbols

word = ("hello", "world", "test")

ARGS = {
    "word": word
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type set — a set output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a set output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_resize_image Ran
ran on a synthesized input
AtsuMiyai/LoCoOp/demo_visualization.py
code served (permissive licence) · get_code("f8757a034583434b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 3, dtype family int, shape (40, 50, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from PIL import Image
import tempfile
import os

# Create a temporary directory for test images
temp_dir = tempfile.mkdtemp()

# Create a small test image and save it
test_image = Image.new('RGB', (100, 80), color=(73, 109, 137))
image_path = os.path.join(temp_dir, 'test_image.png')
test_image.save(image_path)

ARGS = {
    'image_path': image_path,
    'new_size': (50, 40)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (40, 50, 3) — shape (40, 50, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
set_val_loader Ran
ran on a synthesized input
AtsuMiyai/LoCoOp/utils/train_eval_util.py
code served (permissive licence) · get_code("eb2c2fac20121ca2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataLoader. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import Mock, MagicMock
import torchvision.transforms as transforms

torch.manual_seed(0)

# Create a mock args object with required attributes
args = Mock()
args.in_dataset = 'imagenet'
args.root = '/tmp'
args.batch_size = 2

# Create a minimal stand-in for ImageFolder that returns a dataloader-like object
class MockImageFolder:
    def __init__(self, path, transform=None):
        self.path = path
        self.transform = transform
        self.samples = [
            ('img1.jpg', 0),
            ('img2.jpg', 1),
            ('img3.jpg', 0),
            ('img4.jpg', 1),
        ]
    
    def __len__(self):
        return len(self.samples)
    
    def __getitem__(self, idx):
        # Return a small dummy tensor (3 channels, 4x4 image) and a label
        x = torch.randn(3, 4, 4)
        y = self.samples[idx][1]
        if self.transform:
            x = self.transform(x)
        return x, y

# Monkey-patch datasets.ImageFolder
import torchvision.datasets as datasets
original_imagefolder = datasets.ImageFolder
datasets.ImageFolder = MockImageFolder

# Create preprocess transform
normalize = transforms.Normalize(
    mean=(0.48145466, 0.4578275, 0.40821073),
    std=(0.26862954, 0.26130258, 0.27577711)
)
preprocess = transforms.Compose([
    transforms.ToTensor(),
    normalize
])

ARGS = {
    'args': args,
    'preprocess': preprocess
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
stable_cumsum Ran
ran, honoured the contract we drafted
AtsuMiyai/LoCoOp/utils/detection_util.py
pointer only (licence: MIT); the stored copy get_code serves, from fanghenshaometeor/ood-kernel-pca-ext, is pointer only (licence: NONE) · get_code("d4acb3120a027622")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from fanghenshaometeor/ood-kernel-pca-ext, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

whitespace_clean Ran
ran; our contract draft was wrong, not the code
AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py
pointer only (licence: MIT); the stored copy get_code serves, from ltpwy/MSCI, is pointer only (licence: NONE) · get_code("9542161e9640b858")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from ltpwy/MSCI, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

build_model Not yet run
unverified (harvested, no recorded run)
AtsuMiyai/LoCoOp/clip_w_local/model.py
pointer only (licence: MIT); the stored copy get_code serves, from tmlr-group/SCT, is pointer only (licence: NONE) · get_code("dbbf313e1d3a69ba")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from tmlr-group/SCT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

load Not yet run
unverified (harvested, no recorded run)
AtsuMiyai/LoCoOp/clip_w_local/clip.py
code served (permissive licence) · get_code("fbf8c0143d9c48e3")
How it ran

no invocation recorded.

set_ood_loader_ImageNet Not yet run
unverified (harvested, no recorded run)
AtsuMiyai/LoCoOp/utils/train_eval_util.py
code served (permissive licence) · get_code("eb7800d0c58c4a14")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 9 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 7 the same month, 9 later) and 3 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_pairs 258 other papers
58 dated earlier, 2 the same month, 190 later, 7 same year, order not determinable, 1 undated · 4 only as an assembly brick
1802.06474 (2018-02)
A Closed-form Solution to Photorealistic Image Stylization
1803.01128 (2018-03)
Seq2Sick: Evaluating the Robustness of Sequence-to-Sequence Models with Adversarial Examples
1809.00125 (2018-09)
Simple Fusion: Return of the Language Model
and 255 more not named here
whitespace_clean 231 other papers
42 dated earlier, 2 the same month, 181 later, 5 same year, order not determinable, 1 undated · 4 only as an assembly brick
1901.07441 (2019-01)
PadChest: A large chest x-ray image dataset with multi-label annotated reports
2107.06383 (2021-07)
How Much Can CLIP Benefit Vision-and-Language Tasks?
2108.10904 (2021-08)
SimVLM: Simple Visual Language Model Pretraining with Weak Supervision
and 228 more not named here
basic_clean 218 other papers
42 dated earlier, 2 the same month, 168 later, 5 same year, order not determinable, 1 undated · 4 only as an assembly brick
1901.07441 (2019-01)
PadChest: A large chest x-ray image dataset with multi-label annotated reports
2107.06383 (2021-07)
How Much Can CLIP Benefit Vision-and-Language Tasks?
2108.10904 (2021-08)
SimVLM: Simple Visual Language Model Pretraining with Weak Supervision
and 215 more not named here
build_model 119 other papers
28 dated earlier, 1 the same month, 85 later, 3 same year, order not determinable, 2 undated
1809.11096 (2018-09)
Large Scale GAN Training for High Fidelity Natural Image Synthesis
1901.07441 (2019-01)
PadChest: A large chest x-ray image dataset with multi-label annotated reports
2104.14294 (2021-04)
Emerging Properties in Self-Supervised Vision Transformers
and 116 more not named here
load 88 other papers
10 dated earlier, 2 the same month, 72 later, 3 same year, order not determinable, 1 undated
2203.05557 (2022-03)
Conditional Prompt Learning for Vision-Language Models
2206.01986 (2022-06)
Delving into the Openness of CLIP
2207.12819 (2022-07)
S-Prompts Learning with Pre-trained Transformers: An Occam's Razor for Domain Incremental Learning
and 85 more not named here
stable_cumsum 29 other papers
12 dated earlier, 1 the same month, 15 later, 1 same year, order not determinable · 1 only as an assembly brick
1911.11132 (2019-11)
Scaling Out-of-Distribution Detection for Real-World Settings
2003.08440 (2020-03)
Synthesize then Compare: Detecting Failures and Anomalies for Semantic Segmentation
2104.08812 (2021-04)
Contrastive Out-of-Distribution Detection for Pretrained Transformers
and 26 more not named here
fpr_and_fdr_at_recall 5 other papers
1 dated earlier, 1 the same month, 3 later
2304.04521 (2023-04)
GL-MCM: Global and Local Maximum Concept Matching for Zero-Shot Out-of-Distribution Detection
2306.03715 (2023-06)
Unleashing Mask: Explore the Intrinsic Out-of-Distribution Detection Capability
2409.04796 (2024-09)
Local-Prompt: Extensible Local Prompts for Few-Shot Out-of-Distribution Detection
and 2 more not named here
get_measures 4 other papers
1 dated earlier, 3 later
2304.04521 (2023-04)
GL-MCM: Global and Local Maximum Concept Matching for Zero-Shot Out-of-Distribution Detection
2409.04796 (2024-09)
Local-Prompt: Extensible Local Prompts for Few-Shot Out-of-Distribution Detection
2409.14750 (2024-09)
FineCops-Ref: A new Dataset and Task for Fine-Grained Compositional Referring Expression Comprehension
and 1 more not named here
entropy_select_topk 1 other paper
1 later
2411.03359 (2024-11)
Self-Calibrated Tuning of Vision-Language Models for Out-of-Distribution Detection

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We present a novel vision-language prompt learning approach for few-shot out-ofdistribution (OOD) detection. Few-shot OOD detection aims to detect OOD images from classes that are unseen during training using only a few labeled in-distribution (ID) images. While prompt learning methods such as CoOp [60] have shown effectiveness and efficiency in few-shot ID classification, they still face limitations in OOD detection due to the potential presence of ID-irrelevant information in text embeddings. To address this issue, we introduce a new approach called Local regularized Context Optimization (LoCoOp), which performs OOD regularization that utilizes the portions of CLIP local features as OOD features during training. CLIP's local features have a lot of ID-irrelevant nuisances (e.g., backgrounds), and by learning to push them away from the ID class text embeddings, we can remove the nuisances in the ID class text embeddings and enhance the separation between ID and OOD. Experiments on the large-scale ImageNet OOD detection benchmarks demonstrate the superiority of our LoCoOp over zero-shot, fully supervised detection methods and prompt learning methods. Notably, even in a one-shot setting -just one label per class, LoCoOp outperforms existing zeroshot and fully supervised detection methods. The code is available via https: //github.com/AtsuMiyai/LoCoOp.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2306.01293")
get_code_for_paper("2306.01293")
have("2306.01293")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2306.01293.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2306.01293.svg)](https://syntology.ai/paper/2306.01293)

Connect an agent — have() is free.