ultralytics / ultralytics

NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
24.46k stars 4.86k forks source link

How do I save the images of the yolov8 training predictions? #375

Closed Lay-best closed 1 year ago

Lay-best commented 1 year ago

Search before asking

Question

In the yolov8 interface , when I use the method predict which in the class YOLO , I do not know how to save the output images.And there maybe have not args in the method predict to save the output images.

Additional

No response

kyoko9000 commented 1 year ago

you can use results = model("path to your image" , save=True)

Lay-best commented 1 year ago

you can use results = model("path to your image" , save=True) I got it .Thank you.

robmarkcole commented 1 year ago

save=True would be a good default, that appears to be the behaviour when using CLI & yolo task=detect mode=predict

dmddmd commented 1 year ago

@kyoko9000 where does it save?

And does it also work for stream=True

prince0310 commented 1 year ago

@kyoko9000 it will save on runs\detect\predict folder

dmddmd commented 1 year ago

found it .. it was confusing that the runs folder is saved two directories back

prince0310 commented 1 year ago

if you don't need further clarification please close the issue

Harshit26042004 commented 1 year ago

@kyoko9000 where does it save?

And does it also work for stream=True

is stream=True used for streaming live in web-cam?

JJ-McClure commented 1 year ago

The 'save' option needs to be listed under 'Configuration'.

Siddharth1698 commented 1 year ago

Add save = True at end. That is, !yolo predict model="ultralytics/runs/detect/train/weights/best.pt" save=True

RelativelyFine commented 1 year ago

How do define the location where it will save?

Laughing-q commented 1 year ago

@RelativelyFine By default it'll save to runs/task/predict and the task can be detect/segment/classify(depends on what task you're using). The save path consists of two args -> project/name, and you can modify these two args to customize your save path.

sangramdhurve commented 1 year ago

try using this code it is working for me,it was really good but I want here cropping of detected bounding box and save it into disk, if anyone can help me please

from ultralytics import YOLO import cv2

model = YOLO("model/best.pt") model.predict(source = '/home/sangramdh/Downloads/rajsir/test_models/test/2 Wheel Test/', show = True, save=True) cv2.waitKey(0)

glenn-jocher commented 1 year ago

To save crops you can use save_crop=True

kittutrans commented 1 year ago

Add save = True at end. That is, !yolo predict model="ultralytics/runs/detect/train/weights/best.pt" save=True

Thanks it worked

Youssefkhaled55 commented 1 year ago

Ultralytics now use the flag "save=True" to save results. to save the output results by making runs folder automatically and saving the image in it for example code be like this: yolo task=detect mode=predict model=yolov8n.pt source=t.jpg conf=0.5 save=True

Dineth9D commented 1 year ago

Here you can send an image through the Yolov8 model and get predictions.

from ultralytics import YOLO

model = YOLO("best.pt") path = "image.jpg"

results = model.predict(source=path, show=True, save=False, save_txt=False, save_conf=False)

arjun5arvind commented 1 year ago

@kyoko9000 where does it save? And does it also work for stream=True

is stream=True used for streaming live in web-cam?

is there any way for live web cam usage?

Dineth9D commented 1 year ago

accepts all formats - image/dir/Path/URL/video/PIL/ndarray. 0 for webcam results = model.predict(source="0")

JesseDeGelderVW commented 1 year ago

Let's say I want to run my model over a large dataset, can I also make it so only detections above, say 0.6 confidence are saved?

glenn-jocher commented 1 year ago

@Camerabiologist you can set conf to any value you'd like during predict:

yolo predict conf=0.6
glenn-jocher commented 1 year ago

@Camerabiologist you can set conf to any value you'd like during predict:

yolo predict conf=0.6

See https://docs.ultralytics.com/

JesseDeGelderVW commented 1 year ago

Thanks @glenn-jocher! My current yolo predict outputs my full dataset including detections and non-detections. I want to filter out the non-detections from the resulting Predict_xx folder.

glenn-jocher commented 1 year ago

@Camerabiologist see https://docs.ultralytics.com/modes/predict for examples

JiaxinWang123 commented 1 year ago

@Laughing-q > @RelativelyFine By default it'll save to runs/task/predict and the task can be detect/segment/classify(depends on what task you're using). The save path consists of two args -> project/name, and you can modify these two args to customize your save path.

