Giter VIP home page Giter VIP logo

Comments (26)

ar90n avatar ar90n commented on August 26, 2024 6

@jhsiao21
I added some codes to run eval.py on CPU. I guess it works correctly. If you have any time, please try it!
https://github.com/ar90n/yolact/tree/add-evaluation-without-cuda-support

from yolact.

jerpint avatar jerpint commented on August 26, 2024 4

@sch1eicher @sree3333 it seems that the original repo I took the fork from was removed, I forked my own and added the code there:

here the branch on my fork where I got it to work:

https://github.com/jerpint/yolact/tree/yolact-cpu

To use it:

git clone https://github.com/jerpint/yolact/
git checkout yolact-cpu
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4

from yolact.

bond9779 avatar bond9779 commented on August 26, 2024 3

@jhsiao21 Ive made some some modifications such that eval.py runs on cpu too. You can try it out.
https://github.com/HariharanJ9779/yolact

from yolact.

dbolya avatar dbolya commented on August 26, 2024

Oof

While I was implementing this, I considered writing it in a way that would also support running it on the CPU. However, pretty early on I decided that in order to squeeze as much speed out of the model as possible, I would optimize 100% for GPU usage and ignore running it on the CPU. Adding CPU support now would require a lot of changes.

I'll keep this issue open in case I do get around to adding CPU support, but for now it's not a high priority.

from yolact.

sdimantsd avatar sdimantsd commented on August 26, 2024

@ar90n @HariharanJ9779
What was the FPS on CPU?
With which CPU your used?

Thanks!

from yolact.

bond9779 avatar bond9779 commented on August 26, 2024

@sdimantsd Running evaluation on videos is very slow.
Intel CPU works fine.

from yolact.

jerpint avatar jerpint commented on August 26, 2024

@bond9779 thank you, it worked on my laptop (Thinkpad running ubuntu).

It is indeed pretty slow, you can expect approximately about 1-2 fps. The CPU I have is :

$ cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

from yolact.

sdimantsd avatar sdimantsd commented on August 26, 2024

@jerpint @bond9779 Thx!

from yolact.

sree3333 avatar sree3333 commented on August 26, 2024

@bond9779 thank you, it worked on my laptop (Thinkpad running ubuntu).

It is indeed pretty slow, you can expect approximately about 1-2 fps. The CPU I have is :

$ cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

Hey @jerpint
Could you send me the code that @bond9779 made for CPU, the link is not working
could you upload it on Google drive or something and send me the link?

Thanks alot

from yolact.

sch1eicher avatar sch1eicher commented on August 26, 2024

@bond9779 thank you, it worked on my laptop (Thinkpad running ubuntu).
It is indeed pretty slow, you can expect approximately about 1-2 fps. The CPU I have is :

$ cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
model name      : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

Hey @jerpint
Could you send me the code that @bond9779 made for CPU, the link is not working
could you upload it on Google drive or something and send me the link?

Thanks alot

Hey @sree3333 or @jerpint
have you recived any code or can you provide any code made for the cpu for me?

Thanks!

from yolact.

sch1eicher avatar sch1eicher commented on August 26, 2024

@sch1eicher @sree3333 it seems that the original repo I took the fork from was removed, I forked my own and added the code there:

here the branch on my fork where I got it to work:

https://github.com/jerpint/yolact/tree/yolact-cpu

To use it:

git clone https://github.com/jerpint/yolact.git
git checkout yolact-cpu
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4

Works like a charm. Thanks a lot!

from yolact.

elhmadany avatar elhmadany commented on August 26, 2024

which torch version should I use , I installed multiple version for torch and torchvision like
'''
!pip install torch==1.3.0 torchvision==0.4.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

'''
but still git this message :
File "C:\Users\Mohammed\AppData\Roaming\Python\Python37\site-packages\torch\cuda_init_.py", line 192, in _lazy_init
check_driver()
File "C:\Users\Mohammed\AppData\Roaming\Python\Python37\site-packages\torch\cuda_init
.py", line 95, in _check_driver
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

by run this comand:
!python ./yolact/eval.py --trained_model=./yolact_base_54_800000.pth --cuda=False --config=yolact_base_config --score_threshold=0.15 --top_k=15 --images=test_images:output_images

from yolact.

jerpint avatar jerpint commented on August 26, 2024

@elhmadany did you try the solution I posted above? I haven't modified it since, so it should still work. I don't think the pytorch versions will change much at this point.

from yolact.

elhmadany avatar elhmadany commented on August 26, 2024

@jerpint ,thank you for your response .
yes. i used git clone from your repo and run it in jupyter notebook but still the same problem regrading to CUDA by this message after I removed (--cuda=False) from comand :

