File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed 
machine-learning/object-detection Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1616net  =  cv2 .dnn .readNetFromDarknet (config_path , weights_path )
1717
1818ln  =  net .getLayerNames ()
19- ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
19+ try :
20+     ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
21+ except  IndexError :
22+     # in case getUnconnectedOutLayers() returns 1D array when CUDA isn't available 
23+     ln  =  [ln [i  -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
2024
2125cap  =  cv2 .VideoCapture (0 )
2226
Original file line number Diff line number Diff line change 1717net  =  cv2 .dnn .readNetFromDarknet (config_path , weights_path )
1818
1919ln  =  net .getLayerNames ()
20- ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
20+ try :
21+     ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
22+ except  IndexError :
23+     # in case getUnconnectedOutLayers() returns 1D array when CUDA isn't available 
24+     ln  =  [ln [i  -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
2125# read the file from the command line 
2226video_file  =  sys .argv [1 ]
2327cap  =  cv2 .VideoCapture (video_file )
Original file line number Diff line number Diff line change 3737
3838# get all the layer names 
3939ln  =  net .getLayerNames ()
40- ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
40+ try :
41+     ln  =  [ln [i [0 ] -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
42+ except  IndexError :
43+     # in case getUnconnectedOutLayers() returns 1D array when CUDA isn't available 
44+     ln  =  [ln [i  -  1 ] for  i  in  net .getUnconnectedOutLayers ()]
4145# feed forward (inference) and get the network output 
4246# measure how much it took in seconds 
4347start  =  time .perf_counter ()
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments