update
This commit is contained in:
@ -5,13 +5,13 @@ cfg = _C
|
||||
_C.RESIZE = 648
|
||||
|
||||
#Monitoring table of commodity identification System
|
||||
_C.model_path = './checkpoint/best_model.pth'
|
||||
_C.maskImg = './imgs/mask.jpg'
|
||||
_C.maskImg1 = './imgs/mask1.jpg'
|
||||
_C.model_path = '../module/ieemoo-ai-conpurchase/model/now/best_model.pth'
|
||||
_C.maskImg = '../module/ieemoo-ai-conpurchase/model/now/mask.jpg'
|
||||
_C.maskImg1 = '../module/ieemoo-ai-conpurchase/model/now/mask1.jpg'
|
||||
|
||||
_C.maskAreaImg = './imgs/maskAreaImg.jpg'
|
||||
_C.maskAreaImg1 = './imgs/maskAreaImg1.jpg'
|
||||
_C.maskAreaImg = '../module/ieemoo-ai-conpurchase/model/now/maskAreaImg.jpg'
|
||||
_C.maskAreaImg1 = '../module/ieemoo-ai-conpurchase/model/now/maskAreaImg1.jpg'
|
||||
|
||||
_C.streamModel = './checkpoint/raft-things.pth'
|
||||
_C.hFile = './floder/tempdata'
|
||||
_C.videoPath = './floder/tempvideos'
|
||||
_C.streamModel = '../module/ieemoo-ai-conpurchase/model/now/raft-things.pth'
|
||||
_C.hFile = '../module/ieemoo-ai-conpurchase/document'
|
||||
_C.videoPath = '../module/ieemoo-ai-conpurchase/videos'
|
||||
|
@ -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():
|
||||
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, video_name])
|
||||
videoPath = os.sep.join([cfg.videoPath, uuid+'.mp4'])
|
||||
video_data.save(videoPath)
|
||||
#opv.addFreature(uuid, num_id, videoPath)
|
||||
#opv.opFreature(uuid, finalnum, videoPath)
|
||||
if not flag:
|
||||
opv.addFreature(uuid, num_id, videoPath)
|
||||
uploadf(video_name, num_id, videoPath)
|
||||
if flag == 'False':
|
||||
opv.addFeature(uuid, num_id, videoPath)
|
||||
else:
|
||||
result = opv.opFreature(uuid, num_id, videoPath)
|
||||
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)
|
||||
|
17
test.py
17
test.py
@ -26,15 +26,8 @@ if __name__ == '__main__':
|
||||
video2 = './imgs/2.mp4'
|
||||
video3 = './imgs/3.mp4'
|
||||
video4 = './imgs/4.mp4'
|
||||
opv.addFeature('test', 1, video1)
|
||||
opv.addFeature('test', 2, video2)
|
||||
opv.addFeature('test', 3, video3)
|
||||
opv.opFeature('test', 4, video4)
|
||||
#imglist = filt(video)
|
||||
#model = raft_init_model(opt)
|
||||
#imgs = vanalysis(model, imglist)
|
||||
#print('>>>>>>>>>>>>>>>>>> {}'.format(type(imgs)))
|
||||
#
|
||||
#re = dps.getFeatures(imgs)
|
||||
|
||||
#print(re)
|
||||
opv.addFeature('test', 0, video1)
|
||||
opv.addFeature('test', 1, video2)
|
||||
opv.addFeature('test', 2, video3)
|
||||
result = opv.opFeature('test', 3, video4)
|
||||
print('result>>>>> {}'.format(result))
|
||||
|
@ -21,11 +21,11 @@ class opvideo:
|
||||
def opFeature(self, uuid, finalnum, video):
|
||||
videoFeature = []
|
||||
self.addFeature(uuid, finalnum, video)
|
||||
for num_id in range(0, finalnum):
|
||||
print('>>>>>{}'.format(range(0, int(finalnum)+1)))
|
||||
for num_id in range(0, int(finalnum)+1):
|
||||
feature = readf(uuid, num_id)
|
||||
videoFeature.append(feature)
|
||||
redic = self.opVideFeature(videoFeature)
|
||||
#print(redic)
|
||||
return redic
|
||||
|
||||
def opVideFeature(self, videoFeature):
|
||||
|
@ -1,5 +1,14 @@
|
||||
import h5py, os
|
||||
from floder.config import cfg
|
||||
from obs import ObsClient
|
||||
import obs
|
||||
obsClient = ObsClient(
|
||||
access_key_id='LHXJC7GIC2NNUUHHTNVI',
|
||||
secret_access_key='sVWvEItrFKWPp5DxeMvX8jLFU69iXPpzkjuMX3iM',
|
||||
server='https://obs.cn-east-3.myhuaweicloud.com')
|
||||
bucketName = 'ieemoo-ai'
|
||||
headers = obs.SetObjectMetadataHeader()
|
||||
headers.cacheControl = "no-cache"
|
||||
|
||||
def writef(uuid, num_id, feature):
|
||||
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
||||
@ -9,7 +18,7 @@ def writef(uuid, num_id, feature):
|
||||
else:
|
||||
f = h5py.File(fname, 'a')
|
||||
f[str(num_id)] = feature
|
||||
print('>>>>>>>have been write')
|
||||
#print('>>>>>>>have been write')
|
||||
f.close()
|
||||
|
||||
def readf(uuid, num_id):
|
||||
@ -22,3 +31,9 @@ def readf(uuid, num_id):
|
||||
def removef(uuid):
|
||||
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
||||
os.remove(fname)
|
||||
|
||||
def uploadf(video_name, num, file_path):
|
||||
time = video_name.split('-')[0]
|
||||
objectkey = video_name.split('.')[0]+'_'+str(num)+'.mp4'
|
||||
objectkey = 'conpurchase/'+time+'/'+objectkey
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path, headers=headers)
|
||||
|
Reference in New Issue
Block a user