device_count
parent
05bdd0abfe
commit
a4af74a7cb
4
app.py
4
app.py
|
@ -14,6 +14,7 @@ from multiprocessing import Process, Event
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
device_count=0
|
||||||
workers = {}
|
workers = {}
|
||||||
|
|
||||||
@app.route('/start/<id>')
|
@app.route('/start/<id>')
|
||||||
|
@ -62,7 +63,6 @@ def worker(id,source,region=None,stream=False):
|
||||||
region = 10
|
region = 10
|
||||||
else:
|
else:
|
||||||
region = int(region)
|
region = int(region)
|
||||||
device_count = torch.cuda.device_count()
|
|
||||||
print("GPU device count:", device_count)
|
print("GPU device count:", device_count)
|
||||||
print("start loading model...",id,source,region)
|
print("start loading model...",id,source,region)
|
||||||
model = YOLO('./best.pt')
|
model = YOLO('./best.pt')
|
||||||
|
@ -95,6 +95,7 @@ def worker(id,source,region=None,stream=False):
|
||||||
print("Error opening video stream....")
|
print("Error opening video stream....")
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
|
print("device_count",int(id)%device_count)
|
||||||
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%device_count)
|
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%device_count)
|
||||||
use += " track:"+str((time.time()*1000) - bgn)
|
use += " track:"+str((time.time()*1000) - bgn)
|
||||||
del(ret)
|
del(ret)
|
||||||
|
@ -190,6 +191,7 @@ def post_request(url, data):
|
||||||
# break
|
# break
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
device_count = torch.cuda.device_count()
|
||||||
# cProfile.run('test_function()', 'test_function.profile')
|
# cProfile.run('test_function()', 'test_function.profile')
|
||||||
# p = pstats.Stats('test_function.profile')
|
# p = pstats.Stats('test_function.profile')
|
||||||
# p.sort_stats('cumulative').print_stats(100) # Top 10 by cumulative time
|
# p.sort_stats('cumulative').print_stats(100) # Top 10 by cumulative time
|
||||||
|
|
10
show.py
10
show.py
|
@ -25,6 +25,16 @@ def show():
|
||||||
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
|
@app.route('/mj',methods=['POST'])
|
||||||
|
def mj():
|
||||||
|
print(request.json)
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
@app.route('/cq',methods=['POST'])
|
||||||
|
def cq():
|
||||||
|
print(request.json)
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.logger.setLevel(logging.ERROR)
|
app.logger.setLevel(logging.ERROR)
|
||||||
app.run("0.0.0.0",port=8000,threaded=True)
|
app.run("0.0.0.0",port=8000,threaded=True)
|
||||||
|
|
Loading…
Reference in New Issue