car_seg.py
def image_seg(file_names):
  '''
  Function for car image segmentation
  
  filename : str
    name of the Image
  
  Returns
    None
  '''
  # Load a random image from the images folder
  # file_names = next(os.walk(IMAGE_DIR))[2]
  image = skimage.io.imread(file_names)

  # Run detection
  results = model.detect([image], verbose=0)

  idx_ar = np.where(results[0]['class_ids'] == 3)

  for i,idx in enumerate(idx_ar[0]):
    if i == 0:
      car_mask = results[0]['masks'][:,:,idx]
    else:
      car_mask = car_mask + results[0]['masks'][:,:,idx]

  tmp, tmp_b = image.copy(), image.copy()
  tmp[~car_mask] = 0
  tmp_b[car_mask] = 0

  img_overlay = cv2.addWeighted(tmp,1,tmp_b,0.35,0)
  
  plt.rcParams["figure.figsize"] = (16,10)
  plt.imshow(np.hstack((image,img_overlay)))
  plt.show()

  Function for car image segmentation
  
  filename : str
    name of the Image
  
  Returns
    None
  
Function for car image segmentation
filename : str
name of the Image

Returns
None
Function for car image segmentation filename : str name of the Image Returns None
def image_seg(file_names):
  image = skimage.io.imread(file_names)
  results = model.detect([image], verbose=0)
  idx_ar = np.where(results[0]['class_ids'] == 3)
  for i,idx in enumerate(idx_ar[0]):
    if i == 0:
      car_mask = results[0]['masks'][:,:,idx]
    else:
      car_mask = car_mask + results[0]['masks'][:,:,idx]
  tmp, tmp_b = image.copy(), image.copy()
  tmp[~car_mask] = 0
  tmp_b[car_mask] = 0
  img_overlay = cv2.addWeighted(tmp,1,tmp_b,0.35,0)
  plt.rcParams["figure.figsize"] = (16,10)
  plt.imshow(np.hstack((image,img_overlay)))
  plt.show()
def image_seg ( file_names ) : image = skimage . io . imread ( file_names ) results = model . detect ( [ image ] , verbose = 0 ) idx_ar = np . where ( results [ 0 ] [ 'class_ids' ] == 3 ) for i , idx in enumerate ( idx_ar [ 0 ] ) : if i == 0 : car_mask = results [ 0 ] [ 'masks' ] [ : , : , idx ] else : car_mask = car_mask + results [ 0 ] [ 'masks' ] [ : , : , idx ] tmp , tmp_b = image . copy ( ) , image . copy ( ) tmp [ ~ car_mask ] = 0 tmp_b [ car_mask ] = 0 img_overlay = cv2 . addWeighted ( tmp , 1 , tmp_b , 0.35 , 0 ) plt . rcParams [ "figure.figsize" ] = ( 16 , 10 ) plt . imshow ( np . hstack ( ( image , img_overlay ) ) ) plt . show ( )
Function for car image segmentation
filename : str
name of the Image
Function for car image segmentation filename : str name of the Image
'''
  Function for car image segmentation
  
  filename : str
    name of the Image
  
  Returns
    None
  ''' # Load a random image from the images folder # file_names = next(os.walk(IMAGE_DIR))[2] # Run detection
file_names