So here is my first question here. I am preparing a dataset for object detection. I have done the following things so far:
I have an original picture (size w4000 x h3000).
I used the annotation platform Roboflow to annotate it in COCO format, with close to 250 objects in the picture.
Roboflow returned a downscaled picture (2048x1536) with a respective json file with the annotations in COCO format.
Then, to obtain a dataset from my original picture (as I have a lot of objects and the picture is big enough), I decided to tile the original picture in patches of 224x224. For this purpose, I upscaled a bit (4032x3136) to be able to slice it properly, obtaining 252 pictures.
QUESTIONS
How can I resize the bounding boxes of the Roboflow 2048x1536 picture to my original picture (4032x3136)?
Once the b.boxes are resized to my original size picture, how can I resize them again, adapting the size to each of my patches (224x224) created by slicing the original picture?
Thank you!!
It sounds like the ultimate goal is to have tiled 224x224 images from the source 4032x3136 images with bounding boxes correctly updated.
In Roboflow, at least, you can add tiling as a preprocessing step to your original 4032x3136 images. The images will be broken into the number of tiles you select (2x2, 3x3, NxY). The bounding boxes will be correctly updated to cover the objects across each individual tile as well.
To reimplement in code from what you've described, you would need to:
Upscale your 2048x1536 images to 4032x3136
Scale the bounding boxes accordingly
Break the images into 224x224 tiles using something like Pil
Update the annotations to be broken into the coordinates on the respective tiles; one annotation per tile
Related
I want to crop images which is already annotated for yolov5 format ".txt", but the coordinates will change on cropped so how can i update it and the image crop coordinate will also be one of the class in annotation .txt file. For example: there is two model i want to train first will just detect odometer and second will detect the digits in it so for second model first model will crop odometer image and send to second, therefore for training the second model i need this coordinates corrected. Because I already have full annotation ready and don't want to redo annotation on cropped images of like more than 2k images
As I have mentioned in the comments, I think I can write that as an answer as well.
You can crop your images from yolov5 with --save-crop flag of yolov5. And then for the annotations, you can actually give out full image size as the bounding box sizes. I suggest you check out this thread as well.
Problem statement
I am working on a project using YOLO model to detect tools form given picture.i.e hammer, screwdrivers, bolt etc. I have only 100 pictures as training dataset and I have labelled them using polygons. I have decided to augment the data with the below given code. I’ve got 500 new images but, the problem is that I don't want to label them again. I am looking for any way out with which label bounding boxes (polygons) adjust (preserved) with news augmented images so that I can get polygons data without doing labelling again. In short, I want to preserver the label during the image augmentation process.
Code used for Augmentation
Brightness=[0.7,0.8,1] # Different brightness Levels
Rotation=[10,-10] # Different rotation Levels
# Main link source
main_path=r"./Augmentation"
# Directoy from main path
dir=os.listdir(main_path)[1:]
# Read and iterate all images from directory
for name in dir:
image = Image.open(os.path.join(main_path,name))
# Apply rotation from image
for j in Rotation: # Different rotation Levels
rotated = image.rotate(j)
ransImageRGBA = rotated.convert("RGB")
apply_br = ImageEnhance.Brightness(ransImageRGBA)
# Apply values for brightness in rotated images
for i in Brightness: # Different rotation Levels
Lightness =apply_br.enhance(i)
# below line for output
Lightness = apply_br.enhance(i).save((os.path.join(main_path, 'augmented_Images',str(i)+str(j))+name))
print('image has been augmented successfully')
look into imaug. The augmentations from this module also augment the labels. One more thing, what you are doing right now is offline augmentation. You might want to look at online augmentation. Then every epoch the pictures are augmented in a different way and you only train on the augmented pictures. This way you don't have to have a lot of discspace.
If you are using Yolov4 with darknet, image augmentation is performed automatically.
I have a large images 5000x3500 and I want to divide it into small images 512x512 but without loosing the original image coordinates. The large images are annotated/labled that's why I want to keep the original coordinates and I will use the small images to train YOLO model. I am not sure if that called tiled or not. but is there any suggestion to do it using python or opencv-python?
I'm trying to create custom dataset using my own images. This images I cropped from logs data such as below:
https://drive.google.com/open?id=1x0oWiVZ9KOw5P0gIMxQNxO-ajdrGy7Te
I want it to be able to detect the high vibration such as below:
https://drive.google.com/open?id=1tUjthjGG1c23kTCQZOgedcsx99R_a_z3
I have around 300 image of the High Vibration in one folder. the picture is like below:
https://drive.google.com/open?id=1IG_-wRJxe-_TOYfSxHjRq5UBWMn9mO1k
I wanted to do exactly like https://towardsdatascience.com/how-to-train-your-own-object-detector-with-tensorflows-object-detector-api-bec72ecfe1d9. IN this example image dataset was hand-labeled manually with LabelImg.
However I don't see why I need to draw box for images that only have one object in it and can have the frame of the image as the bounding box.
Please advice how I can create data set and processing the images without manually drawing the bounding box (since the images consist of one object), and how to draw bounding boxes in batch for image that contain one object(i.e. having the frame of the image as the bounding box)?
It sounds like you want to do 'image classification' as opposed to 'object detection' -- it may be easier to make a script that generates xml files, containing the image's width and height as bounding box dimensions, as opposed to using labelImg.
I am working with a stack of noisy images, trying to isolate a blob in an image section. Below you can see the starting image, loaded and plotted with python, and the same image after some editing with Gimp.
What I want to do is to isolate and recognise the blob inside the light blue circle, editing the image and then using something like ndimage.label. Do you have any suggestion on how to edit the image? Thanks.
The background looks quite even so you should be able to isolate the main object using thresholding, allowing you to use array masking to identify regions within the main object. I would have a go with some tools from scikit image to see where that gets you http://scikit-image.org/docs/dev/auto_examples/
I would try gaussian/median filtering followed by thresholding/filling gaps. Or you could try random walker segmentation, or pherhaps texture classification might be more useful. When you have a list of smaller objects within the main object you can then filter these with respect to shape, size, roundness etc
http://scikit-image.org/docs/dev/auto_examples/plot_label.html#example-plot-label-py