Git Product home page Git Product logo

Comments (8)

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

I was not able to reproduce issue.
I tested FaceLocations methjod on the following pattern

Did you face this issue everytime when passing 0 for numberOfTimesToUpsample?

from facerecognitiondotnet.

turowicz avatar turowicz commented on July 17, 2024

@takuya-takeuchi try with a large input image. 0 always works, 1 always blows up for large images.

from facerecognitiondotnet.

turowicz avatar turowicz commented on July 17, 2024

Model CNN, it is a CudaException after all ;)

from facerecognitiondotnet.

gloednieuw avatar gloednieuw commented on July 17, 2024

Hi,

I got the exact same error when trying to run CUDA with the following image and upsampling set to 1:

https://media.gettyimages.com/photos/-picture-id906162?s=2048x2048

any updates on a possible solution?

from facerecognitiondotnet.

gloednieuw avatar gloednieuw commented on July 17, 2024

Actually, it happens to me even with upsampling set to 0 given big enough images. For example: one image of size 1568 x 1981 and another one of size 1675 x 2048 processed within the same runtime process.

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

The following sample program can reproduce issue.

using System;
using DlibDotNet;
using FaceRecognitionDotNet;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            const string filename = "gettyimages-906162-2048x2048.jpg";
            var fr = FaceRecognition.Create(@"D:\Works\OpenSource\FaceRecognitionDotNet\test\FaceRecognitionDotNet.Tests\bin\Release\netcoreapp2.0\Models");
            using (var image = FaceRecognition.LoadImageFile(filename))
                for (var num = 0; num < 5; num++)
                    try
                    {
                        foreach (var face in fr.FaceLocations(image, num, Model.Cnn))
                            Console.WriteLine($"numberOfTimesToUpsample={num}: {face.Left}, {face.Top}, {face.Right}, {face.Bottom}");
                    }
                    catch (CudaException e)
                    {
                        Console.WriteLine($"CUDA Error code: {e.ErrorCode}");
                    }
        }
    }
}

The above program output the following message

numberOfTimesToUpsample=0: 317, 285, 600, 568
numberOfTimesToUpsample=1: 321, 273, 614, 566
CUDA Error code: 2
CUDA Error code: 2
CUDA Error code: 2

CUDA Error code 2 is cudaErrorMemoryAllocation = 2
My dev machine is GTX 1080 and it has 8GB GPU RAM.

So FaceRecogtnitionDotNet.CUDA could throw exception.
In other words, FaceRecogtnitionDotNet works fine but it very slow.
The above program consumed more than 15G ram by FaceRecogtnitionDotNet cpu.

However, @turowicz said 'In python I do 1 upsample and it works fine.'

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

I tried example program.

from PIL import Image
import face_recognition

# Load the jpg file into a numpy array
image = face_recognition.load_image_file("gettyimages-906162-2048x2048.jpg")

# Find all the faces in the image using a pre-trained convolutional neural network.
# This method is more accurate than the default HOG model, but it's slower
# unless you have an nvidia GPU and dlib compiled with CUDA extensions. But if you do,
# this will use GPU acceleration and perform well.
# See also: find_faces_in_picture.py
for num in range(0, 5):
    face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=num, model="cnn")

    print("I found {} face(s) in this photograph.".format(len(face_locations)))

    for face_location in face_locations:

        # Print the location of each face in this image
        top, right, bottom, left = face_location
        print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))

It occurs the following output.

>python test.py
I found 1 face(s) in this photograph.
A face is located at pixel location Top: 285, Left: 317, Bottom: 568, Right: 600
I found 1 face(s) in this photograph.
A face is located at pixel location Top: 273, Left: 321, Bottom: 567, Right: 615
Traceback (most recent call last):
  File "test.py", line 13, in <module>
    face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=num, model="cnn")
  File "D:\Works\Python\envs\face_recognition\lib\site-packages\face_recognition\api.py", line 116, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "D:\Works\Python\envs\face_recognition\lib\site-packages\face_recognition\api.py", line 100, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaMalloc(&data, new_size*sizeof(float)) in file D:\Works\Lib\Dlib\19.17\dlib\cuda\gpu_data.cpp:218. code: 2, reason: out of memory

It is similar with C# example on the previous post.

from facerecognitiondotnet.

turowicz avatar turowicz commented on July 17, 2024

Looks like its a valid behaviour then.

from facerecognitiondotnet.

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.