Giter Club home page Giter Club logo

glasses-detector's Issues

Getting HTTP 404 when trying to download models

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?

Eyeglasses Classifier

Setting up Eyeglasses Classification model

About

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).

Model

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 $\downarrow$ F1 score $\uparrow$ ROC-AUC score $\uparrow$ Num params $\downarrow$ Model size $\downarrow$
Eyeglasses classifier small 0.1726 0.9217 0.9908 342.82 k 1.34 Mb

Note

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.

Setup

Prepare the weights

  1. Download eyeglasses_classifier_shufflenet_v2_x0_5.zip
  2. Unzip and place 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.

Run the classifier

  1. You can just run from command-line:

    glasses-detector -i data/demo --kind anyglasses-classifier
  2. 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

Error load pretrained weight

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", ...."

Training Dataset

Hi, i want to train with my dataset but i got an error like this. Can you help me? Thanks

image

image

image

Video input

Hello, i wonder this can be use with video input?
Really looking forward!

Python Script is not working

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",
)

Eyeglass classifier

Is the Eyeglass classifier available at the moment ?
Would it possible to share a single checkpoint for eyeglass classifier.

Thanks in advance!

classify sunglasses

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

TODO for v1.0.0 (Late February 2024 Update)

Features and Improvements for v1.0.0

Data

  • Update scripts to process dataset-by-dataset instead of task-by-task
  • Find or add more datasets for classification, detection, and segmentation
  • Write processing scripts, update preprocess.py CLI
  • Upload the datasets as a single big one to Kaggle

Architecture

  • Add prediction interface to handle predictions and conversion + saving to different formats
  • Update base model to be extendable with glasses classifier, detector, and segmenter children
  • Change class-based model instantiation to arg-based, create default models for each specification
  • Require task for CLI, add size alias, detect device when None

Features

  • Add detection dataset, tiny detection model, and binary detection wrapper
  • Identify the best hyperparameters and set them as default for each wrapper
  • Train models of different sizes and kinds for different tasks (36 in total)

Documentation

  • Add a demo file and a collab notebook for quick examples
  • Crop only the eye area in the tables, add more example images to showcase features
  • Add the results for each model + their sizes, document training parameters
  • Document data download and preprocessing steps
  • Add type hints and documentation for the new classes/functions
  • Add dataset + model architecture references

Could you help me?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.