Traceback (most recent call last):
File "./yolact/eval.py", line 1078, in
torch.set_default_tensor_type('torch.cuda.FloatTensor')
File "C:\Users\Mohammed\AppData\Roaming\Python\Python37\site-packages\torch_init_.py", line 155, in set_default_tensor_type
_C._set_default_tensor_type(t)
TypeError: type torch.cuda.FloatTensor not available. Torch not compiled with CUDA enabled.

in addition I checked CUDA status by:

import torch
print(torch.version.cuda)
print(torch.cuda.device_count())
print(torch.cuda.is_available())

--->
None
0
False

from yolact.

jerpint avatar jerpint commented on August 26, 2024

@elhmadany what are you running inside a notebook exactly? The fork will only allow you to run the command I posted, anything else in that repo probably won't work out of the box on cpu.

As for the cuda statuses you get, they are e
what you should expect when running on cpu.

from yolact.

elhmadany avatar elhmadany commented on August 26, 2024

yes, my objective is run yolcat on CPU only with out cuda.
but I am still I do not know where is the issue . and in notebook I just installed the used packages like (cython,opencv-python,pillow)and torch==1.2.0+cpu torchvision==0.4.0+cpu.
I think my problem in torch . do I reinstall it a gain by another version or what do you see.
I really appreciate your help

from yolact.

elhmadany avatar elhmadany commented on August 26, 2024

now ,it works good with me on images after comment and modify the eval.py and augmentations.py files where is cuda used.

from yolact.

arjungoel7 avatar arjungoel7 commented on August 26, 2024

@sch1eicher @sree3333 it seems that the original repo I took the fork from was removed, I forked my own and added the code there:

here the branch on my fork where I got it to work:

https://github.com/jerpint/yolact/tree/yolact-cpu

To use it:

git clone https://github.com/jerpint/yolact/
git checkout yolact-cpu
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4

I am getting an error while loading the weights : Error(s) in loading state_dict for Yolact
I followed the steps that you have mentioned. Any fix for this?

from yolact.

shakey-cuimiao avatar shakey-cuimiao commented on August 26, 2024

@sch1eicher @sree3333@arjungoel7 when i use it :
"git clone https://github.com/jerpint/yolact/
git checkout yolact-cpu
python eval.py --trained_model=weights/yolact_plus_resnet50_pascal_441_190000.pth --score_threshold=0.01 --top_k=5 --images="./test_single":"./genout1"
I am getting an error:
[sherry@xiaoi2018-754 yolact-yolact-cpu]$ CUDA_VISIBLE_DEVICES=-1 sh run_test.sh
Config not specified. Parsed yolact_plus_resnet50_pascal_config from the file name.

Loading model...Traceback (most recent call last):
File "eval.py", line 1031, in
net.load_weights(args.trained_model)
File "/home/sherry/cuimiao/Fabric_defect_detection/yolact-yolact-cpu/yolact.py", line 478, in load_weights
self.load_state_dict({k.replace('module.',''):v for k,v in state_dict.items()})
File "/home/sherry/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 845, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Yolact:
Unexpected key(s) in state_dict: "maskiou_net.maskiou_net.0.weight", "maskiou_net.maskiou_net.0.bias", "maskiou_net.maskiou_net.2.weight", "maskiou_net.maskiou_net.2.bias", "maskiou_net.maskiou_net.4.weight", "maskiou_net.maskiou_net.4.bias", "maskiou_net.maskiou_net.6.weight", "maskiou_net.maskiou_net.6.bias", "maskiou_net.maskiou_net.8.weight", "maskiou_net.maskiou_net.8.bias", "maskiou_net.maskiou_net.10.weight", "maskiou_net.maskiou_net.10.bias".

from yolact.

arjungoel7 avatar arjungoel7 commented on August 26, 2024

@shakey-cuimiao Yes I get the same error

from yolact.

shakey-cuimiao avatar shakey-cuimiao commented on August 26, 2024

@arjungoel7 @ jerpint @ar90n elhmadany when i run
python eval.py --trained_model=weights/weights/yolact_base_54_800000.pth --score_threshold=0.01 --top_k=5 --images="./test_single":"./genout1" ,it is ok,
But i run yolact++ ,I am getting an error :Error(s) in loading state_dict for Yolact,Unexpected key(s) in state_dict: "maskiou_net.maskiou_net.0.weight",

from yolact.

jerpint avatar jerpint commented on August 26, 2024

I haven't used this repo in a while. Most likely the models have been updated while the branch I created a while back has remained stale. Try merging master of yolact back into the branch I created, that might be your best bet.

