Skip to content

Commit

Permalink
updates flask server
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgeho committed Nov 11, 2023
1 parent 733c3e7 commit c305f34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions backend/yolo_model/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from dtaidistance import dtw


# call only this one!
# call only this one! and frames should only have one person (frames: array of dicts)
def score(frames1, frames2):
# high means good match
return 100 * (1 - _distance(_frames_to_movements(frames1),
_frames_to_movements(frames2)))


def _frames_to_movements(frames):
assert len(np.asarray(frames).shape) == 1, 'Take only one person for each frame'
def _frames_to_movements(frames: list[dict]):
# 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
for frame in frames:
for i in range(0, 17):
Expand Down
21 changes: 15 additions & 6 deletions backend/yolo_model/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from flask import Flask

import comparison
import model
from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/yolo_model', methods=['GET'])
def get_yolo_model():
re = model.cool_thing()
return jsonify({'message': re})

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


@app.route('/compare')
def compare(frames1, frames2):
return comparison.score(frames1, frames2)


if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True)

0 comments on commit c305f34

Please sign in to comment.