logs
parent
2763f9bafc
commit
a54d47c3c1
27
app.py
27
app.py
|
@ -4,10 +4,25 @@ import time
|
||||||
import requests
|
import requests
|
||||||
import supervision as sv
|
import supervision as sv
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
from flask import Flask,request,Response
|
from flask import Flask,request,Response
|
||||||
from multiprocessing import Process, Event
|
from multiprocessing import Process, Event
|
||||||
|
|
||||||
|
import torch
|
||||||
|
|
||||||
|
device_count = 0
|
||||||
|
|
||||||
|
if torch.cuda.is_available():
|
||||||
|
device_count = torch.cuda.device_count()
|
||||||
|
print("GPU is available.")
|
||||||
|
print("GPU device count:", torch.cuda.device_count())
|
||||||
|
print("GPU device Current:", torch.cuda.current_device())
|
||||||
|
print("GPU device name:", torch.cuda.get_device_name(torch.cuda.current_device()))
|
||||||
|
else:
|
||||||
|
print("GPU is not available.")
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
workers = {}
|
workers = {}
|
||||||
|
@ -39,7 +54,15 @@ def stop(id):
|
||||||
|
|
||||||
@app.route('/show',methods=['POST'])
|
@app.route('/show',methods=['POST'])
|
||||||
def show():
|
def show():
|
||||||
print(request.data)
|
# print(request.json)
|
||||||
|
data = request.json["content"]
|
||||||
|
balls = data["balls"]
|
||||||
|
table = data["table"]
|
||||||
|
text = f"table:{table:>3} "
|
||||||
|
for i in range(16):
|
||||||
|
ball = "#" if "ball"+str(i) in balls else " "
|
||||||
|
text += f"| {i} : {ball} "
|
||||||
|
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
def worker(id,source,region=None,stream=False):
|
def worker(id,source,region=None,stream=False):
|
||||||
|
@ -60,7 +83,7 @@ def worker(id,source,region=None,stream=False):
|
||||||
if not ret:
|
if not ret:
|
||||||
print("Error read video stream.")
|
print("Error read video stream.")
|
||||||
break
|
break
|
||||||
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%4)
|
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%device_count)
|
||||||
result = result[0]
|
result = result[0]
|
||||||
detections = sv.Detections.from_yolov8(result)
|
detections = sv.Detections.from_yolov8(result)
|
||||||
if result.boxes.id is not None:
|
if result.boxes.id is not None:
|
||||||
|
|
Loading…
Reference in New Issue