from yolact.

rohanshingade avatar rohanshingade commented on August 26, 2024

@jhsiao21
I added some codes to run eval.py on CPU. I guess it works correctly. If you have any time, please try it!
https://github.com/ar90n/yolact/tree/add-evaluation-without-cuda-support

I'm trying to run yolact++ on CPU using your code. i made changes to load_weights function in yolact.py

def load_weights(self, path,map_location=None):
        """ Loads weights from a compressed save file. """
        #state_dict = torch.load(path)
        state_dict = torch.load(path, map_location=map_location)
        
        # For backward compatability, remove these (the new variable is called layers)
        for key in list(state_dict.keys()):
            if key.startswith('backbone.layer') and not key.startswith('backbone.layers'):
                del state_dict[key]
        
            # Also for backward compatibility with v1.0 weights, do this check
            if key.startswith('fpn.downsample_layers.'):
                if cfg.fpn is not None and int(key.split('.')[2]) >= cfg.fpn.num_downsample:
                    del state_dict[key]
        
        self = nn.DataParallel(self)
        self.module.load_state_dict(state_dict)

And this was the error. it works fine for yolact, but does not work with yolact++ resnet101.

Loading model...Traceback (most recent call last):
  File "eval.py", line 1110, in <module>
    net.load_weights(args.trained_model, map_location=map_location)
  File "/content/yolact_gpu/yolact.py", line 495, in load_weights
    self.module.load_state_dict(state_dict)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 830, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Yolact:
	Unexpected key(s) in state_dict: "backbone.layers.1.0.conv2.bias", "backbone.layers.1.0.conv2.conv_offset_mask.weight", "backbone.layers.1.0.conv2.conv_offset_mask.bias", "backbone.layers.1.3.conv2.bias", "backbone.layers.1.3.conv2.conv_offset_mask.weight", "backbone.layers.1.3.conv2.conv_offset_mask.bias", "backbone.layers.2.0.conv2.bias", "backbone.layers.2.0.conv2.conv_offset_mask.weight", "backbone.layers.2.0.conv2.conv_offset_mask.bias", "backbone.layers.2.3.conv2.bias", "backbone.layers.2.3.conv2.conv_offset_mask.weight", "backbone.layers.2.3.conv2.conv_offset_mask.bias", "backbone.layers.2.6.conv2.bias", "backbone.layers.2.6.conv2.conv_offset_mask.weight", "backbone.layers.2.6.conv2.conv_offset_mask.bias", "backbone.layers.2.9.conv2.bias", "backbone.layers.2.9.conv2.conv_offset_mask.weight", "backbone.layers.2.9.conv2.conv_offset_mask.bias", "backbone.layers.2.12.conv2.bias", "backbone.layers.2.12.conv2.conv_offset_mask.weight", "backbone.layers.2.12.conv2.conv_offset_mask.bias", "backbone.layers.2.15.conv2.bias", "backbone.layers.2.15.conv2.conv_offset_mask.weight", "backbone.layers.2.15.conv2.conv_offset_mask.bias", "backbone.layers.2.18.conv2.bias", "backbone.layers.2.18.conv2.conv_offset_mask.weight", "backbone.layers.2.18.conv2.conv_offset_mask.bias", "backbone.layers.2.21.conv2.bias", "backbone.layers.2.21.conv2.conv_offset_mask.weight", "backbone.layers.2.21.conv2.conv_offset_mask.bias", "backbone.layers.3.0.conv2.bias", "backbone.layers.3.0.conv2.conv_offset_mask.weight", "backbone.layers.3.0.conv2.conv_offset_mask.bias".

Any reference or leads would help. Thank you.

from yolact.

azadehashouri avatar azadehashouri commented on August 26, 2024

@jerpint
Hello.
I changed eval.py code of YOLACT repo based on your eval code, but I can't inference with CPU as before.
By the way, I always get "RuntimeError: CUDA error: out of memory".
Please help me.
Many thanks

from yolact.

SpaceView avatar SpaceView commented on August 26, 2024

Reference:
https://github.com/SpaceView/yolact_cpu
I have just tested in on windows, it works fine. Hope it can help a little bit.
I found that most of their work didn't remove the parallel part, the torch parallel will automatically select CUDA if there is one.
Main changes are made as below,
net = net.cpu() #net = CustomDataParallel(net)
transform = FastBaseTransform() #transform = torch.nn.DataParallel(FastBaseTransform())

from yolact.

azadehashouri avatar azadehashouri commented on August 26, 2024

@SpaceView Thanks a lot for sharing this link :)

from yolact.

Related Issues (20)

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.