ViT

고전 Vision Transformer는 학습된 클래스 토큰과 고정 크기 이미지 패치에 적용되는 순수 트랜스포머이며 컨볼루션을 사용하지 않습니다. LibreYOLO는 이미지 분류용 AugReg 사전 학습 크기 4개를 제공합니다.

작업
classify
크기
ti, s, b, l at 224 px
설치
pip install libreyolo
지원 티어
추론 전용, v부터 지원. 예측, 검증, 내보내기만 지원합니다. 학습 기능은 적용되지 않습니다.
업스트림
Google Research의 ViT, Apache-2.0. 논문, 소스
라이선스
코드 Apache-2.0, 가중치 Apache-2.0. 상업적 사용

설치

ViT에는 선택적 extra가 필요하지 않습니다. 가져오는 모든 항목이 기본 설치에 포함됩니다.

bash
pip install libreyolo

예측

가중치는 처음 사용할 때 Hugging Face에서 내려받아 로컬에 캐시됩니다.

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreViTti-cls.pt")result = model(SAMPLE_IMAGE, save=True) probs = result.probsprint(probs.top1, probs.top1conf)print(probs.top5, probs.top5conf)
CLI
libreyolo predict model=LibreViTti-cls.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True

분류기는 result.boxes 대신 result.probs를 반환합니다. top1top5는 클래스 인덱스를, top1conftop5conf는 해당 신뢰도를 제공합니다. 전처리는 timm의 AugReg 평가 레시피에 따라 0.9 크롭 비율의 bicubic 보간을 사용하여 고정 224px 입력으로 크기를 조정하고 중앙 크롭합니다. 소스, 스트리밍, 결과 처리는 예측을 참조합니다.

변형

tiny부터 large까지 크기 4개가 있으며 모두 고정 224px patch-16 그래프를 공유하고 임베딩 너비와 트랜스포머 깊이가 다릅니다. LibreYOLO는 이 계열을 추론 전용으로 제공합니다. 예측, ImageNet 방식 top-1/top-5 검증, 내보내기를 지원하며 AugReg 파인튜닝 레시피는 구현되지 않았습니다.

검증

val()은 ImageFolder 방식 분할(train/val/ 하위 폴더와 클래스별 폴더가 있는 디렉터리)을 대상으로 실행하고 top-1 및 top-5 정확도를 반환합니다.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreViTti-cls.pt") # data는 데이터셋 YAML이 아니라 train/ 및 val/ 클래스 폴더 분할이 있는# 디렉터리 루트(ImageFolder 레이아웃)입니다.metrics = model.val(data="imagenet-1k/") print(metrics["metrics/accuracy_top1"])print(metrics["metrics/accuracy_top5"])
CLI
libreyolo val model=LibreViTti-cls.pt data=imagenet-1k/

내보내기

작업ONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
classifyclassify to ONNX: 지원함classify to TorchScript: 지원함classify to ExecuTorch: 지원함classify to TensorRT: 지원함classify to OpenVINO: 지원함classify to Paddle: 지원하지 않음classify to MNN: 지원하지 않음classify to RKNN: 지원하지 않음classify to ncnn: 지원함classify to TFLite: 지원하지 않음classify to CoreML: 지원하지 않음classify to Core AI: 지원하지 않음

내보낸 아티팩트는 파일 접미사에 따라 LibreYOLO()로 다시 불러오므로 .onnx 또는 .engine 파일이 체크포인트처럼 동작하며 동일한 Results를 반환합니다. 내보내기에는 모든 형식이 허용하는 인수와 일부 형식이 추가하는 extra가 나열되어 있습니다.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreViTti-cls.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibreViTti-cls.pt format=onnxlibreyolo export model=LibreViTti-cls.pt format=tensorrt half=True
내보낸 파일 사용하기
from libreyolo import LibreYOLO, SAMPLE_IMAGE # 팩토리는 파일 접미사로 라우팅하므로 내보낸 아티팩트도# 체크포인트처럼 불러오며 동일한 Results 객체를 반환합니다.model = LibreYOLO("LibreViTti-cls.onnx")result = model(SAMPLE_IMAGE) print(result.probs.top1)

체크포인트

이 계열에서 공개된 모든 가중치 파일입니다.

파일입력(px)가중치 라이선스
classify
LibreViTti-cls.pt224apache-2.0
LibreViTs-cls.pt224apache-2.0
LibreViTb-cls.pt224apache-2.0
LibreViTl-cls.pt224apache-2.0

위의 모든 파일은 현재 LibreYOLO 조직에 있으며 처음 사용할 때 내려받습니다.

라이선스

내려받는 특정 가중치의 Hugging Face 저장소에서 라이선스를 확인하십시오. LibreYOLO 조직의 모든 체크포인트에는 라이선스가 있으며 한 계열 안에서도 항상 같지는 않습니다. 해당 저장소가 신뢰할 수 있는 기준입니다. 아래 요약은 이 페이지를 마지막으로 검증했을 때 적용된 내용을 설명합니다.

관련 라이선스에 관한 설명이며 법률 자문이 아닙니다. 상업적으로 중요한 사안이라면 라이선스를 직접 읽고 별도의 법률 자문을 받으십시오.

원작
ViT, Google Research
업스트림 라이선스
Apache-2.0
LibreYOLO 코드
MIT
가중치
Apache-2.0, huggingface.co/LibreYOLO에 다시 게시됨
해석
Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code. LibreYOLO's runtime code for this family is a derived port of the Apache-2.0 timm Vision Transformer implementation (Ross Wightman, huggingface/pytorch-image-models), kept checkpoint-compatible with the shipped tensors. The four AugReg checkpoints themselves are timm's Apache-2.0 conversion of Google Research's own AugReg pretraining, so the code and the weights carry the same permissive terms end to end.

인용

@article{dosovitskiy2020vit,
  title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
  author={Dosovitskiy, Alexey and Beyer, Lucas and Kolesnikov, Alexander and Weissenborn, Dirk and Zhai, Xiaohua and Unterthiner, Thomas and  Dehghani, Mostafa and Minderer, Matthias and Heigold, Georg and Gelly, Sylvain and Uszkoreit, Jakob and Houlsby, Neil},
  journal={ICLR},
  year={2021}
}

@article{steiner2021augreg,
  title={How to train your ViT? Data, Augmentation, and Regularization in Vision Transformers},
  author={Steiner, Andreas and Kolesnikov, Alexander and and Zhai, Xiaohua and Wightman, Ross and Uszkoreit, Jakob and Beyer, Lucas},
  journal={arXiv preprint arXiv:2106.10270},
  year={2021}
}

github.com/google-research/vision_transformer#bibtex에 있는 저자의 인용 블록에서 복사했습니다.

LibreYOLO v1.5.0에서 검증되었습니다. 이 페이지의 지원 표, 체크포인트, 벤치마크 수치는 출시된 라이브러리와 공개된 가중치에서 생성되며 수동으로 작성되지 않습니다.