HW-202337458-backbone-swin-replacement
Assignment
커스텀 Backbone 모델 교체 실습 과제입니다.
Student
- Student ID: 202337458
- Hugging Face ID: hf-june
Backbone Replacement
- 기존 Backbone: ViT
- 교체 Backbone: Swin Transformer
- 사용 모델: microsoft/swin-tiny-patch4-window7-224
Required Code Included
- register_for_auto_class
- AutoConfig
- AutoModel
Files
- modeling_custom_swin.py
- backbone_swin_replacement.ipynb
- custom_swin_model/
- test_result.json
- README.md
How to Use
import torch
from modeling_custom_swin import CustomBackboneConfig, CustomSwinImageClassifier
config = CustomBackboneConfig()
model = CustomSwinImageClassifier(config)
pixel_values = torch.randn(2, 3, 224, 224)
labels = torch.tensor([0, 1])
outputs = model(pixel_values=pixel_values, labels=labels)
print(outputs.loss)
print(outputs.logits.shape)
Expected Output
torch.Size([2, 2])