diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation_test_coverage.yml similarity index 93% rename from .github/workflows/documentation.yml rename to .github/workflows/documentation_test_coverage.yml index f23c20c09..b72303132 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation_test_coverage.yml @@ -1,4 +1,4 @@ -name: Deploy Documentation to GitHub Pages +name: Deploy Documentation and Test Coverage to GitHub Pages on: push: @@ -45,7 +45,6 @@ jobs: - name: Generate Documentation run: | - python3 ./yolo_models/scripts/copy_readme.py cd doxyfiles doxygen Doxyfile diff --git a/README.md b/README.md index f7553a8bb..ba80829bd 100644 --- a/README.md +++ b/README.md @@ -106,12 +106,15 @@ By doing so, we achieved significantly higher inference performance using the Je Tested on: **Jetson Nano 4GB**, Ubuntu 20.04, JetPack 4.x, CUDA, cuDNN, TensorRT. -## Test Coverage Report +## Documentation -To see our test coverage report click here: [Coverage Report](https://seame-pt.github.io/ObjectDetectionAvoidance/coverage/index.html). +To see more documentation on: + - PID control, go to [this file](pid_control/README.md). -## Documentation + - Microservices, go to [this file](services_raspberryPi/README.md). -To see more Documentation on the PID control go to [this file](pid_control/README.md). +For a more structured documentation, visit the [Doxygen documentation](https://seame-pt.github.io/ObjectDetectionAvoidance/). -To see a more structured Documentation go to [Doxygen](https://seame-pt.github.io/ObjectDetectionAvoidance/). \ No newline at end of file +## Test Coverage Report + +To see our test coverage report click here: [Coverage Report](https://seame-pt.github.io/ObjectDetectionAvoidance/coverage/index.html). diff --git a/doxyfiles/Doxyfile b/doxyfiles/Doxyfile index de91d73f1..98d17e9ec 100644 --- a/doxyfiles/Doxyfile +++ b/doxyfiles/Doxyfile @@ -1120,7 +1120,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = doxyfile_readme.md +USE_MDFILE_AS_MAINPAGE = ../README.md # The Fortran standard specifies that for fixed formatted Fortran code all # characters from position 72 are to be considered as comment. A common diff --git a/doxyfiles/doxyfile.css b/doxyfiles/doxyfile.css index 5d318c400..ed864ebc5 100644 --- a/doxyfiles/doxyfile.css +++ b/doxyfiles/doxyfile.css @@ -6,3 +6,11 @@ body { font-family: Arial, sans-serif; font-size: 20px; } + +img { + max-width: 100%; /* ensures images never overflow container */ + height: auto; /* keeps aspect ratio */ + display: block; /* optional: removes inline gaps */ + margin: 10px auto; /* centers the image with margins */ +} + diff --git a/doxyfiles/doxyfile_readme.md b/doxyfiles/doxyfile_readme.md deleted file mode 100644 index fa0ce9097..000000000 --- a/doxyfiles/doxyfile_readme.md +++ /dev/null @@ -1,47 +0,0 @@ -## Project Architecture - -This project aims to retrain Yolo for **Lane, Drivable Area and Road Object detection** as well. - -You can find our **best models** in [this folder](models/). You can also download our model and dataset here: [Link to Google Drive](https://drive.google.com/drive/folders/1RwFmYyjxCafdnUORBcm2kgo62itcLmcS?usp=drive_link). In there you have our full dataset, and separate folders with some of the images we used. - -\image html ADR/Fluxograma.jpg "Project Structure" width=60% - -## Inference Result - -\image html models/seame_training/val_batch1_pred.jpg "Results" width=50% - -## Datasets - -For lane and drivable area detection, we took some images of our lab and also used the bdd10k dataset. For the objects, we downloaded some datasets from Roboflow. - -I noticed a decay of object detection outside the objects of my dataset, despite the fact that i froze the backbone and lowered the learning rate. So you might need to add some object images to preserve more information. - -### Roboflow - -To create the masks of our lab images, we used Roboflow to generate the annotations, then we added blur, noise and grayscale to the images and resized them to 320x320, keeping aspect ratio. After this, we downloaded to **COCO segmentation** format. This creates a Json file with all the annotations. So, in *scripts/json_txt.py* we convert these annotations, that have the polygons of the lanes into binary masks, so we can then convert them back to normalized polygons and save them to a txt file. We tried to convert the COCO polygons directly to yolo-seg txt format but we noticed some weird values and loss of information. Therefore, converting first to binary masks helped preserve the lane shape. - -We downloaded a few Roboflow datasets of road objects, such as the **traffic lights, the stop, speed, danger and cross walk signs**. We then used *scripts/remap_polygons.py* to reorder the labels to match our project and *scripts/bbox_seg.py* to transform them into segmentation labels, since this is a segmentation model. - -## Creating Annotations - -In the scripts directory file *create_annotations.py* we create the **annotation labels** for lane and object detection. How do we do this? We pass our images through a pre-trained **Yolo11-seg model**, to get the object polygons. Then, we use **supervision** tools to convert the lane **binary masks** to valid Yolo **polygons**. Finaly, we **merge** the object and lane annotations and get the label files. - -Be attentive towards the size of the images and masks, we decided to keep the images square, (training and testing), for compatibility. In the scripts directory, file *resize.py* you can resize images with **letterboxing** (keeping **aspect ratio**), or not. - -In these scripts, you might need to change some function **parameters**, the original size of the images, and the **paths** to the images, so that it correctly links to your dataset and original size of your images. - -For debugging, you can **visualize the annotations** in *scripts/visual_annotations.py*. - -## Training and Testing - -In *training.py* (scripts directory) where we are retraining our model, we set the augmentations to None since it disrupts our images, and add other augmentations that dont disrupt them, such as brightness, saturation and hue. After the first training where we freeze the backbone, you train again to unfreeze everything. - -For testing, (in *scripts/testing.py*), we call our trained model and set it to **predict**, to test the prediction of a given validation image. - -For debugging we added *scripts/count_labels.py* that outputs how many annotations we have for each class id. - -## Jetson Nano - -In Jetson, we have an ultralytics Yolo **container**, specific for compatibility with Jetson Nano. This container only runs a yolo model above or equal to version 8. In here we will run our Yolo with lane detection. - -We have a self-hosted jetson runner, so that everytime I push the code to github, it will deploy my models to jetson, this code is in *.github/deploy_jetson.yml*. diff --git a/services_raspberryPi/README.MD b/services_raspberryPi/README.md similarity index 100% rename from services_raspberryPi/README.MD rename to services_raspberryPi/README.md diff --git a/yolo_models/scripts/copy_readme.py b/yolo_models/scripts/copy_readme.py deleted file mode 100644 index 7acda8add..000000000 --- a/yolo_models/scripts/copy_readme.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys - -def copy_markdown_lines(source_file, target_file, start_line=15): - try: - # Read source file - with open(source_file, 'r', encoding='utf-8') as src: - source_lines = src.readlines() - - # Check if source file has enough lines - if len(source_lines) < start_line: - print(f"Error: Source file '{source_file}' has fewer than {start_line} lines.") - sys.exit(1) - - with open(target_file, 'r', encoding='utf-8') as dst: - dest_lines = dst.readlines() - - content_to_copy = dest_lines[:start_line] + source_lines[start_line + 1:-5] - - # Write to target file - with open(target_file, 'w', encoding='utf-8') as tgt: - tgt.writelines(content_to_copy) - - print(f"Successfully copied content from '{source_file}' (line {start_line} onward) to '{target_file}'.") - - except FileNotFoundError as e: - print(f"Error: File not found - {e}") - sys.exit(1) - except Exception as e: - print(f"Error: {e}") - sys.exit(1) - -if __name__ == "__main__": - source_file = "./README.md" # Path to the source file - target_file = "./doxyfiles/doxyfile_readme.md" # Path to the target file - copy_markdown_lines(source_file, target_file) \ No newline at end of file diff --git a/yolo_models/scripts/tests/test_bbox_seg.py b/yolo_models/scripts/tests/test_bbox_seg.py index 2f925172a..faf6541c9 100644 --- a/yolo_models/scripts/tests/test_bbox_seg.py +++ b/yolo_models/scripts/tests/test_bbox_seg.py @@ -32,3 +32,4 @@ def test_convert_bbox_to_segmentation(tmp_path): # Check that all coords are in range [0.0, 1.0] coords = list(map(float, parts[1:])) assert all(0.0 <= c <= 1.0 for c in coords), "Coords not in [0.0, 1.0]" + diff --git a/yolov8n-seg.pt b/yolov8n-seg.pt deleted file mode 100644 index e928b4610..000000000 Binary files a/yolov8n-seg.pt and /dev/null differ