tanveer-hussain / efficientsod Goto Github PK
View Code? Open in Web Editor NEWThis research is based on efficient saliency detection using deformable convolutions.
License: Apache License 2.0
This research is based on efficient saliency detection using deformable convolutions.
License: Apache License 2.0
Hi, I got an error during the training of your model "EfficientSOD". The error is "Can't find file DDNet_500Model.pt". How to resolve this issue? Thank you.
I've tried to run your model on webcam with this code:
import torch
from torchvision import transforms as T
from PIL import Image
import os
import numpy as np
import cv2
import timeit
# datasets = SIP , DUT-RGBD , NLPR , NJU2K
model_path = os.path.join('DDNet_500Model.pt')
model = torch.load(model_path)
model.eval()
kernel = np.ones((5,5), np.uint8)
def preprocess_image(img):
transform = T.Compose([T.ToPILImage(),T.Resize((224, 224)), T.ToTensor()])
x = transform(img)
x = torch.unsqueeze(x, 0)
x = x.cuda(0)
return x
def predictions(img):
x = preprocess_image(img)
start_time = timeit.default_timer()
print(x.shape)
output = model(x)
output = torch.squeeze(output, 0)
output = output.detach().cpu().numpy()
output = output.dot(255)
output *= output.max()/255.0
# print (max(output))
# output = cv2.erode(output, kernel, iterations=2)
# output = cv2.dilate(output, kernel, iterations=1)
return output
def test_video():
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH,480);
cam.set(cv2.CAP_PROP_FRAME_HEIGHT,480);
while True:
ok, img = cam.read()
# img = cv2.resize(img, (640, 480))
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
output = predictions(img)
output = np.transpose(output, (1, 2, 0))
cv2.imshow('Mask', output)
cv2.waitKey(10)
if __name__ == "__main__":
test_video()
but faced with this error:
Traceback (most recent call last):
File "demo.py", line 59, in <module>
test_video()
File "demo.py", line 48, in test_video
output = predictions(img)
File "demo.py", line 28, in predictions
output = model(x)
File "C:\Users\NoteBook TANDIS\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "D:\Projects\Src\EfficientSOD-main\ModelNetworks\BaseNetwork_3.py", line 55, in forward
x = self.deform3(x)
File "C:\Users\NoteBook TANDIS\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "D:\Projects\Src\EfficientSOD-main\deformable_conv.py", line 34, in forward
offset = self.p_conv(x)
File "C:\Users\NoteBook TANDIS\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 1071, in _call_impl
result = forward_call(*input, **kwargs)
File "C:\Users\NoteBook TANDIS\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\conv.py", line 443, in forward
return self._conv_forward(input, self.weight, self.bias)
File "C:\Users\NoteBook TANDIS\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\conv.py", line 440, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [18, 128, 3, 3], expected input[1, 256, 28, 28] to have 128 channels, but got 256 channels instead
[ WARN:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-_xlv4eex\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
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.