Giter Club home page Giter Club logo

Comments (8)

ChandanKumarAAI avatar ChandanKumarAAI commented on April 27, 2024 6

Screenshot from 2019-03-18 11-42-36

from facedetection-dsfd.

ChandanKumarAAI avatar ChandanKumarAAI commented on April 27, 2024 1

My torch version is 0.4, and I was facing the same issue, so I updated the following code, and now it is working.

def infer(net , img , transform , thresh , cuda , shrink):
if shrink != 1:
img = cv2.resize(img, None, None, fx=shrink, fy=shrink, interpolation=cv2.INTER_LINEAR)
x = torch.from_numpy(transform(img)[0]).permute(2, 0, 1)
with torch.no_grad():
x = Variable(x.unsqueeze(0))
if cuda:
x = x.cuda()
#print (shrink , x.shape)
y = net(x) # forward pass
detections = y.data
# scale each detection back up to the image
scale = torch.Tensor([ img.shape[1]/shrink, img.shape[0]/shrink,
img.shape[1]/shrink, img.shape[0]/shrink] )
det = []
for i in range(detections.size(1)):
j = 0
while detections[0, i, j, 0] >= thresh:
score = detections[0, i, j, 0].cpu().numpy()
#label_name = labelmap[i-1]
pt = (detections[0, i, j, 1:]*scale).cpu().numpy()
#print ("#"*20,type(pt), pt)
coords = (pt[0], pt[1], pt[2], pt[3])
det.append([pt[0], pt[1], pt[2], pt[3], score])
j += 1
if (len(det)) == 0:
det = [ [0.1,0.1,0.2,0.2,0.01] ]
det = np.array(det)

    keep_index = np.where(det[:, 4] >= 0)[0]
    det = det[keep_index, :]
    return det

from facedetection-dsfd.

ChandanKumarAAI avatar ChandanKumarAAI commented on April 27, 2024

Can you please specify your pytorch version?

from facedetection-dsfd.

DecentMakeover avatar DecentMakeover commented on April 27, 2024

Hi

Facing a similar issue, Not able to run the demo.py file.

from facedetection-dsfd.

DecentMakeover avatar DecentMakeover commented on April 27, 2024

@ChandanKumarAAI Were you able to get predictions using the demo.py file?

from facedetection-dsfd.

ChandanKumarAAI avatar ChandanKumarAAI commented on April 27, 2024

@DecentMakeover yes I was able to get prediction from demo.py.

from facedetection-dsfd.

DecentMakeover avatar DecentMakeover commented on April 27, 2024

Okay let me try this.

from facedetection-dsfd.

ChaunceyWang avatar ChaunceyWang commented on April 27, 2024

@AnberLu @ChandanKumarAAI @DecentMakeover
It's mainly caused by torch version. Someone faces this similar problem. The torch version we used is 0.3.1.

from facedetection-dsfd.

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.