image-segmentation

How to create a binary mask from a yolo8 segmentation result

How to create a binary mask from a yolo8 segmentation result Question: I want to segment an image using yolo8 and then create a mask for all objects in the image with specific class. I have developed this code: img=cv2.imread(‘images/bus.jpg’) model = YOLO(‘yolov8m-seg.pt’) results = model.predict(source=img.copy(), save=False, save_txt=False) class_ids = np.array(results[0].boxes.cls.cpu(), dtype="int") for i in …

Total answers: 2

module 'keras.utils.generic_utils' has no attribute 'get_custom_objects' when importing segmentation_models

module 'keras.utils.generic_utils' has no attribute 'get_custom_objects' when importing segmentation_models Question: I am working on google colab with the segmentation_models library. It worked perfectly the first week using it, but now it seems that I can’t import the library anymore. Here is the error message, when I execute import segmentation_models as sm : ————————————————————————— AttributeError Traceback …

Total answers: 2

ValueError: Inputs have incompatible shapes

ValueError: Inputs have incompatible shapes Question: I have the following code: def fcn8_decoder(convs, n_classes): # features from the encoder stage f3, f4, f5 = convs # number of filters n = 512 # add convolutional layers on top of the CNN extractor. o = tf.keras.layers.Conv2D(n , (7 , 7) , activation=’relu’ , padding=’same’, name="conv6", data_format=IMAGE_ORDERING)(f5) …

Total answers: 4

How do you train Huggingface Maskformer for instance segmentation?

How do you train Huggingface Maskformer for instance segmentation? Question: I can see an example to train for semantic segmentation but I’m unclear how to fine tune a model for instance segmentation. Specifically how to calculate the loss function assuming the data is in COCO format? Asked By: nickponline || Source Answers: I found a …

Total answers: 1

How to extract a segmented object or change the background of the original image?

How to extract a segmented object or change the background of the original image? Question: I am doing a detection with Mask R-CNN of one model available at Train Mask R-CNN for Image Segmentation. Code I # Load Image img = cv2.imread("/content/image.jpg") test_model, inference_config = load_inference_model(1, "/content/mask_rcnn.h5") image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Detect results r …

Total answers: 1

Resizing binary mask stored in numpy array

Resizing binary mask stored in numpy array Question: I have got numpy arrays consisting of only 0s and 1s. They are supposed to be the target for an Image Segmentation Model, so I am trying to resize them all so they have the same dimensions. The problem is that when resizing with the code below, …

Total answers: 1

how to segment text/handwritten lines using horizontal profile projection?

how to segment text/handwritten lines using horizontal profile projection? Question: I have managed to get the horizontal profile projection of a handwritten image(the code of which in python is mentioned below). I wish to segment the individual lines and save them. I know this can be done using other methods but I wish to implement …

Total answers: 1

modify image to black text on white background

modify image to black text on white background Question: I have an image that need to do OCR (Optical Character Recognition) to extract all data. First I want to convert color image to black text on white background in order to improve OCR accuracy. I try below code from PIL import Image img = Image.open("data7.png") …

Total answers: 3

In detectron2 there are class IDs instead of class names

In detectron2 there are class IDs instead of class names Question: I finished training model for instance segmentation in detectron2 when I test images in training files there is no problem class names(apple,banana,orange) are written on the image but I downloaded some fruit images from the internet and class names are not written on the …

Total answers: 3