dolor8946 commited on
Commit
a91cbfb
1 Parent(s): 3b78e59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -26
app.py CHANGED
@@ -8,32 +8,6 @@ app = FastAPI()
8
  model = YOLO('model.pt')
9
  #device = torch.device('cuda')
10
  #model.to(device)
11
- @app.post("/")
12
- def detect(data):
13
- try:
14
- objects_dict = {}
15
- img_arr = data['img_arr']
16
- img_arr = cv2.resize(img_arr, (416, 416))
17
- img_arr = np.array([img_arr.transpose(2, 0, 1)])
18
- #img_arr = torch.from_numpy(img_arr).float().to(device)
19
- results = model(img_arr)
20
-
21
- for r in results:
22
- n = len(r.boxes.cls)
23
-
24
- for i in range(n):
25
- cls = int(r.boxes.cls[i].cpu())
26
- temp_obj = [int(r.boxes.conf[i].cpu()), r.boxes.xyxy[i].cpu().numpy()] #уверенность модели, координаты прямоугольника
27
-
28
- if cls not in objects_dict:
29
- objects_dict[cls] = [temp_obj]
30
- else:
31
- objects_dict[cls].append(temp_obj)
32
- return objects_dict
33
-
34
- except Exception as e:
35
- print(str(e))
36
- return {}
37
 
38
  @app.get("/detect")
39
  def test():
 
8
  model = YOLO('model.pt')
9
  #device = torch.device('cuda')
10
  #model.to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  @app.get("/detect")
13
  def test():