Downloads · 30 days
5
17% of all-time downloads
Purino/resnet50-nih-chestxray-4class
resnet50-nih-chestxray-4class is a image classification model from Purino. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
Fine-tune từ trọng số ImageNet1k, phân loại ĐƠN-NHÃN (single-label, softmax) giữa 4 bệnh lý lồng ngực phổ biến nhất trong bộ NIH ChestX-ray14 (chỉ dùng ảnh mang đúng 1 bệnh, loại ảnh "No Finding" và ảnh đa-bệnh). 4 lớ…
Downloads · 30 days
5
17% of all-time downloads
All-time downloads
29
Public
Parameters
23.6M
95 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors94.3 MB · 99%
From the Hugging Face model README
Fine-tune từ trọng số ImageNet1k, phân loại ĐƠN-NHÃN (single-label, softmax) giữa 4 bệnh lý lồng ngực phổ biến nhất trong bộ NIH ChestX-ray14 (chỉ dùng ảnh mang đúng 1 bệnh, loại ảnh "No Finding" và ảnh đa-bệnh). 4 lớp: Infiltration, Atelectasis, Effusion, Nodule.
Huấn luyện trên subset cân bằng 8000 ảnh (không phải toàn bộ 112.120 ảnh gốc), early stopping theo Val Macro-AUROC.
model.layer1 -> layer2 -> layer3 -> layer4 (các block conv) -> AdaptiveAvgPool2d
-> 1 Linear duy nhất (model.fc, 4 lớp output, softmax). Không có
lớp fully-connected trung gian nào khác, nên đây là kiến trúc kinh điển tương thích CAM
(Zhou et al. dùng chính ResNet/GoogLeNet cho bài báo gốc) và Grad-CAM: hook vào
model.layer4[-1] để lấy feature map 2048-kênh cuối cùng trước GAP.
import torch, json
from torchvision import models
from safetensors.torch import load_file
from huggingface_hub import hf_hub_download
repo_id = "Purino/resnet50-nih-chestxray-4class"
config = json.load(open(hf_hub_download(repo_id, "config.json")))
weights_path = hf_hub_download(repo_id, "model.safetensors")
model = models.resnet50(weights=None)
model.fc = torch.nn.Linear(model.fc.in_features, config["num_labels"])
model.load_state_dict(load_file(weights_path))
model.eval()
# dự đoán: probs = torch.softmax(model(x), dim=1); class_idx = probs.argmax(dim=1)
Xem file inference_gradcam_example.py trong repo này — chạy được ngay, tạo heatmap
Grad-CAM cho ảnh X-quang bất kỳ trong 1 trong 4 lớp trên. Có thể
đối chiếu định tính với BBox_List_2017.csv của bộ dữ liệu gốc (bounding box tổn
thương do bác sĩ khoanh trên ~1.000 ảnh) để kiểm tra vùng CAM có trùng vùng tổn
thương thật hay không.
train_split.csv / val_split.csv / test_split.csv để biết chính xác ảnh nào
thuộc tập nào.MAX_PER_CLASS).NUM_SELECTED_CLASSES).