U-Net
U-Net performs semantic segmentation with an encoder, skip connections and an upsampling decoder.
- Tác vụ
- semantic segmentation
- Cài đặt
pip install libreyolo- Bậc hỗ trợ
- Được hỗ trợ, từ v1.6.0. Các mô hình huấn luyện bổ trợ: luôn giữ CI ở trạng thái xanh, tính năng được bổ sung khi có cơ hội.
- Giấy phép
- Mã nguồn MIT, trọng số Apache-2.0. Sử dụng thương mại
Install
pip install "libreyolo"Predict
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreUNets-sem.pt", device="cpu")result = model(SAMPLE_IMAGE) mask = result.semantic_maskprint(mask.data.shape) # (H, W) class idsprint(mask.classes) # sorted class ids present in the imageWeights download from Hugging Face on first use and are cached locally. LibreUNets-sem.pt is a conversion of the Cityscapes UNet-S5-D16 checkpoint from mmsegmentation: the same-padded S5-D16 graph with an FCN head, predicting the 19 Cityscapes classes. Prediction runs the whole frame on the 1024x2048 evaluation canvas.
Train
Use a semantic dataset with image/mask pairs. Training defaults to 160 epochs, batch 4 and amp=False, with a (512, 1024) crop and (1024, 2048) evaluation canvas. The loss includes an auxiliary head. Export is not supported.
Dataset setup describes the required training data.
from libreyolo import LibreUNet # Random initialization: this trains from scratch.model = LibreUNet(size="s", device="cpu")# Replace with your semantic segmentation dataset YAML (image/mask pairs).model.train(data="path/to/your/semantic_dataset.yaml", pretrained=False, epochs=1, device="cpu", workers=0)Validate
from libreyolo import LibreYOLO # Or a U-Net checkpoint you trained with model.train().model = LibreYOLO("LibreUNets-sem.pt", device="cpu")# Replace with your semantic segmentation dataset YAML (image/mask pairs).metrics = model.val(data="path/to/your/semantic_dataset.yaml", workers=0)print(metrics)Use the dataset format for this task. Validation explains the dataset requirements and returned metrics.
Checkpoints
| Tệp | Giấy phép trọng số |
|---|---|
| Semantic segmentation | |
| LibreUNets-sem.pt | apache-2.0 |
Mọi tệp ở trên hiện đều có trong tổ chức LibreYOLO và được tải xuống trong lần sử dụng đầu tiên.
Licensing
Hãy kiểm tra giấy phép trong repo Hugging Face của trọng số cụ thể mà bạn tải xuống. Mỗi checkpoint trong tổ chức LibreYOLO đều có giấy phép riêng và giấy phép có thể khác nhau trong cùng một họ. Repo đó là nguồn có thẩm quyền; phần tóm tắt dưới đây mô tả các điều khoản áp dụng khi trang này được kiểm chứng lần gần nhất.
Đây là phần mô tả các giấy phép liên quan, không phải tư vấn pháp lý. Nếu câu trả lời có ý nghĩa về mặt thương mại, hãy tự đọc các giấy phép và tham khảo cố vấn của riêng bạn.
- Công trình gốc
- U-Net, U-Net authors
- Giấy phép thượng nguồn
- Apache-2.0
- Nguồn thượng nguồn
- github.com/open-mmlab/mmsegmentation
- Mã nguồn LibreYOLO
- MIT
- Trọng số
- Apache-2.0, được phát hành lại tại huggingface.co/LibreYOLO
- Diễn giải
- Apache-2.0 is a permissive license, so this code and 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 you redistribute, and it grants a patent license. LibreYOLO's port follows mmsegmentation's Apache-2.0 UNet-S5-D16 implementation with an FCN head, and LibreUNets-sem.pt is a conversion of mmsegmentation's Cityscapes checkpoint, which upstream releases under Apache-2.0.