esimov/caire

Face flag doesnt seem to work

kartikwar opened this issue · 9 comments

I am using the face flag to prevent faces from getting distorted (as mentioned in the documentation). But there seems to be no difference in output with/without this flag. Am I doing something wrong?

This is the command I used

go run github.com/esimov/caire/cmd/caire@latest -in /home/kartik/example.jpg -out output.jpg -face=1 -perc=1 -width=30

Attaching the output as well

output0

The reason is the following: when you are running the CLI with face detection enabled it embeds the facefinder cascade file on-the-fly without to require the cascade file as a standalone flag argument. You can check this one below in the process.go file :

//go:embed data/facefinder

Now, because you are downloading and running the binary file at the same time the data folder is missing and obviously also the facefinder cascade file. The strange thing is that it should have thrown an error that the cascade file is missing or cannot be unpacked like in the line 420:

caire/process.go

Lines 418 to 421 in 1cd0863

p.PigoFaceDetector, err = p.PigoFaceDetector.Unpack(cascadeFile)
if err != nil {
return fmt.Errorf("error unpacking the cascade file: %v", err)
}

I will look into it.

Thanks for your reply @esimov. I don't have any experience with go prior to this. Can you please tell me how can this be fixed? Awaiting your reply. Thanks in advance

If you need a quick resolution, then the most straightforward way is to download the project and run the application inside the root directory where it has been installed. I'm telling this, because I have just realized that in situations like this, when you are running the application once it has been downloaded the embedding might not work just out of the box.

I will try modify the code in such a way that in case the embedded file is not accessible to ask for the cascade file.

Whats the command to run it locally? Currently I am using go run github.com/esimov/caire/cmd/caire@latest

It's stated on the Readme file: go install github.com/esimov/caire/cmd/caire@latest

OK but this would run from source right. I want to run locally from root folder like you mentioned. I am guessing the command you shared would fetch from github and run

I am guessing the command you shared would fetch from github.

Exactly, it will fetch from the Github and also will create the executable. See the documentation: https://go.dev/ref/mod#go-install

Meantime I just wanted to make sure that building locally will embed the cascade file correctly, and it does. So if you build the main go file from cmd/caire running the go build main.go command the face detection will work. I need to figure out why the embedding is not working when you are running directly with go run command.

This is working locally by using the go run command as you mentioned. Closing this issue, as this works for me. Also, you might want to update the instructions to run it from local only.

$ go install github.com/esimov/caire/cmd/caire@latest should install the package along with its dependencies into the $GOPATH/bin folder, exactly as it's described in the README file: https://github.com/esimov/caire#install