--- tags: - computer-vision - defect-detection - pytorch - onnx library_name: pytorch --- # Defect Classifier (ResNet18) Steel surface defect classification model trained on NEU-DET dataset. ## Model Details - **Architecture**: ResNet18 - **Classes**: 6 defect types (crazing, inclusion, patches, pitted_surface, rolled-in_scale, scratches) - **Input**: 224x224 RGB images - **Formats**: PyTorch (.pth), ONNX (.onnx) ## Files - `pytorch_model.pth`: PyTorch checkpoint - `model.onnx`: ONNX format for deployment - `metadata.json`: Model configuration - `training_history.json`: Training metrics ## Usage ### PyTorch ```python import torch from torchvision import models from huggingface_hub import hf_hub_download # Download model model_path = hf_hub_download(repo_id="Seif-melz/defect-classifier-resnet18", filename="pytorch_model.pth") # Load model model = models.resnet18() model.fc = torch.nn.Linear(model.fc.in_features, 6) checkpoint = torch.load(model_path, map_location='cpu') model.load_state_dict(checkpoint['model_state_dict']) model.eval() ``` ### ONNX ```python import onnxruntime as ort from huggingface_hub import hf_hub_download # Download ONNX model model_path = hf_hub_download(repo_id="Seif-melz/defect-classifier-resnet18", filename="model.onnx") # Load with ONNX Runtime session = ort.InferenceSession(model_path) ``` ## Training See training history in `training_history.json` for detailed metrics.