mantasu / glasses-detector Goto Github PK
View Code? Open in Web Editor NEWGlasses detection, classification and segmentation
Home Page: https://mantasu.github.io/glasses-detector/
License: MIT License
Glasses detection, classification and segmentation
Home Page: https://mantasu.github.io/glasses-detector/
License: MIT License
Hello,
I am having difficulty running the classifier locally. I'm getting a 404 error while using command line as well as in a Python script. This is the URL it is trying to hit:
Downloading: "https://github.com/mantasu/glasses-detector/releases/download/eyeglasses_classifier_efficientnet_b0.pth"
Is anyone else facing the same problem?
Alternatively, where can I find the different models that are used here?
Some people asked for a generic glasses classifier (#3, #7, #8), so I released weights for the small eyeglasses classification model. This means you can classify Eyeglasses
(sunglasses are excluded) and Anyglasses
(sunglasses are included).
The same model architecture was used as for the small sunglasses classifier, i.e., Shufflenet. The datasets used were Face Attributes Grouped, Face Attributes Extra, and Glasses and Coverings. The results on the test set are as follows:
Model type | BCE loss |
F1 score |
ROC-AUC score |
Num params |
Model size |
---|---|---|---|---|---|
Eyeglasses classifier small | 0.1726 | 0.9217 | 0.9908 | 342.82 k | 1.34 Mb |
Please note that this is just a temporary solution. As noted in #2, the package should be updated in February (non-beta release) with more features, newer models, and better accuracies. Additionally, there will be some architectural changes, thus don't rely on imports or any code used in this beta release - it will be incompatible with v1.0.0
.
eyeglasses_classifier_shufflenet_v2_x0_5.pth
inside .cache/torch/hub/checkpoints
.Note: your torch hub directory may be elsewhere, you can check that by trying to classify sunglasses. All the models are automatically downloaded there, so just place
eyeglasses_classifier_shufflenet_v2_x0_5.pth
alongside them.
You can just run from command-line:
glasses-detector -i data/demo --kind anyglasses-classifier
OR create a custom script, e.g., classify_if_glasses.py
:
from glasses_detector import AnyglassesClassifier, EyeglassesClassifier
# Constants - change if needed
CLASSIFIER_CLS = AnyglassesClassifier
REL_PATH = "data/demo"
# Instantiate and run the classifier (only "small" is available)
classifier = CLASSIFIER_CLS(base_model="small", pretrained=True).eval()
classifier.process(REL_PATH)
and then just run:
python classify_if_glasses.py
Hi, I'm try run predict.py to test your weight, but i got the error:
"RuntimeError: Error(s) in loading state_dict for SunglassesClassifier:
Missing key(s) in state_dict: "base_model.features.0.0.weight", "base_model.features.0.1.weight", ...."
Hello, i wonder this can be use with video input?
Really looking forward!
Eyeglasses classifier checkpoints not uploaded to assets, library fails when trying to use pretrained eyeglasses classifier
I tried running this script
from glasses_detector import SunglassesClassifier
classifier = SunglassesClassifier(model_type="small", pretrained=True).eval()
classifier.predict(
input_path="path/to/dir",
output_path="path/to/output.csv",
label_type="int",
)
but it didn't work
so I fixed it like this.
from glasses_detector import SunglassesClassifier
classifier = SunglassesClassifier(base_model="small", pretrained=True).eval()
classifier.process(
input_path="path/to/dir",
output_path="path/to/output.csv",
label_type="int",
)
Is the Eyeglass classifier available at the moment ?
Would it possible to share a single checkpoint for eyeglass classifier.
Thanks in advance!
Hello author, I really need a model to classify sunglasses (the same task you provided). Can you upload the code of this task earlier. I really appreciate that..Thank you so much
preprocess.py
CLINone
Hi!
I'm trying to use, I tried first to clone this source code, but I'm using Py 3.11 and I receive a lot of errors, so now I'm using pip install glasses-detector (compiled package).
but I'm not haven error codes that I had when I use src code, but I think it's not finding something that need to download.
Thanks! I'm searching for an glasses detector for long time, hope to can use this.
glasses-detector -i .\fotos\foto_alexandre.jpg --kind anyglasses-classifier
Downloading: "https://github.com/mantasu/glasses-detector/releases/download/eyeglasses_classifier_shufflenet_v2_x0_5.pth" to C:\Users\Alexandre/.cache\torch\hub\checkpoints\eyeglasses_classifier_shufflenet_v2_x0_5.pth
Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Program Files\Python311\Scripts\glasses-detector.exe_main.py", line 7, in
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector_main.py", line 175, in main
model = model_cls(base_model=base_model, pretrained=True).to(device).eval()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\classifiers.py", line 195, in init
self.eyeg_classifier = EyeglassesClassifier(base_model[0], pretrained[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\classifiers.py", line 73, in init
super().init(base_model, pretrained)
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\bases\base_classifier.py", line 72, in init
super().init(*args, **kwargs)
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\bases\base_model.py", line 134, in init
self._init_from_base_model(base_model, pretrained)
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\bases\base_model.py", line 265, in _init_from_base_model
self._load_weights_from_url(self.kind, self.name, version)
File "C:\Program Files\Python311\Lib\site-packages\glasses_detector\bases\base_model.py", line 280, in _load_weights_from_url
weights = torch.hub.load_state_dict_from_url(url, map_location=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\torch\hub.py", line 766, in load_state_dict_from_url
download_url_to_file(url, cached_file, hash_prefix, progress=progress)
File "C:\Program Files\Python311\Lib\site-packages\torch\hub.py", line 620, in download_url_to_file
u = urlopen(req)
^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.