40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
from flask import request, Flask
|
|
import os
|
|
from network.vanalysis_video import vanalysis, raft_init_model
|
|
import argparse
|
|
from floder.config import cfg
|
|
from utils.detect import opvideo
|
|
from utils.embedding import DataProcessing as dp
|
|
|
|
app = Flask(__name__)
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--model', default='./checkpoint/raft-small.pth',help="restore checkpoint")
|
|
parser.add_argument('--checkpoint', default='mobilevit',help="get embedding ")
|
|
parser.add_argument('--device', default='cuda',help="device")
|
|
parser.add_argument('--small', type=bool, default=True, help='use small model')
|
|
parser.add_argument('--mixed_precision', action='store_true', help='use mixed precision')
|
|
parser.add_argument('--alternate_corr', action='store_true', help='use efficent correlation implementation')
|
|
opt, unknown = parser.parse_known_args()
|
|
|
|
flowmodel = raft_init_model(opt)
|
|
dps = dp(opt.checkpoint, cfg.model_path, opt.device)
|
|
opv = opvideo(flowmodel, dps)
|
|
@app.route('/conpurchase', methods=['POST', 'GET'])
|
|
def conpurchase():
|
|
flag = request.form.get('flag')
|
|
num_id = request.form.get('num')
|
|
video_name = request.form.get('uuid')
|
|
video_data = request.files['video']
|
|
videoPath = os.sep.join([cfg.videoPath, video_name])
|
|
video_data.save(videoPath)
|
|
#opv.addFreature(uuid, num_id, videoPath)
|
|
#opv.opFreature(uuid, finalnum, videoPath)
|
|
if not flag:
|
|
opv.addFreature(uuid, num_id, videoPath)
|
|
else:
|
|
result = opv.opFreature(uuid, num_id, videoPath)
|
|
return result
|
|
if __name__ == '__main__':
|
|
app.run('0.0.0.0', 8898)
|