Comments (8)
I was not able to reproduce issue.
I tested FaceLocations methjod on the following pattern
- numberOfTimesToUpsample
- 0 or 1
- model
- cnn or hog
- image
Did you face this issue everytime when passing 0 for numberOfTimesToUpsample?
from facerecognitiondotnet.
@takuya-takeuchi try with a large input image. 0 always works, 1 always blows up for large images.
from facerecognitiondotnet.
Model CNN, it is a CudaException after all ;)
from facerecognitiondotnet.
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.
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.
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.
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.
Looks like its a valid behaviour then.
from facerecognitiondotnet.
Related Issues (20)
- Getting Started guide
- Use Cases supported
- Performance Matrix
- UnhandledException: System.TypeInitializationException: The type initializer for 'DlibDotNet.NativeMethods' threw an exception. HOT 3
- Refactor System.Drawing out of the project HOT 6
- Getting started on GPU is few
- System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. HOT 4
- GOOD
- Dlib.LoadImage is unable to read images from image library (even when capabity granted) HOT 4
- Will this run faster than the python version? HOT 1
- Provide an overload with SkiaSharp Bitmap to use it on Net7/Linux? HOT 1
- Unexpected version found while deserializing dlib::add_skip_layer when load Emotion Estimator Model
- Could you please provide FaceRecognitionDotNet that supports x86?
- Training Duration HeadPose HOT 1
- Bug: HeadPose.Equals throws NullReferenceException
- Can you merge LoadImage for SkiaSharp in main?
- how to know face size from FaceEncoding Object?
- Not Find ProjectDlibDotNet
- building the tools dll
- Illegal Instruction em computadores windows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facerecognitiondotnet.