update
This commit is contained in:
@ -5,13 +5,13 @@ cfg = _C
|
|||||||
_C.RESIZE = 648
|
_C.RESIZE = 648
|
||||||
|
|
||||||
#Monitoring table of commodity identification System
|
#Monitoring table of commodity identification System
|
||||||
_C.model_path = './checkpoint/best_model.pth'
|
_C.model_path = '../module/ieemoo-ai-conpurchase/model/now/best_model.pth'
|
||||||
_C.maskImg = './imgs/mask.jpg'
|
_C.maskImg = '../module/ieemoo-ai-conpurchase/model/now/mask.jpg'
|
||||||
_C.maskImg1 = './imgs/mask1.jpg'
|
_C.maskImg1 = '../module/ieemoo-ai-conpurchase/model/now/mask1.jpg'
|
||||||
|
|
||||||
_C.maskAreaImg = './imgs/maskAreaImg.jpg'
|
_C.maskAreaImg = '../module/ieemoo-ai-conpurchase/model/now/maskAreaImg.jpg'
|
||||||
_C.maskAreaImg1 = './imgs/maskAreaImg1.jpg'
|
_C.maskAreaImg1 = '../module/ieemoo-ai-conpurchase/model/now/maskAreaImg1.jpg'
|
||||||
|
|
||||||
_C.streamModel = './checkpoint/raft-things.pth'
|
_C.streamModel = '../module/ieemoo-ai-conpurchase/model/now/raft-things.pth'
|
||||||
_C.hFile = './floder/tempdata'
|
_C.hFile = '../module/ieemoo-ai-conpurchase/document'
|
||||||
_C.videoPath = './floder/tempvideos'
|
_C.videoPath = '../module/ieemoo-ai-conpurchase/videos'
|
||||||
|
@ -4,6 +4,7 @@ from network.vanalysis_video import vanalysis, raft_init_model
|
|||||||
import argparse
|
import argparse
|
||||||
from floder.config import cfg
|
from floder.config import cfg
|
||||||
from utils.detect import opvideo
|
from utils.detect import opvideo
|
||||||
|
from utils.opfile import uploadf, removef
|
||||||
from utils.embedding import DataProcessing as dp
|
from utils.embedding import DataProcessing as dp
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -22,18 +23,26 @@ dps = dp(opt.checkpoint, cfg.model_path, opt.device)
|
|||||||
opv = opvideo(flowmodel, dps)
|
opv = opvideo(flowmodel, dps)
|
||||||
@app.route('/conpurchase', methods=['POST', 'GET'])
|
@app.route('/conpurchase', methods=['POST', 'GET'])
|
||||||
def conpurchase():
|
def conpurchase():
|
||||||
flag = request.form.get('flag')
|
try:
|
||||||
num_id = request.form.get('num')
|
result = 'continue'
|
||||||
video_name = request.form.get('uuid')
|
flag = request.form.get('flag')
|
||||||
video_data = request.files['video']
|
num_id = request.form.get('num')
|
||||||
videoPath = os.sep.join([cfg.videoPath, video_name])
|
video_name = request.form.get('uuid')
|
||||||
video_data.save(videoPath)
|
#print('>>>>>>>>>>flag:{} num_id:{} video_name:{}'.format(flag, num_id, video_name))
|
||||||
#opv.addFreature(uuid, num_id, videoPath)
|
uuid = video_name.split('_')[1]
|
||||||
#opv.opFreature(uuid, finalnum, videoPath)
|
video_data = request.files['video']
|
||||||
if not flag:
|
videoPath = os.sep.join([cfg.videoPath, uuid+'.mp4'])
|
||||||
opv.addFreature(uuid, num_id, videoPath)
|
video_data.save(videoPath)
|
||||||
else:
|
uploadf(video_name, num_id, videoPath)
|
||||||
result = opv.opFreature(uuid, 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
|
return result
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run('0.0.0.0', 8898)
|
app.run('0.0.0.0', 8898)
|
||||||
|
17
test.py
17
test.py
@ -26,15 +26,8 @@ if __name__ == '__main__':
|
|||||||
video2 = './imgs/2.mp4'
|
video2 = './imgs/2.mp4'
|
||||||
video3 = './imgs/3.mp4'
|
video3 = './imgs/3.mp4'
|
||||||
video4 = './imgs/4.mp4'
|
video4 = './imgs/4.mp4'
|
||||||
opv.addFeature('test', 1, video1)
|
opv.addFeature('test', 0, video1)
|
||||||
opv.addFeature('test', 2, video2)
|
opv.addFeature('test', 1, video2)
|
||||||
opv.addFeature('test', 3, video3)
|
opv.addFeature('test', 2, video3)
|
||||||
opv.opFeature('test', 4, video4)
|
result = opv.opFeature('test', 3, video4)
|
||||||
#imglist = filt(video)
|
print('result>>>>> {}'.format(result))
|
||||||
#model = raft_init_model(opt)
|
|
||||||
#imgs = vanalysis(model, imglist)
|
|
||||||
#print('>>>>>>>>>>>>>>>>>> {}'.format(type(imgs)))
|
|
||||||
#
|
|
||||||
#re = dps.getFeatures(imgs)
|
|
||||||
|
|
||||||
#print(re)
|
|
||||||
|
@ -21,11 +21,11 @@ class opvideo:
|
|||||||
def opFeature(self, uuid, finalnum, video):
|
def opFeature(self, uuid, finalnum, video):
|
||||||
videoFeature = []
|
videoFeature = []
|
||||||
self.addFeature(uuid, finalnum, video)
|
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)
|
feature = readf(uuid, num_id)
|
||||||
videoFeature.append(feature)
|
videoFeature.append(feature)
|
||||||
redic = self.opVideFeature(videoFeature)
|
redic = self.opVideFeature(videoFeature)
|
||||||
#print(redic)
|
|
||||||
return redic
|
return redic
|
||||||
|
|
||||||
def opVideFeature(self, videoFeature):
|
def opVideFeature(self, videoFeature):
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
import h5py, os
|
import h5py, os
|
||||||
from floder.config import cfg
|
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):
|
def writef(uuid, num_id, feature):
|
||||||
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
||||||
@ -9,7 +18,7 @@ def writef(uuid, num_id, feature):
|
|||||||
else:
|
else:
|
||||||
f = h5py.File(fname, 'a')
|
f = h5py.File(fname, 'a')
|
||||||
f[str(num_id)] = feature
|
f[str(num_id)] = feature
|
||||||
print('>>>>>>>have been write')
|
#print('>>>>>>>have been write')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def readf(uuid, num_id):
|
def readf(uuid, num_id):
|
||||||
@ -22,3 +31,9 @@ def readf(uuid, num_id):
|
|||||||
def removef(uuid):
|
def removef(uuid):
|
||||||
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
||||||
os.remove(fname)
|
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