Could you please give a short example code of customizing predicting save path?

Laughing-q commented 1 year ago

@JiaxinWang123

model = YOLO("yolov8n.pt")
model.predict(source=..., project="xx", name="xxx")

then it'll be save in xx/xxx.

JiaxinWang123 commented 1 year ago

@Laughing-q

@JiaxinWang123

model = YOLO("yolov8n.pt")
model.predict(source=..., project="xx", name="xxx")

then it'll be save in xx/xxx.

Great! It worked, thanks!

dronespov commented 11 months ago

Hello, im trying to save a video. What needs to be added to this python script?

import cv2 from ultralytics import YOLO

Load the custom YOLOv8 model

model = YOLO('/path/to/best.pt')

Open the video file

video_path = "path/to/video"

cap = cv2.VideoCapture(video_path)

Save Video

Loop through the video frames

while cap.isOpened():

Read a frame from the video

success, frame = cap.read()

if success:
    # Run YOLOv8 inference on the frame
    results = model(frame)

    # Visualize the results on the frame
    annotated_frame = results[0].plot()

    # Display the annotated frame
    cv2.imshow("YOLOv8 Inference", annotated_frame)

    # Break the loop if 'q' is pressed
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break
else:
    # Break the loop if the end of the video is reached
    break
glenn-jocher commented 11 months ago

@dronespov to save the video with the YOLOv8 predictions, you can add the following code:

  1. Create a VideoWriter object before the loop:

    output_path = 'path/to/output_video.mp4'
    video_writer = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'mp4v'), int(cap.get(5)), (int(cap.get(3)), int(cap.get(4))))
  2. Inside the loop, after visualizing the results on the frame, write the annotated frame to the VideoWriter object:

    video_writer.write(annotated_frame)
  3. After the loop ends, release the VideoWriter object and close the video capture:

    video_writer.release()
    cap.release()

This code will save the annotated video with YOLOv8 predictions to the specified output path in the mp4 format. Make sure to replace 'path/to/output_video.mp4' with your desired output path.

Let me know if you have any further questions!

dronespov commented 11 months ago

@glenn-jocher thank you, that was very helpful and worked!

Where can I find an instruction page for

glenn-jocher commented 11 months ago

@dronespov hi Andrew,

I'm glad to hear that the previous solution worked for you!

Regarding your new questions:

  1. To control the playback speed while viewing a video using cv2.VideoCapture, you can use the cv2.waitKey(delay) function inside your loop. By adjusting the delay parameter, you can control the speed at which frames are displayed. Higher values for delay will slow down the playback speed, while lower values will speed it up.

  2. If you want to process the predicted video without displaying it, you can simply remove the line cv2.imshow("YOLOv8 Inference", annotated_frame) from your code. This will prevent the annotated frame from being displayed.

  3. To change the font size of the annotations on images and videos, you need to modify the visualization settings in the YOLO.plot() method. Inside the YOLO.plot() method, you can specify the font_size parameter to adjust the size of the annotations. Please note that the font_size value is in pixels.

  4. If you want to save the predicted videos with different names, you can modify the output path before creating the VideoWriter object. You can loop over the desired names and concatenate them to the output path string, for example: output_path = 'path/to/output_video_' + str(i) + '.mp4', where i is the index of your loop.

I hope this helps! Let me know if you have any further questions or need more clarification.

Best regards, Glenn Jocher

dronespov commented 11 months ago

@glenn-jocher Thank you very much! Do you know if there's a script for a trained model to scan all images in a directory, detect, annotate, and store the outputs in a in a new directory?

glenn-jocher commented 11 months ago

@dronespov sure! In YOLOv8, you can write a script to scan all the images in a directory, perform object detection using a trained model, annotate the detected objects, and store the annotated images in a new directory.

Here's a general outline of the steps you can follow to achieve this:

  1. Retrieve the list of image files in the input directory.
  2. Load the trained YOLOv8 model.
  3. Iterate over each image file: a. Read the image file. b. Run the YOLOv8 inference on the image to detect objects. c. Annotate the detected objects on the image. d. Save the annotated image to the output directory.
  4. Once all the images have been processed, the annotated images will be stored in the specified output directory.

