Glasses Detector
[![Colab](https://raw.githubusercontent.com/mantasu/glasses-detector/main/docs/_static/svg/colab.svg)](https://colab.research.google.com/github/mantasu/glasses-detector/blob/main/notebooks/demo.ipynb)
[![Docs](https://github.com/mantasu/glasses-detector/actions/workflows/sphinx.yaml/badge.svg)](https://mantasu.github.io/glasses-detector/)
[![PyPI](https://img.shields.io/pypi/v/glasses-detector?color=yellow&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAsCAMAAAAQPRtoAAAB9VBMVEVHcEzY2Nnr6ufb2dDCxtDp6eXq6ufQz8rHycj5+vvo6OXm5d+9xctWfqDl5eTf393m5uPz8/Dbz6Zzkav40E/19fTu7u7f391Dcpnm5eOGnrJSha7vzmY7bJb00V9sjqr0yT7x8fB9mbHy8vL7+/vp6ObpzXTnzXnl5eTo5+X80kzg4N5OeZ309PFHc5rr6ujr0X/09PHy0GbpzXTx0Gjyykv7ySlZgKFUfZ9Xf6H29fJpiqd3lKxhhaRsj5jy8vI3danv7ur/0kIvZJH/////0kE1dKnu7eoyZpIuY5Ht7ek0c6r50VL90kc4dqorYpD40VVLfaY8eKr29vNLga780kvz8/E+bpcwZZHp6OXs7Oh4l7H39/Tr6uc3aZROg679/Pr/00NvkZg6d6xEfKxBcZlThrDy8OtHfqz20Vz/0j/62nZIdZtFc5r00WBKe6T+0kL357WUo4tPeZ750EuMp7z30VhXiLJjj7Rdh6nx8e4/eqv/yR3k5uaAnLQ4dqmXssn6ySitsYiYppHLvnPCz9hqkKC0xdKCnZ/u7ev5+PX3z0tQf6ZKeJ//3G3X2tzexmzz5br1y0TT3+p0nsF+pMT12oVXgaU6d6rw0W779d/55aX/2Fz/5pWoucbtzFnn3LHN1NhukKz279egvdb7yi7/++/yPOqTAAAAQHRSTlMAA+0iB9a7Egz+0HIXpT02gewsT+fPiEvdlSvVgPe0xNTFhMDxqUs7WrL1acny7U9g4ZvCz5f3kvjU+HNqfP2dYTAkVgAAA9RJREFUSMeN1nlD2kgYB2A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z2zsG+PcTKIvlyNEDHQZRT+AHJjG/tvHMglasEtgnMP7tn28pV1mXuc2hI2gElao1TyGYvlOfmqof4YOH9ot64ihrCeD4q6dO9OivvY5jx/dJLQjIXf2i+Q1hunwRFuhoIHzfZ63vIWMPjKUnT7QBWtyqKFaVXDjf1dO+h8sexQpDgk6gc69/FAbTNXOb+XLrn4n/AS3T2zxNRKClAAAAAElFTkSuQmCC)](https://pypi.org/project/glasses-detector/)
[![Python](https://img.shields.io/badge/python-ā„%203.12-blue?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAbqSURBVGiBxZp/bFVnGcc/77m3P6C4MBhWcCKFaDI2ox37w0YSWdhANxp/TDeFuCXESTTqtsoEHcY757Rp3TJ/zD9YpmEki6IxmRtxqBl3kdHxR80qmyMS4gZD2tBRgwJt7z3P1z/uPe05t/fXObfUJ3nT95znnPN+v8+v97nn1NGoSK67/4VOH3UhrfZNHZhWSHalUKukhZImJbuANCHTsMlOgr0hub95kxzI9t32VqMwXNIb12UOtra1cY/QV5CWS4YkZCr8DY4lCB/P1PtI+/yUu3/g4dtPzymRDf0H2ppc85+QukpBF8BaiEDd+hGTf8vL/V/4axJMXpKbmr2mB6ZJCJNeQfqjpPEAIGHgJaOCvt3JPdd1375Fc0ZExu3T1tWDB3Zu6Hz+Wxs3Oo8PI12MSSA8lhrj988NEclJurq48KRry/0wUB3Y+bEhyZ6JgrMSAiVhVqrHPjMnRG7tPbRQqKVo4VTTpVxzlKdaRQ0PVNWzgkwmNq7YN6RsojkEIDWeb3nss5l9zQDrH9q/SVJ3whwJPJRelwBXOu4NQCQsJG0dS7V9ev33njuH+SujAK2EgFGPPonEJnIBSM+08EIKG1+iJC/VJ5FkVasY51UBNqBPIrE9sih3bux86oqbDb9w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D8uvECIVquwh0LvT8okdJ2gaDT5Q9Z0/MBd/5ezU0QAXPPib0q2t1qIlfdCA2EzIxRrPCu64/6O15b1BQdTr4OymRvzwJ1rdzz9GxN3U2jv36nQjy4zC3miVqWpdzOrcU1QtQoyCu4foF9y7Uu/cNdNB3vsT28auacd34ZjABt3K381L+46cSXR2/hIqNS2alonbust2C50nnxhboHFgzlwTfbbzpUvLZUkgUe+2E4uNTyLfRIznnU23eRuzOarwJghCT0SA1TcXT2hxCdyAUiXNnZ1thrR607i9AzyVyDbBEr8zT8ZESjmSEN90htMqNN1Zv8NoKMf2Y6jvxEi8T/0tHr/mYVW47cBCQAmxp8IrXAxbn4kIuKW7b6I/GMNthrvjjx0XuvV0wswFBcTJA0t838C9vMKYUPN0II7dHTtn5m4tJfmee8BhT3yeBJIiRJMynicOPo02B0x8qJwPip5osZ8yl330l1JMCX6GOpcxljlbUH+g8ifTNAnBRKQGEfaxd+XbU2CBxr4N6dAdKy7A29yG6Y7kS2t0ieVk1M49uK0260+/Ga1C2tJw0QC0cF1adq5gcI/oHVhtgpP7YglOHcJaQzH24hXkY7g6WVWDwzFbUUqyf8ASQ3KW+bpq4sAAAAASUVORK5CYII=)](https://docs.python.org/3/)
[![CUDA](https://img.shields.io/badge/cuda-yes-5eb304?logo=nvidia)](https://developer.nvidia.com/cuda-toolkit)
[![DOI](https://img.shields.io/badge/doi-10.5281/zenodo.8126101-ad55d9?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAE9GlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZWRhMmIzZmFjLC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LiWMZWVkDDDNDygFPwLjDX4XQwKLRv9bQBfQnHOcAWCOwTcDz+B2zII0IRuBFQb/O/Bupm29Z/oyYbwQHs02YktrFrDD4O9SZh9UIzThMnK/EYNDAX4dcDExoBQUyIiAOCE/Ac8b/E7gu+SQ0nAdOJcl8s6R97BL5xywISKAk8AN3EMtFQLO4Krj30Eyj5DJuG/dwpLIIJaRtgRXRJ7SOhbg1+GW0hjf43KMl4RKGdkFTDf43cA3FWytJ3JqSS0COnBLbhH4B/gedygbgPJC1uC2Gj7O47JRCd0GNx84lcM2i3bgqMf1AvvJPKtCpdWO29VaeAX7YefDeje1JYedj0+8tnBL/elhcQTOAF2B88T7EeeIuQEfb0b4eMGwvyZ3SmzL3msZfxEIYG9EAIPXLwFf03PYTpB03rPrl3RU0jxJTeWEvBYY+HiCCCS1Srpt+OuT9EYZu1cl/WXY9UraJC8bkoZN9rXAV4E67Qf2YL+mKYeb2CfFVmAf8Gfp81fc6jMXdwyYbdgIt+ncB9we2TukansgG/WCIxrK8ogsZletwgiV9YNTwPLS31aGhwk5A/TVMJj9uLeYsdgJvIRVTll4KVpeo7K4LOmp0hiLJe2Wm/Dl0ClplV9Coct69zsHWIjL1mj/m6CAy3InbuudxXO4TecU3CJSKH3rPcBh3A9E+QcyhPwv8dD8htgQUm9oCKk3NITUG+4BHP2mwwGKgTwAAAAASUVORK5CYII=)](https://zenodo.org/badge/latestdoi/610509640)
[![License](https://img.shields.io/badge/license-MIT-red?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfoAwYAMwyp1T9YAAAJQ0lEQVRo3sWaaWxU1xXHf2/zLMSAbUxsgj22QdixWRziJKjwIXVNgxwJmi8JfKkUUqlITSqqoipREqpIlRNlQ3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OjEyKzAwOjAwQxJVFwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAAASUVORK5CYII=)](https://opensource.org/licenses/MIT)
![Banner](https://raw.githubusercontent.com/mantasu/glasses-detector/main/docs/_static/img/banner.jpg)
About
Package for processing images with different types of glasses and their parts. It provides a quick way to use the pre-trained models for 3 kinds of tasks, each divided into multiple categories, for instance, classification of sunglasses or segmentation of glasses frames.
Classification | š transparent š¶ļø opaque š„½ any āæshadows |
Detection | š¤ worn š standalone š eye-area |
Segmentation | š full š¼ļø frames š¦æ legs š lenses š„ shadows |
$\color{gray}{\textit{Note: }\text{refer to}}$ [Glasses Detector Features](https://mantasu.github.io/glasses-detector/docs/features.html) $\color{gray}{\text{for visual examples.}}$
Installation
[!IMPORTANT]
Minimum version of Python 3.12 is required. Also, you may want to install Pytorch (select Nightly for compatibility) in advance to select specific configuration for your device and environment.
Pip Package
If you only need the library with pre-trained models, just install the pip package and see Quick Start for usage (also check Glasses Detector Installation for more details):
pip install glasses-detector
You can also install it from the source:
git clone https://github.com/mantasu/glasses-detector
cd glasses-detector && pip install .
Local Project
If you want to train your own models on the given datasets (or on some other datasets), just clone the project and install training requirements, then see Running section to see how to run training and testing.
git clone https://github.com/mantasu/glasses-detector
cd glasses-detector && pip install -r requirements.txt
You can create a virtual environment for your packages via venv, however, if you have conda, then you can simply use it to create a new environment, for example:
conda create -n glasses-detector python=3.12
conda activate glasses-detector
To set-up the datasets, refer to Data section.
Quick Start
Command Line
You can run predictions via the command line. For example, classification of a single image and segmentation of images inside a directory can be performed by running:
glasses-detector -i path/to/img.jpg -t classification -d cuda -f int # Prints 1 or 0
glasses-detector -i path/to/img_dir -t segmentation -f mask -e .jpg # Generates masks
[!TIP]
You can also specify things like --output-path
, --size
, --batch-size
etc. Check the Glasses Detector CLI and Command Line Examples for more details.
Python Script
You can import the package and its models via the python script for more flexibility. Here is an example of how to classify people wearing sunglasses:
from glasses_detector import GlassesClassifier
# Generates a CSV with each line "<img_name.jpg>,<True|False>"
classifier = GlassesClassifier(size="small", kind="sunglasses")
classifier.process_dir("path/to/dir", "path/to/preds.csv", format="bool")
And here is a more efficient way to process a dir for detection task (only single bbox per image is currently supported):
from glasses_detector import GlassesDetector
# Generates dir_preds with bboxes as .txt for each img
detector = GlassesDetector(kind="eyes", device="cuda")
detector.process_dir("path/to/dir", ext=".txt", batch_size=64)
[!TIP]
Again, there are a lot more things that can be specified, for instance, output_size
and pbar
. It is also possible to directly output the results or save them in a variable. See Glasses Detector API and Python Script Examples for more details.
Demo
Feel free to play around with some demo image files. For example, after installing through pip, you can run:
git clone https://github.com/mantasu/glasses-detector && cd glasses-detector/data
glasses-detector -i demo -o demo_labels.csv --task classification:eyeglasses
You can also check out the demo notebook which can be also accessed via Google Colab.
Data
Before downloading the datasets, please install unrar
package, for example if you're using Ubuntu (if you're using Windows, just install WinRAR):
sudo apt-get install unrar
Also, ensure the scripts are executable:
chmod +x scripts/*
Once you download all the datasets (or some that interest you), process them:
python scripts/preprocess.py --root data -f -d
[!TIP]
You can also specify only certain tasks, e.g., --tasks classification segmentation
would ignore detection datasets. It is also possible to change image size and val/test split fractions: use --help
to see all the available CLI options.
After processing all the datasets, your data
directory should have the following structure:
āāā data # The data directory (root) under project
āāā classification
ā āāā anyglasses # Datasets with any glasses as positives
ā āāā eyeglasses # Datasets with transparent glasses as positives
ā āāā shadows # Datasets with visible glasses frames shadows as positives
ā āāā sunglasses # Datasets with semi-transparent/opaque glasses as positives
ā
āāā detection
ā āāā eyes # Datasets with bounding boxes for eye area
ā āāā solo # Datasets with bounding boxes for standalone glasses
ā āāā worn # Datasets with bounding boxes for worn glasses
ā
āāā segmentation
āāā frames # Datasets with masks for glasses frames
āāā full # Datasets with masks for full glasses (frames + lenses)
āāā legs # Datasets with masks for glasses legs (part of frames)
āāā lenses # Datasets with masks for glasses lenses
āāā shadows # Datasets with masks for eyeglasses frames cast shadows
āāā smart # Datasets with masks for glasses frames and lenses if opaque
Almost every dataset will have train
, val
and test
sub-directories. These splits for classification datasets are further divided to <category>
and no_<category>
, for detection - to images
and annotations
, and for segmentation - to images
and masks
sub-sub-directories. By default, all the images are 256x256
.
[!NOTE]
Instead of downloading the datasets manually one-by-one, here is a Kaggle Dataset that you could download which already contains everything.
Download Instructions
Download the following files and _place them all_ inside the cloned project under directory `data` which will be your data `--root` (please note for some datasets you need to have created a free [Kaggle](https://www.kaggle.com/) account):
**Classification** datasets:
1. From [CMU Face Images](http://archive.ics.uci.edu/dataset/124/cmu+face+images) download `cmu+face+images.zip`
2. From [Specs on Faces](https://sites.google.com/view/sof-dataset) download `original images.rar` and `metadata.rar`
3. From [Sunglasses / No Sunglasses](https://www.kaggle.com/datasets/amol07/sunglasses-no-sunglasses) download `archive.zip` and _rename_ to `sunglasses-no-sunglasses.zip`
4. From [Glasses and Coverings](https://www.kaggle.com/datasets/mantasu/glasses-and-coverings) download `archive.zip` and _rename_ to `glasses-and-coverings.zip`
5. From [Face Attributes Grouped](https://www.kaggle.com/datasets/mantasu/face-attributes-grouped) download `archive.zip` and _rename_ to `face-attributes-grouped.zip`
6. From [Face Attributes Extra](https://www.kaggle.com/datasets/mantasu/face-attributes-extra) download `archive.zip` and _rename_ to `face-attributes-extra.zip`
7. From [Glasses No Glasses](https://www.kaggle.com/datasets/jorgebuenoperez/datacleaningglassesnoglasses) download `archive.zip` and _rename_ to `glasses-no-glasses.zip`
8. From [Indian Facial Database](https://drive.google.com/file/d/1DPQQ2omEYPJDLFP3YG2h1SeXbh2ePpOq/view) download `An Indian facial database highlighting the Spectacle.zip`
9. From [Face Attribute 2](https://universe.roboflow.com/heheteam-g9fnm/faceattribute-2) download `FaceAttribute 2.v2i.multiclass.zip` (choose `v2` and `Multi Label Classification` format)
10. From [Glasses Shadows Synthetic](https://www.kaggle.com/datasets/mantasu/glasses-shadows-synthetic) download `archive.zip` and _rename_ to `glasses-shadows-synthetic.zip`
**Detection** datasets:
11. From [AI Pass](https://universe.roboflow.com/shinysky5166/ai-pass) download `AI-Pass.v6i.coco.zip` (choose `v6` and `COCO` format)
12. From [PEX5](https://universe.roboflow.com/pex-5-ylpua/pex5-gxq3t) download `PEX5.v4i.coco.zip` (choose `v4` and `COCO` format)
13. From [Sunglasses Glasses Detect](https://universe.roboflow.com/burhan-6fhqx/sunglasses_glasses_detect) download `sunglasses_glasses_detect.v1i.coco.zip` (choose `v1` and `COCO` format)
14. From [Glasses Detection](https://universe.roboflow.com/su-yee/glasses-detection-qotpz) download `Glasses Detection.v2i.coco.zip` (choose `v2` and `COCO` format)
15. From [Glasses Image Dataset](https://universe.roboflow.com/new-workspace-ld3vn/glasses-ffgqb) download `glasses.v1-glasses_2022-04-01-8-12pm.coco.zip` (choose `v1` and `COCO` format)
16. From [EX07](https://universe.roboflow.com/cam-vrmlm/ex07-o8d6m) download `Ex07.v1i.coco.zip` (choose `v1` and `COCO` format)
17. From [No Eyeglass](https://universe.roboflow.com/doms/no-eyeglass) download `no eyeglass.v3i.coco.zip` (choose `v3` and `COCO` format)
18. From [Kacamata-Membaca](https://universe.roboflow.com/uas-kelas-machine-learning-blended/kacamata-membaca) download `Kacamata-Membaca.v1i.coco.zip` (choose `v1` and `COCO` format)
19. From [Only Glasses](https://universe.roboflow.com/woodin-ixal8/onlyglasses) download `onlyglasses.v1i.coco.zip` (choose `v1` and `COCO` format)
**Segmentation** datasets:
20. From [CelebA Mask HQ](https://drive.google.com/file/d/1badu11NqxGf6qM3PTTooQDJvQbejgbTv/view) download `CelebAMask-HQ.zip` and from [CelebA Annotations](https://drive.google.com/file/d/1xd-d1WRnbt3yJnwh5ORGZI3g-YS-fKM9/view) download `annotations.zip`
21. From [Glasses Segmentation Synthetic Dataset](https://www.kaggle.com/datasets/mantasu/glasses-segmentation-synthetic-dataset) download `archive.zip` and _rename_ to `glasses-segmentation-synthetic.zip`
22. From [Face Synthetics Glasses](https://www.kaggle.com/datasets/mantasu/face-synthetics-glasses) download `archive.zip` and _rename_ to `face-synthetics-glasses.zip`
23. From [Eyeglass](https://universe.roboflow.com/azaduni/eyeglass-6wu5y) download `eyeglass.v10i.coco-segmentation.zip` (choose `v10` and `COCO Segmentation` format)
24. From [Glasses Lenses Segmentation](https://universe.roboflow.com/yair-etkes-iy1bq/glasses-lenses-segmentation) download `glasses lenses segmentation.v7-sh-improvments-version.coco.zip` (choose `v7` and `COCO` format)
25. From [Glasses Lens](https://universe.roboflow.com/yair-etkes-iy1bq/glasses-lens) download `glasses lens.v6i.coco-segmentation.zip` (choose `v6` and `COCO Segmentation` format)
26. From [Glasses Segmentation Cropped Faces](https://universe.roboflow.com/yair-etkes-iy1bq/glasses-segmentation-cropped-faces) download `glasses segmentation cropped faces.v2-segmentation_models_pytorch-s_1st_version.coco-segmentation.zip` (choose `v2` and `COCO Segmentation` format)
27. From [Spects Segmentation](https://universe.roboflow.com/teamai-wuk2z/spects-segementation) download `Spects Segementation.v3i.coco-segmentation.zip` (choose `v3` and `COCO Segmentation`)
28. From [KINH](https://universe.roboflow.com/fpt-university-1tkhk/kinh) download `kinh.v1i.coco.zip` (choose `v1` and `COCO` format)
29. From [Capstone Mini 2](https://universe.roboflow.com/christ-university-ey6ms/capstone_mini_2-vtxs3) download `CAPSTONE_MINI_2.v1i.coco-segmentation.zip` (choose `v1` and `COCO Segmentation` format)
30. From [Sunglasses Color Detection](https://universe.roboflow.com/andrea-giuseppe-parial/sunglasses-color-detection-roboflow) download `Sunglasses Color detection roboflow.v2i.coco-segmentation.zip` (choose `v2` and `COCO Segmentation` format)
31. From [Sunglasses Color Detection 2](https://universe.roboflow.com/andrea-giuseppe-parial/sunglasses-color-detection-2) download `Sunglasses Color detection 2.v3i.coco-segmentation.zip` (choose `v3` and `COCO Segmentation` format)
32. From [Glass Color](https://universe.roboflow.com/snap-ml/glass-color) download `Glass-Color.v1i.coco-segmentation.zip` (choose `v1` and `COCO Segmentation` format)
The table below shows which datasets are used for which tasks and their categories. Feel free to pick only the ones that interest you.
| Task | Category | Dataset IDs |
| -------------- | ------------ | ---------------------------------------------------------- |
| Classification | `anyglasses` | `1`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `14`, `15`, `16` |
| Classification | `eyeglasses` | `2`, `4`, `5`, `6`, `11`, `12`, `13`, `14`, `15` |
| Classification | `sunglasses` | `1`, `2`, `3`, `4`, `5`, `6`, `11`, `12`, `13`, `14`, `15` |
| Classification | `shadows` | `10` |
| Detection | `eyes` | `14`, `15`, `16`, `17` |
| Detection | `solo` | `18`, `19` |
| Detection | `worn` | `11`, `12`, `13`, `14`, `15`, `16` |
| Segmentation | `frames` | `21`, `23` |
| Segmentation | `full` | `20`, `27`, `28` |
| Segmentation | `legs` | `29`, `30`, `31` |
| Segmentation | `lenses` | `23`, `24`, `25`, `26`, `30`, `31`, `32` |
| Segmentation | `shadows` | `21` |
| Segmentation | `smart` | `22` |
Running
To run custom training and testing, it is first advised to familiarize with how Pytorch Lightning works and briefly check its CLI documentation. In particular, take into account what arguments are accepted by the Trainer class and how to customize your own optimizer and scheduler via command line. Prerequisites:
- Clone the repository
- Install the requirements
- Download and preprocess the data
Training
You can run simple training as follows (which is the default):
python scripts/run.py fit --task classification:anyglasses --size medium
You can customize things like batch-size
, num-workers
, as well as trainer
and checkpoint
arguments:
python scripts/run.py fit --batch-size 64 --trainer.max_epochs 300 --checkpoint.dirname ckpt
It is also possible to overwrite default optimizer and scheduler:
python scripts/run.py fit --optimizer Adam --optimizer.lr 1e-3 --lr_scheduler CosineAnnealingLR
Testing
To run testing, specify the trained model and the checkpoint to it:
python scripts/run.py test -t classification:anyglasses -s small --ckpt_path path/to/model.ckpt
Or you can also specify the pth
file to pre-load the model with weights:
python scripts/run.py test -t classification:anyglasses -s small -w path/to/weights.pth
If you get UserWarning: No positive samples in targets, true positive value should be meaningless, increase the batch size.
Credits
For references and citation, please see Glasses Detector Credits.