Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce Face Classification #1418

Merged
merged 18 commits into from
Oct 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update how fetching unknown persons works
  • Loading branch information
derneuere committed Oct 16, 2024
commit fa947de2230cc9695c8ed0e1b8c57eda995eae99
46 changes: 20 additions & 26 deletions api/views/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,29 @@ class FaceListView(ListViewSet):
pagination_class = RegularResultsSetPagination

def get_queryset(self):
personid = self.request.query_params.get("person")

conditional_filter = Q(person=personid)
personid = self.request.query_params.get("person", None)
if personid == "None":
personid = None
analysis_method = self.request.query_params.get("analysis_method", "clustering")
order_by = ["-id"]

if (
self.request.query_params.get("inferred")
and self.request.query_params.get("inferred").lower() == "true"
self.request.query_params.get("inferred", "").lower() == "false"
and personid
):
if analysis_method == "classification":
conditional_filter = Q(classification_person=personid) & Q(person=None)
order_by = ["-classification_probability", "id"]
if analysis_method == "clustering":
conditional_filter = Q(cluster_person=personid) & Q(person=None)
order_by = ["-cluster_probability", "id"]
if self.request.query_params.get("order_by"):
if self.request.query_params.get("order_by").lower() == "date":
if analysis_method == "classification":
order_by = [
"photo__exif_timestamp",
"-classification_probability",
"id",
]
if analysis_method == "clustering":
order_by = [
"photo__exif_timestamp",
"-cluster_probability",
"id",
]
analysis_method = None
if analysis_method == "classification":
print("classification")
conditional_filter = Q(classification_person=personid) & Q(person=None)
order_by = ["-classification_probability", "id"]
if analysis_method == "clustering":
conditional_filter = Q(cluster_person=personid) & Q(person=None)
order_by = ["-cluster_probability", "id"]
if not analysis_method:
conditional_filter = Q(person=personid)
order_by = ["-id"]
if self.request.query_params.get("order_by", "").lower() == "date":
order_by = ["photo__exif_timestamp", *order_by]
print(conditional_filter)
return (
Face.objects.filter(
Q(photo__owner=self.request.user),
Expand Down