Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuzJ committed Nov 11, 2023
1 parent f9e76a3 commit f380452
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion backend/pocketbase/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ func main() {

// serves static files from the provided public dir (if exists)
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.GET("/api/weihu/score", func(c echo.Context) error {
e.Router.GET("/api/weihua/score", func(c echo.Context) error {

// Figure out where video is
// Get reference score

// GetScore
score := score.GetScore()

return c.String(http.StatusOK, score)
}, apis.ActivityLogger(app))
return nil
Expand Down
Binary file added backend/pocketbase/pb_data/data.db
Binary file not shown.
Binary file added backend/pocketbase/pb_data/data.db-shm
Binary file not shown.
Empty file.
Binary file added backend/pocketbase/pb_data/logs.db
Binary file not shown.
Binary file added backend/pocketbase/pb_data/logs.db-shm
Binary file not shown.
Binary file added backend/pocketbase/pb_data/logs.db-wal
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/pocketbase/score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func GetScore() string {
yoloServerUrl := "http://127.0.0.1:5000/yolo_model"
yoloServerUrl := "http://127.0.0.1:5000/infer"

response, err := http.Get(yoloServerUrl)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions backend/yolo_model/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def score(frames1, frames2):
_frames_to_movements(frames2)))


def _frames_to_movements(frames: list[dict]):
def _frames_to_movements(frames: list[dict]) -> list[float]:
# assert len(np.asarray(frames).shape) == 1, 'Take only one person for each frame'
movements = [[] for i in range(0, 17)] # all relative to upper left corner of the bounding box
# all relative to upper left corner of the bounding box
movements = [[] for i in range(0, 17)]
for frame in frames:
for i in range(0, 17):
x = frame['keypoints']['x'][i]
Expand All @@ -27,10 +28,12 @@ def _frames_to_movements(frames: list[dict]):

for i in range(0, 17):
if np.linalg.norm(movements[i, :, 0]) != 0:
movements[i, :, 0] = movements[i, :, 0] / np.linalg.norm(movements[i, :, 0])
movements[i, :, 0] = movements[i, :, 0] / \
np.linalg.norm(movements[i, :, 0])

if np.linalg.norm(movements[i, :, 1]) != 0:
movements[i, :, 1] = movements[i, :, 1] / np.linalg.norm(movements[i, :, 1])
movements[i, :, 1] = movements[i, :, 1] / \
np.linalg.norm(movements[i, :, 1])
return movements


Expand Down
2 changes: 1 addition & 1 deletion backend/yolo_model/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@app.route('/infer')
def infer(video_link):
def infer():
return model.cool_thing()


Expand Down
4 changes: 3 additions & 1 deletion backend/yolo_model/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Flask
flask
dtaidistance
numpy

0 comments on commit f380452

Please sign in to comment.