By following this approach, you can easily process multiple images, detect objects, annotate them, and save the annotated images for further analysis or usage.

I hope this explanation helps! Let me know if you have any further questions.

dronespov commented 11 months ago

@glenn-jocher youre a rockstar, thanks! Do you know if segment anything is compatible with yolov8?

Sti11ness commented 11 months ago

Good day!I need help with one question..I want to save my yolov8n detection results.Im using results = model.predict(source=img, project=, name=,save = True), it saving a picture without bboxes and classes,so as it was before , how can I save an image with detection and classification results?

glenn-jocher commented 11 months ago

@dronespov hi there!

To save the YOLOv8 detection and classification results with bounding boxes and class labels, you can use the results[0].render() method. This method will apply the annotations and return an annotated image with the bounding boxes and class labels. You can then save this annotated image using standard image-saving functions or libraries in Python.

Using results = model.predict(source=img, project=**, name=**, save=True) saves the image without bounding boxes and class labels because it saves the original image with the same name and under the specified project. To obtain the annotated image, you need to apply the annotations using results[0].render() and save the resulting image separately.

Let me know if you have any further questions or need additional clarification!

Best regards, Glenn Jocher

tahmidrashid commented 10 months ago

Hi @glenn-jocher

You are surely a godsend! Your solution saved me a lot of trouble getting the video to be stored from YOLOv8 detections.

My only issue is that my saved videos are "fast-forwarded" whenever I play them (i.e., they run several times faster than they should). Any thoughts on how to fix it? Here is my current code:

import cv2
from ultralytics import YOLO

gstreamer_pipeline="nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1920, height=1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=2  ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink" 

cap = cv2.VideoCapture(gstreamer_pipeline, cv2.CAP_GSTREAMER) #Using live camera 

output_path = 'path/to/output_video.mp4'
record = cv2.VideoWriter(output_path , cv2.VideoWriter_fourcc(*'x264'), 60, (1920,1080))

def runInfer():
    model = YOLO('yolov8n.pt')

    while cap.isOpened():
        # Read a frame from the video
        success, frame = cap.read()

        if success:
            # Run YOLOv8 inference on the frame
            results = model.predict(frame, verbose=False)

            # Visualize the results on the frame
            annotated_frame = results[0].plot()

            # Display the annotated frame
            cv2.imshow("YOLOv8 Inference", annotated_frame)

            #save the frame
            record.write(annotated_frame)

            # Break the loop if 'q' is pressed
            if cv2.waitKey(1) & 0xFF == ord("q"):
                break
        else:
            # Break the loop if the end of the video is reached
            break

    # Release the video capture object and close the display window
    cap.release()
    record.release() #Stop Recording Video if saveVid is True
    cv2.destroyAllWindows()
vitorStein commented 10 months ago

My only issue is that my saved videos are "fast-forwarded" whenever I play them (i.e., they run several times faster than they should). Any thoughts on how to fix it? Here is my current code:

Hi @tahmidrashid, in your code, you're specifying a frame rate of 60FPS for the output video

record = cv2.VideoWriter(output_path , cv2.VideoWriter_fourcc(*'x264'), 60, (1920,1080))

However, you're capturing frames from the camera using the gstreamer pipeline, which specifies a frame rate of 30FPS.

Try the following code:

fps = cap.get(cv2.CAP_PROP_FPS)

output_path = 'path/to/output_video.mp4'
record = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'x264'), fps, (1920, 1080))
dronespov commented 10 months ago

Hi @glenn-jocher do you know if there's a way to run a model then capture a screenshot of only the object that's detected and everything not detected removed

so

perform object detection on the input image -> draw bounding boxes and labels or segmentation (preferably) around the detected objects -> save the output image with bounding boxes and labels as a jpg, svg, or png (which ever is easier) -> save a screenshot of each detected object (could be multiple files for multiple detections)

glenn-jocher commented 10 months ago

Hi @vitorStein,

