Skip to main content

fsdetection

fsdetection is a Python package for few-shot object detection, inspired by the simplicity and flexibility of Hugging Face libraries. With fsdetection, you can quickly experiment with few-shot learning for object detection tasks, easily integrate it with popular frameworks, and customize detection models with minimal data.

Features

  • Few-Shot Object Detection: Fine-tune object detection models with only a few examples per class.
  • Cross-Domain Adaptation: Effortlessly adapt models to new domains.
  • Modular Design: Build and customize models with a clean, intuitive API.
  • Pre-trained Models: Access a range of pre-trained models as a starting point for your tasks.

Installation

Install fsdetection directly from PyPI:

pip install fsdetection

LoRA script implementation

https://github.com/Baijiong-Lin/LoRA-Torch

def replace_lora(model, module_name, rank):
    for sub_module_name in model._modules:
        cuurent_module_name = sub_module_name if module_name == "" else module_name + "." + sub_module_name

        if len(model._modules[sub_module_name]._modules) > 1:
            replace_lora(model._modules[sub_module_name], cuurent_module_name, rank=rank)
        else:
            if isinstance(model._modules[sub_module_name], nn.Conv2d):
                model._modules[sub_module_name] = LoraConv2d(
                    in_channels=model._modules[sub_module_name].in_channels,
                    out_channels=model._modules[sub_module_name].out_channels,
                    kernel_size=model._modules[sub_module_name].kernel_size[0],
                    stride=model._modules[sub_module_name].stride,
                    padding=model._modules[sub_module_name].padding,
                    padding_mode=model._modules[sub_module_name].padding_mode,
                    dilation=model._modules[sub_module_name].dilation,
                    groups=model._modules[sub_module_name].groups,
                    bias=model._modules[sub_module_name].bias is not None,
                    norm=model._modules[sub_module_name].norm,
                    r=rank
                ).to('cuda')
            elif isinstance(model._modules[sub_module_name], nn.MultiheadAttention):
                model._modules[sub_module_name] = lora.MultiheadAttention(
                    model._modules[sub_module_name].embed_dim,
                    model._modules[sub_module_name].num_heads,
                    dropout=model._modules[sub_module_name].dropout,
                    r=rank
                ).to('cuda')
            elif isinstance(model._modules[sub_module_name], nn.Linear):
                model._modules[sub_module_name] = lora.Linear(
                    model._modules[sub_module_name].in_features,
                    model._modules[sub_module_name].out_features,
                    bias=model._modules[sub_module_name].bias is not None,
                    r=rank
                ).to('cuda')
            else:
                if len(model._modules[sub_module_name]._modules) > 0:
                    replace_lora(model._modules[sub_module_name], cuurent_module_name, rank=rank)


class LoraTrainer(FineTuningTrainer):
    def __init__(self, cfg):
        super().__init__(cfg)

    @classmethod
    def build_model(cls, cfg, is_finetuned=False):
        model = super().build_model(cfg, is_finetuned)
        replace_lora(model, "", rank=cfg.FINETUNE.LORA.RANK)
        return model

Metadata

Release files for fsdetection 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fsdetection 0.0.5
File Size Uploaded Provenance Actions
fsdetection-0.0.5.tar.gz 15.0 kB Without provenance Details for fsdetection-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fsdetection 0.0.5
File Interpreter ABI Platform Actions
fsdetection-0.0.5-py3-none-any.whl Python 3 none any Details for fsdetection-0.0.5-py3-none-any.whl

Total release size: 30.1 kB

Release files / fsdetection-0.0.5.tar.gz

Download URL fsdetection-0.0.5.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f9b0afdfd05bca7321e25dd21ae576e101b31686bf0ea7b0f1dac91fc17e91b9
BLAKE2b-256 checksum
How to use checksums
e2d45a21acfc26e2df5c709a08e8242dccfdb7efa6631dbfcc052f01e6693bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / fsdetection-0.0.5-py3-none-any.whl

Download URL fsdetection-0.0.5-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18bdeb68fc95c750ed42c834d9598ad51cd9b332176501aa2a4b049c2513b755
BLAKE2b-256 checksum
How to use checksums
f166be0b2c2bc328f7f2cf49965aa775a998b34f288c54074178876aec4924ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for fsdetection 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page