tensor conversion
This commit is contained in:
		
							parent
							
								
									ce53d60702
								
							
						
					
					
						commit
						e73bd95677
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		
							
								
								
									
										5
									
								
								app.py
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								app.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -64,11 +64,14 @@ async def detect(websocket: WebSocket):
 | 
			
		|||
        boxes = []
 | 
			
		||||
        for r in model.track(frame, stream=False, persist=True):
 | 
			
		||||
            for box in r.boxes:
 | 
			
		||||
                track_id = None
 | 
			
		||||
                if hasattr(box, "id") and box.id is not None:
 | 
			
		||||
                    track_id = box.id.item()
 | 
			
		||||
                box_cpu = box.cpu()
 | 
			
		||||
                boxes.append({
 | 
			
		||||
                    "class": model.names[int(box_cpu.cls[0])],
 | 
			
		||||
                    "confidence": float(box_cpu.conf[0]),
 | 
			
		||||
                    "id": box_cpu.id,
 | 
			
		||||
                    "id": track_id,
 | 
			
		||||
                })
 | 
			
		||||
        # Broadcast to all subscribers of this URL
 | 
			
		||||
        detection_data = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue