EfficientNet-B3 finetuned for walnut shell defect classification across 4 categories.
Trained on the Nut Surface Defect Dataset with class remapping to match walnut-specific defect taxonomy.
Classes
Output Label
Remapped From (Dataset)
Healthy
Excellent
Black Spot
Rusting
Shriveled
Scratches
Damaged
Deformation + Fracture
Metrics (Epoch 8 — Best Checkpoint)
Class
Precision
Recall
F1
Healthy
0.88
1.00
0.93
Black Spot
1.00
0.99
1.00
Shriveled
1.00
0.98
0.99
Damaged
1.00
0.98
0.99
Macro Avg
0.97
0.99
0.98
Weighted Avg
0.99
0.99
0.99
Val Accuracy: 98.55% | Macro F1: 0.98
Training Setup
Parameter
Value
Base Model
EfficientNet-B3 (pretrained ImageNet)
Image Size
512×512 px
Batch Size
18 per GPU × 2 T4 = 36 effective
Optimizer
AdamW (lr=2e-5, wd=1e-2)
Scheduler
Cosine Annealing + 3-epoch warmup
Precision
FP16 (torch.cuda.amp)
Drop Rate
0.4
Label Smoothing
0.05
Early Stop Patience
7 epochs
Hardware
Kaggle 2× NVIDIA T4 (16 GB each)
Inference
import torch, timm
from PIL import Image
import torchvision.transforms as transforms
CLASSES = ["Healthy", "Black Spot", "Shriveled", "Damaged"]
model = timm.create_model("efficientnet_b3", pretrained=False,
num_classes=4, drop_rate=0.4)
ckpt = torch.load("best_model.pth", map_location="cpu")
state = {k.replace("module.", ""): v for k, v in ckpt["model_state_dict"].items()}
model.load_state_dict(state)
model.eval()
transform = transforms.Compose([
transforms.Resize((512, 512)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
img = Image.open("walnut.jpg").convert("RGB")
x = transform(img).unsqueeze(0)
probs = torch.softmax(model(x), dim=1)
conf, idx = probs.max(0)
print({"defect_class": CLASSES[idx.item()], "confidence": round(conf.item(), 4)})
License
Apache 2.0
Runs of Arko007 walnut-defect-classifier on huggingface.co
0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About walnut-defect-classifier huggingface.co Model
walnut-defect-classifier huggingface.co is an AI model on huggingface.co that provides walnut-defect-classifier's model effect (), which can be used instantly with this Arko007 walnut-defect-classifier model. huggingface.co supports a free trial of the walnut-defect-classifier model, and also provides paid use of the walnut-defect-classifier. Support call walnut-defect-classifier model through api, including Node.js, Python, http.
walnut-defect-classifier huggingface.co is an online trial and call api platform, which integrates walnut-defect-classifier's modeling effects, including api services, and provides a free online trial of walnut-defect-classifier, you can try walnut-defect-classifier online for free by clicking the link below.
Arko007 walnut-defect-classifier online free url in huggingface.co:
walnut-defect-classifier is an open source model from GitHub that offers a free installation service, and any user can find walnut-defect-classifier on GitHub to install. At the same time, huggingface.co provides the effect of walnut-defect-classifier install, users can directly use walnut-defect-classifier installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
walnut-defect-classifier install url in huggingface.co: