This commit is contained in:
2023-06-26 16:31:07 +08:00
parent 00d6bc25c5
commit e749605916
5 changed files with 52 additions and 35 deletions

View File

@ -4,6 +4,7 @@ from network.vanalysis_video import vanalysis, raft_init_model
import argparse
from floder.config import cfg
from utils.detect import opvideo
from utils.opfile import uploadf, removef
from utils.embedding import DataProcessing as dp
app = Flask(__name__)
@ -22,18 +23,26 @@ 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)
try:
result = 'continue'
flag = request.form.get('flag')
num_id = request.form.get('num')
video_name = request.form.get('uuid')
#print('>>>>>>>>>>flag:{} num_id:{} video_name:{}'.format(flag, num_id, video_name))
uuid = video_name.split('_')[1]
video_data = request.files['video']
videoPath = os.sep.join([cfg.videoPath, uuid+'.mp4'])
video_data.save(videoPath)
uploadf(video_name, num_id, videoPath)
if flag == 'False':
opv.addFeature(uuid, num_id, videoPath)
else:
result = opv.opFeature(uuid, num_id, videoPath)
os.remove(videoPath)
#os.remove(os.sep.join([cfg.hFile, uuid+'.h5']))
removef(uuid)
except Exception as e:
print(e)
return result
if __name__ == '__main__':
app.run('0.0.0.0', 8898)