Giter Club home page Giter Club logo

Comments (4)

Kagami avatar Kagami commented on June 12, 2024

Try these methods to improve accuracy: https://github.com/Kagami/go-face#how-to-improve-recognition-accuracy

from go-face.

Archie1978 avatar Archie1978 commented on June 12, 2024

Thank you for the quick reply.

I read the code and I found the problem. In fact, I put an image of more than Pascal_Praud and the algorithm
` std::unordered_map<int, std::pair<int, float>> hits_by_cat;
for (int i = 0; i < len; i++) {
int idx = distances[i].first;
float dist = distances[i].second;
auto cat = cats.find(idx);
if (cat == cats.end())
continue;
int cat_idx = cat->second;
auto hit = hits_by_cat.find(cat_idx);
if (hit == hits_by_cat.end()) {
// printf("1 hit for %d (%d: %f)\n", cat_idx, idx, dist);
hits_by_cat[cat_idx] = {1, dist};
} else {
// printf("+1 hit for %d (%d: %f)\n", cat_idx, idx, dist);
hits_by_cat[cat_idx].first++;
}
}

auto hit = std::max_element(
	hits_by_cat.begin(), hits_by_cat.end(),
	[](const auto a, const auto b) {
		auto hits1 = a.second.first;
		auto hits2 = b.second.first;
		auto dist1 = a.second.second;
		auto dist2 = b.second.second;
		if (hits1 == hits2) return dist1 > dist2;
		return hits1 < hits2;
	}
);`

It only works if there is the same number of images in the training. If I do that, it works.

Would you have idea for improvement?

from go-face.

Kagami avatar Kagami commented on June 12, 2024

This algorithm tries to improve accuracy by counting number of hits for the same category in top 10 minimal distances. You can implement some modificaton of that method (e.g. choose just the minimal distance between descriptors) or provide more samples so result would be more accurate.

Maybe we should add support to go-face for few other classify algorithms. PR would be great.

Btw, I've tried Yuha's photo you linked with example from readme and it correctly prints Yuha for me.

from go-face.

Archie1978 avatar Archie1978 commented on June 12, 2024

Yes it great.

I modified classify.cc by :
`
if (hit == hits_by_cat.end()) {
printf("1 hit for %d (%d: %f)\n", cat_idx, idx, dist);
hits_by_cat[cat_idx] = {1, dist};
} else {
printf("+1 hit for %d (%d: %f)\n", cat_idx, idx, dist);
hits_by_cat[cat_idx].first++;
hits_by_cat[cat_idx].second+=dist;
}
}

auto hit = std::max_element(
	hits_by_cat.begin(), hits_by_cat.end(),
	[](const auto a, const auto b) {
		auto hits1 = a.second.first;
		auto hits2 = b.second.first;
		auto dist1 = a.second.second;
		auto dist2 = b.second.second;
		return float(hits1)/dist1 < float(hits2)/dist2;
	}
);

`
It is an average of the number of hits in the distance. But it depends on datasets ;).
I'm looking if I can do a knn classification.

Thanks you

from go-face.

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.