deepcam-cn / yolov5-face

YOLO5Face: Why Reinventing a Face Detector (https://arxiv.org/abs/2105.12931) ECCV Workshops 2022)
GNU General Public License v3.0
2.04k stars 495 forks source link

Yolov5-face is not working via torch hub. #212

Open ioctl-user opened 1 year ago

ioctl-user commented 1 year ago

Here is an example code:

#!/bin/python

import torch

# Model
model = torch.hub.load('deepcam-cn/yolov5-face', 'yolov5s', pretrained=True)

# Images
imgs = ['https://ultralytics.com/images/zidane.jpg']  # batch of images

# Inference
results = model(imgs)

# Results
results.print()
results.show()

Here is output:

Using cache found in /home/build/.cache/torch/hub/deepcam-cn_yolov5-face_master
Overriding model.yaml nc=1 with nc=80

                 from  n    params  module                                  arguments                     
  0                -1  1      8256  models.common.StemBlock                 [3, 32, 3, 2]                 
  1                -1  1     16768  models.common.C3                        [32, 64, 1]                   
  2                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
  3                -1  1    156928  models.common.C3                        [128, 128, 3]                 
  4                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]              
  5                -1  1    625152  models.common.C3                        [256, 256, 3]                 
  6                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]              
  7                -1  1    656896  models.common.SPP                       [512, 512, [3, 5, 7]]         
  8                -1  1   1182720  models.common.C3                        [512, 512, 1, False]          
  9                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              
 10                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 11           [-1, 5]  1         0  models.common.Concat                    [1]                           
 12                -1  1    361984  models.common.C3                        [512, 256, 1, False]          
 13                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              
 14                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 15           [-1, 3]  1         0  models.common.Concat                    [1]                           
 16                -1  1     90880  models.common.C3                        [256, 128, 1, False]          
 17                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              
 18          [-1, 13]  1         0  models.common.Concat                    [1]                           
 19                -1  1    296448  models.common.C3                        [256, 256, 1, False]          
 20                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]              
 21           [-1, 9]  1         0  models.common.Concat                    [1]                           
 22                -1  1   1182720  models.common.C3                        [512, 512, 1, False]          
 23      [16, 19, 22]  1    256215  models.yolo.Detect                      [80, [[4, 5, 8, 10, 13, 16], [23, 29, 43, 55, 73, 105], [146, 217, 231, 300, 335, 433]], [128, 256, 512]]
/home/build/.local/lib/python3.10/site-packages/torch/functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2895.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Model Summary: 292 layers, 7287703 parameters, 7287703 gradients, 16.1 GFLOPS

Traceback (most recent call last):
  File "/home/build/.cache/torch/hub/deepcam-cn_yolov5-face_master/hubconf.py", line 40, in create
    state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].shape == v.shape}  # filter
  File "/home/build/.cache/torch/hub/deepcam-cn_yolov5-face_master/hubconf.py", line 40, in <dictcomp>
    state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].shape == v.shape}  # filter
KeyError: 'model.0.conv.weight'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/build/delme/./1.py", line 7, in <module>
    model = torch.hub.load('deepcam-cn/yolov5-face', 'yolov5s', pretrained=True)
  File "/home/build/.local/lib/python3.10/site-packages/torch/hub.py", line 540, in load
    model = _load_local(repo_or_dir, model, *args, **kwargs)
  File "/home/build/.local/lib/python3.10/site-packages/torch/hub.py", line 569, in _load_local
    model = entry(*args, **kwargs)
  File "/home/build/.cache/torch/hub/deepcam-cn_yolov5-face_master/hubconf.py", line 65, in yolov5s
    return create('yolov5s', pretrained, channels, classes, autoshape)
  File "/home/build/.cache/torch/hub/deepcam-cn_yolov5-face_master/hubconf.py", line 51, in create
    raise Exception(s) from e
Exception: Cache maybe be out of date, try force_reload=True. See https://github.com/ultralytics/yolov5/issues/36 for help.

Recommended option force_reload=True doesn't help.

amirafshari commented 1 year ago

It's not available on the torch hub https://pytorch.org/hub/research-models

ioctl-user commented 1 year ago

There is a file hubconf.py in the project, that a little bit confusing.

May you adding project to the hub or remove this file?

martinenkoEduard commented 1 year ago

There is a file hubconf.py in the project, that a little bit confusing.

May you adding project to the hub or remove this file?

Have you managed to start it?

ioctl-user commented 1 year ago

There is a file hubconf.py in the project, that a little bit confusing. May you adding project to the hub or remove this file?

Have you managed to start it?

I did not tried any more.