Certainly, you can accomplish this with YOLOv8. The basic idea for your task would be:

  1. Perform object detection on the input image. This can be done by using the predict() function of your YOLO model.

  2. Draw bounding boxes and labels or apply segmentation on the objects detected. After obtaining the detection results from the predict() function, you can use the plot() method to generate an image with bounding boxes and labels. If you want to apply segmentation, you would need to implement the segmentation logic manually, as YOLO is primarily a detector and doesn't support segmentation out of the box.

  3. Save the output image with bounding boxes and labels. You can save the resulting image from the plot() method using standard image I/O operations.

  4. Save a screenshot of each detected object. You would need to extract the bounding box coordinates for each detected object from the output of the predict() function. You can then use these coordinates to crop the original image around each detected object.

Please note that this would require some additional programming to implement, as the predict function by default doesn't save individual crops of detected objects. Of course, the level of complexity might depend on your proficiency with Python and the specific details of your task.

I hope that gives you a clear idea! Let me know if you have further questions.

Best regards, Glenn Jocher

20481a0534 commented 6 months ago

Hello @glenn-jocher , I have a input as Video. So how can i save only full detected image in video without cropping. please help me to solve this issue !yolo task=detect mode=predict model=/content/test/best.pt conf=0.50 source=/content/test/test.mp4 save_crop=True this line saves only croped images of detected part if i replace save=True then it saves whole video which is detected and not detected. Or else is there possibility to save video only detected part.

ghost commented 6 months ago

Hello @glenn-jocher , I have a input as Video. So how can i save only full detected image in video without cropping. please help me to solve this issue !yolo task=detect mode=predict model=/content/test/best.pt conf=0.50 source=/content/test/test.mp4 save_crop=True this line saves only croped images of detected part if i replace save=True then it saves whole video which is detected and not detected. Or else is there possibility to save video only detected part.

glenn-jocher commented 6 months ago

@Prem-Buraga hello,

To save the full frames of the video where detections are made, without cropping, you can use the save=True flag in the command line:

!yolo task=detect mode=predict model=/content/test/best.pt conf=0.50 source=/content/test/test.mp4 save=True

This will save one frame per detection event across all the detections in that frame. It is essentially saving the entire frame any time there's a detection without cropping to just the detected object.

If your intention is to save video clips where only detected frames are included (and omit frames without detections), that would require custom scripting. The default command line interface does not offer this functionality. You would need to write a Python script that loads your model using the Ultralytics YOLO package, processes the video frame-by-frame, checks if there are any detections, and conditionally writes frames to an output video file only when detections occur.

Lastly, saving the entire video but only including detected parts would also be considered a form of video editing, which would require you to loop through frames, detect objects, and then only output a video clip to a file when a detection happens. This is not a default feature and would again require a custom script.

Hope this helps clarify your options. If you require further assistance, consider reviewing additional documentation or seeking out community examples where similar tasks have been accomplished.

dronespov commented 5 months ago

@dronespov sure! In YOLOv8, you can write a script to scan all the images in a directory, perform object detection using a trained model, annotate the detected objects, and store the annotated images in a new directory.

Here's a general outline of the steps you can follow to achieve this:

  1. Retrieve the list of image files in the input directory.
  2. Load the trained YOLOv8 model.
  3. Iterate over each image file: a. Read the image file. b. Run the YOLOv8 inference on the image to detect objects. c. Annotate the detected objects on the image. d. Save the annotated image to the output directory.
  4. Once all the images have been processed, the annotated images will be stored in the specified output directory.

By following this approach, you can easily process multiple images, detect objects, annotate them, and save the annotated images for further analysis or usage.

I hope this explanation helps! Let me know if you have any further questions.

Hi @glenn-jocher

By any chance do you have a script that you can share with me to achieve this along with any links to scripts that perform custom tasks like this. Thanks!

glenn-jocher commented 5 months ago

@dronespov hi Andrew,

I'm glad to hear you're looking to utilize YOLOv8 for detecting objects in a directory of images! While I don't have a bespoke script to share, you can achieve this by writing a simple Python script using the YOLOv8 model interface.

In this script, you'd:

  1. Utilize standard Python libraries to list your image files.
  2. Load the YOLOv8 model using the YOLO class from the Ultralytics package.
  3. Loop through your images, perform detection with the predict() method, and render the results using results[0].render().
  4. Save these annotated images using your preferred Python imaging library, such as PIL or OpenCV.

For guidance on writing this script, you can refer to our documentation at docs.ultralytics.com, which provides detailed explanations on using the different modes and functionalities of YOLOv8, including predictions and annotations.

