Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
calvin-laurenson committed Nov 1, 2023
1 parent 18f4c16 commit 8f9439a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions backend/classsync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
allow_headers=["*"],
)


@app.middleware("http")
async def add_process_time_header(request: Request, call_next):
start_time = time.time()
Expand All @@ -39,6 +40,7 @@ async def add_process_time_header(request: Request, call_next):
response.headers["X-Process-Time"] = str(process_time)
return response


# Posts
@app.post("/add_teacher")
async def add_teacher(name: str):
Expand Down Expand Up @@ -92,10 +94,20 @@ async def add_image(image_file: Annotated[bytes, File()], time: int, tardy: bool
.order_by(Student.face_embedding.cosine_distance(face).desc())
.all()
)
students = [student for student in students if student.face_embedding is not None]
students = [
student for student in students if student.face_embedding is not None
]
for student in students:
print(student.name, ": ", cosine_similarity(student.face_embedding, np.array(face)), "\n\n")
students = [(student, cosine_similarity(student.face_embedding, np.array(face))) for student in students]
print(
student.name,
": ",
cosine_similarity(student.face_embedding, np.array(face)),
"\n\n",
)
students = [
(student, cosine_similarity(student.face_embedding, np.array(face)))
for student in students
]
students = [student for student in students if student[1] > 0.25]
if len(students) == 0:
continue
Expand Down Expand Up @@ -304,7 +316,10 @@ async def get_classes_by_teacher_id(teacher_id: int):
with Session(engine) as session:
class_query = session.query(PeriodClass)
periodclasses = class_query.filter(PeriodClass.teacher_id == teacher_id).all()
return {"error": None, "periodclasses": [{"name":c.name, "id": c.id} for c in periodclasses]}
return {
"error": None,
"periodclasses": [{"name": c.name, "id": c.id} for c in periodclasses],
}


if __name__ == "__main__":
Expand Down

0 comments on commit 8f9439a

Please sign in to comment.