How to Create a Training Dataset for Photo-Based Card Grading
In this article
This guide walks you through building a high-quality image dataset for training a machine learning model to assess the condition of trading cards (sports cards, Pokémon, etc.) from photos. A well-structured dataset is the foundation for accurate grading of corners, edges, surfaces, and centering. You'll need a camera or scanner, a consistent setup, and a systematic approach to labeling.
What You'll Need
- A camera (phone camera works) or a flatbed scanner
- A consistent lighting setup (e.g., two lamps at 45-degree angles)
- A card holder or stand to keep cards flat and in a fixed position
- A computer with spreadsheet software (Excel, Google Sheets) for labeling
- Optional: a magnifying glass or loupe for close inspection
- Access to a labeling tool (e.g., LabelImg, CVAT, or a simple CSV)
Step-by-Step
- Define your grading criteria. Decide what conditions you want the model to detect. Common categories: corners (sharp vs. rounded), edges (clean vs. chipped), surface (scratches, print lines), and centering (front/back balance). Create a scale (e.g., 1-10 or Good/Fair/Excellent) for each.
- Gather a diverse set of cards. Collect cards of various ages, brands, and conditions. Include cards with obvious defects and near-mint examples. Aim for at least 100-200 images per condition category for a robust dataset, but start smaller if needed.
- Set up a consistent photo station. Use a tripod or fixed stand. Place the card on a neutral background (black or white). Ensure lighting is even—avoid glare by using diffused light. The card should fill the frame, with the entire card visible.
- Capture images systematically. Take photos of the front and back of each card. For each side, capture at least one straight-on shot. If you're grading corners or edges, you may also take close-up shots of each corner or edge segment—but keep the same distance and angle for all cards.
- Use a consistent file naming convention. Example:
CardID_Front.jpg,CardID_Back.jpg. This will make labeling and tracking easier. - Label each image. For each photo, record the card ID, side (front/back), and the grade for each criterion (e.g., corners=8, edges=7, surface=9, centering=8). Use a spreadsheet or a labeling tool that allows bounding boxes if you want to localize defects.
- Split your dataset. Divide the labeled images into training (70%), validation (15%), and test (15%) sets. Ensure each set has a similar distribution of grades and card types.
- Augment your images (optional). To improve model robustness, apply slight rotations, brightness changes, or zoom crops. Do this after splitting to avoid data leakage.
- Document your dataset. Create a README file describing the criteria, scale, and any exceptions. This is crucial for reproducibility.
Common Mistakes
- Inconsistent lighting: Shadows or glare can confuse the model. Keep lighting identical across all images.
- Inconsistent framing: If the card is at different distances or angles, the model may learn to measure size rather than condition.
- Labeling bias: If you grade cards yourself, you may be inconsistent. Have multiple people grade and average scores, or use a clear rubric.
- Ignoring centering: Centering is a key grading factor—make sure you include it in your labels.
- Too few examples of defects: If your dataset only has mint cards, the model won't learn to detect damage.
Tips
- Use a scanner for perfectly flat, glare-free images—especially for surface grading.
- Take multiple photos of the same card under slight angle changes to simulate real-world conditions.
- Start with a small pilot dataset (e.g., 30 cards) to test your labeling scheme before scaling up.
- Use a loupe to verify defects when labeling—your eyes are the ground truth.
- Store images in a lossless format (PNG or TIFF) to avoid compression artifacts.
Troubleshooting
- Model performs poorly on new cards: Likely overfitting. Increase dataset size, add augmentation, or simplify the grading scale.
- Images have inconsistent brightness: Use a fixed white balance and manual exposure settings on your camera.
- Labels are inconsistent between graders: Create a detailed rubric with example images for each grade level, and conduct a calibration session.
- Card edges are blurred: Use a smaller aperture (higher f-stop) for greater depth of field, or use a scanner.
- Dataset is too small: Consider using transfer learning with a pre-trained model (e.g., ResNet) and fine-tune on your images.
Frequently Asked Questions
How many images do I need to start?
For a proof-of-concept, 50-100 images per category can work. For production, aim for 1,000+ images per category.
Should I use photos or scans?
Scans are more consistent, but photos better represent real-world user submissions. Use both if possible.
What resolution should the images be?
At least 300 DPI for scans, or 12+ megapixels for photos. The card should be at least 1000 pixels across.
Can I use a pre-trained model?
Yes, transfer learning is highly recommended. Start with a model trained on general objects and fine-tune on your card images.
How do I handle centering if the card is slightly rotated?
Use image preprocessing to straighten the card based on edge detection before labeling centering.
What if my labels are subjective?
That's okay—grading is subjective. Just be consistent. Consider using a 5-point scale instead of 10 to reduce ambiguity.