Best of luck with your detection tasks, and feel free to reach out if you have further questions!

dronespov commented 5 months ago

@dronespov hi Andrew,

I'm glad to hear you're looking to utilize YOLOv8 for detecting objects in a directory of images! While I don't have a bespoke script to share, you can achieve this by writing a simple Python script using the YOLOv8 model interface.

In this script, you'd:

  1. Utilize standard Python libraries to list your image files.
  2. Load the YOLOv8 model using the YOLO class from the Ultralytics package.
  3. Loop through your images, perform detection with the predict() method, and render the results using results[0].render().
  4. Save these annotated images using your preferred Python imaging library, such as PIL or OpenCV.

For guidance on writing this script, you can refer to our documentation at docs.ultralytics.com, which provides detailed explanations on using the different modes and functionalities of YOLOv8, including predictions and annotations.

Best of luck with your detection tasks, and feel free to reach out if you have further questions!

Hi @glenn-jocher thanks for your help, I was able to create a script that uses my weight to scan images in a directory for specific features then segmented the detections.

Now trying to use the detected and segmented images as a dataset to further fine-tune my model by converting the masks to polygons. Do you know if there's a way to convert detected segmented images into polygons so it they can be used as labels? This is the script I use when converting cvat.ai segmented masks to polygons.

import os

import cv2

input_dir = 'path/to/masks'
output_dir = '/path/to/output'

for j in os.listdir(input_dir):
    image_path = os.path.join(input_dir, j)
    # load the binary mask and get its contours

    # Skip non-image files
    if not j.lower().endswith(('.jpg', '.jpeg', '.png')):
        print(f"Skipping non-image file: {image_path}")
        continue

    mask = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
    # Check if the image was successfully loaded

    if mask is None:
        print(f"Error reading image: {image_path}")
        continue
    _, mask = cv2.threshold(mask, 1, 255, cv2.THRESH_BINARY)

    H, W = mask.shape
    contours, hierarchy = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    # convert the contours to polygons
    polygons = []
    for cnt in contours:
        if cv2.contourArea(cnt) > 200:
            polygon = []
            for point in cnt:
                x, y = point[0]
                polygon.append(x / W)
                polygon.append(y / H)
            polygons.append(polygon)

    # print the polygons
    with open('{}.txt'.format(os.path.join(output_dir, j)[:-4]), 'w') as f:
        for polygon in polygons:
            for p_, p in enumerate(polygon):
                if p_ == len(polygon) - 1:
                    f.write('{}\n'.format(p))
                elif p_ == 0:
                    f.write('0 {} '.format(p))
                else:
                    f.write('{} '.format(p))

        f.close()
else:
        print("No contours found in {image_path}")
glenn-jocher commented 5 months ago

@dronespov hi Andrew,

Great to hear that your script is working for the initial segmentation. For converting detected segmentations into polygon labels, you can still use OpenCV functions like findContours and approxPolyDP to approximate contours as polygons.

Your existing code is mostly applicable; you just need to ensure that as you retrieve segmentation maps from YOLOv8 detections, they are in the correct binary mask format expected by OpenCV. The detected segmentations often come as binary masks if you're performing instance segmentation.

Once you have the binary masks, process them with OpenCV to get the contours and then approximate these contours as polygons. The resulting polygons can be normalized and stored as you're doing in your existing script. Be sure to use a consistent format for your labels, fitting the requirements of the model you're fine-tuning.

Your understanding of the process appears solid, so just adapt it as needed for the YOLOv8 segmented images. For more information on how to integrate this functionality, please refer to our documentation.

Keep up the good work, and don't hesitate to reach out if you encounter any stumbling blocks!

dronespov commented 5 months ago

Thanks @glenn-jocher !

I modified the script to the below(1). It works but most of the txt files seem a bit light. Most of the txt are 1 line of points compared to other txt where there's 25+ lines of points.

The other complication is some images don't have detection so on a 1000+ file dataset, separating the detected vs undetected takes some time lol. Im working on a a script that checks a directory for the same file names with different extensions then copy's them into separate directories (2).

Interestingly my Mac with m2 processor & 16 gb of ram ran out of memory (Process finished with exit code 137 (interrupted by signal 9: SIGKILL)) so I separated the dataset into 3 separate parts/training sessions. Also used device='mps'.

1


import os
import cv2

def convert_masks_to_yolo_format(input_dir, output_dir):
    os.makedirs(output_dir, exist_ok=True)

    for filename in os.listdir(input_dir):
        if filename.lower().endswith(('.jpg', '.jpeg', '.png')):
            image_path = os.path.join(input_dir, filename)

            # load the binary mask and get its contours
            mask = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)

            # Skip if the image was not successfully loaded
            if mask is None:
                print(f"Error reading image: {image_path}")
                continue

            _, binary_mask = cv2.threshold(mask, 1, 255, cv2.THRESH_BINARY)

            H, W = binary_mask.shape
            contours, _ = cv2.findContours(binary_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

            # convert the contours to polygons
            polygons = []
            for cnt in contours:
                if cv2.contourArea(cnt) > 200:
                    polygon = []
                    for point in cnt:
                        x, y = point[0]
                        polygon.append(x / W)
                        polygon.append(y / H)
                    polygons.append(polygon)

            # print the polygons
            output_file_path = os.path.join(output_dir, f'{os.path.splitext(filename)[0]}.txt')
            with open(output_file_path, 'w') as f:
                for polygon in polygons:
                    for p_, p in enumerate(polygon):
                        if p_ == len(polygon) - 1:
                            f.write('{}\n'.format(p))
                        elif p_ == 0:
                            f.write('0 {} '.format(p))
                        else:
                            f.write('{} '.format(p))

            print(f"Processed {filename}, saved YOLO format to {output_file_path}")

        else:
            print(f"Skipping non-image file: {filename}")
            # Example usage
input_directory = '/path/to/directory'  # Replace with the path to your labeled masks
output_directory = '/path/to/directory'  # Replace with the desired output path
convert_masks_to_yolo_format(input_directory, output_directory)

2


import os

def copy_matching_files(source_dir1, source_dir2, destination_dir):
    os.makedirs(destination_dir, exist_ok=True)

    # Get the list of files in both directories
    files_dir1 = set(f for f in os.listdir(source_dir1))
    files_dir2 = set(f for f in os.listdir(source_dir2))

    # Find common files by name (ignoring extension)
    common_files = files_dir1.intersection(files_dir2)

    # Copy common files to the destination directory
    for file_name in common_files:
        source_path1 = os.path.join(source_dir1, file_name)
        source_path2 = os.path.join(source_dir2, file_name)
        destination_path = os.path.join(destination_dir, file_name)

        # Check if the files have different extensions
        ext1 = os.path.splitext(source_path1)[-1]
        ext2 = os.path.splitext(source_path2)[-1]

        if ext1 != ext2:
            print(f"Skipping {file_name}, different file formats")
            continue

        # Copy files with the same name to the destination directory
        with open(source_path1, 'rb') as src_file, open(destination_path, 'wb') as dest_file:
            dest_file.write(src_file.read())

        print(f"Copied {file_name} to {destination_path}")

source_directory1 = '/path/directory'
source_directory2 = '/path/directory'
destination_directory = '/path/directory'

copy_matching_files(source_directory1, source_directory2, destination_directory)
glenn-jocher commented 5 months ago

@dronespov Hi Andrew,

For the light .txt files with only one line of points, this typically indicates that few contours passed the cv2.contourArea threshold. You could lower this threshold to capture smaller detections, or investigate if the segmentation masks are as expected.

Regarding images without detections, automating the separation process with a script is indeed efficient. Your approach to match file names across directories is sound.

Memory issues can arise with large datasets or high-resolution images. Dividing the dataset and using device='mps' for Apple Silicon compatibility is a smart move. For long-running jobs, ensure you're not accumulating unnecessary data in memory, and consider batch processing with proper memory management.

Good luck with the continued development! If you have any more questions or need further assistance, feel free to ask.

dronespov commented 5 months ago

@glenn-jocher I appreciate the assurance! To visually validate the segmented masks are as expected, im working on a script that covers all areas other than the segmented masks into black while keeping segmented masks red. This is a bit tricky so im researching best approaches and see cvat.ai has good info

https://github.com/opencv/cvat/blob/588df39ebf8ff519618aa0548328e8d2963938f4/cvat/apps/dataset_manager/formats/mask.py#L23