Comments (4)
π Hello @dhouib-akram, thank you for your interest in Ultralytics YOLOv8 π! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
If this is a π Bug Report, please provide a minimum reproducible example to help us debug it.
If this is a custom training β Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Join the vibrant Ultralytics Discord π§ community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
from ultralytics.
Hi @dhouib-akram,
Thank you for reaching out and providing a detailed description of your issue along with the code snippets. It's great to see your effort in hosting the YOLOv8-segmentation model on a Triton server and working through the post-processing steps.
To address your concern about the low-resolution masks, there are a few key points and suggestions to consider:
-
Ensure Latest Versions: First, please make sure you are using the latest versions of
torch
andultralytics
. You can update them using:pip install --upgrade torch ultralytics
-
Model Export and NMS: When exporting the model to ONNX and subsequently to TensorRT, ensure that the Non-Maximum Suppression (NMS) layer is correctly integrated. If the NMS is not properly handled, it might affect the quality of the masks.
-
Resolution Handling: The low-resolution issue might be due to the resizing and reshaping operations. Ensure that the mask resolution is consistent throughout the process. Hereβs a refined approach to handle the mask resolution:
def get_mask(row, box, img_w, img_h): mask = row.reshape(160, 160) mask = sigmoid(mask) mask = (mask > 0.5).astype('uint8') * 255 # Calculate the bounding box coordinates in the mask's scale mask_x1 = round(box.x1 / img_w * 160) mask_y1 = round(box.y1 / img_h * 160) mask_x2 = round(box.x2 / img_w * 160) mask_y2 = round(box.y2 / img_h * 160) # Crop the mask to the bounding box mask = mask[mask_y1:mask_y2, mask_x1:mask_x2] # Resize mask directly to the bounding box size desired_width = round(box.x2 - box.x1) desired_height = round(box.y2 - box.y1) mask_resized = cv2.resize(mask, (desired_width, desired_height), interpolation=cv2.INTER_LINEAR) return mask_resized
-
Post-Processing Pipeline: Ensure that the post-processing pipeline maintains the resolution integrity. Hereβs a refined version of your
postprocess
function:def postprocess(det_boxes, det_scores, det_classes, img_w, img_h, input_shape, masks): detected_objects = [] polygons = [] # Extracting box coordinates and converting to (x1, y1, x2, y2) format x, y, w, h = det_boxes[:, 0], det_boxes[:, 1], det_boxes[:, 2], det_boxes[:, 3] x1, y1, x2, y2 = (x - 0.5 * w), (y - 0.5 * h), (x + 0.5 * w), (y + 0.5 * h) boxes = np.stack([x1, y1, x2, y2], axis=-1) # Calculate the scale factors for width and height width_scale = img_w / input_shape[0] height_scale = img_h / input_shape[1] # Apply scale factors to adjust the bounding box coordinates boxes = boxes * np.array([width_scale, height_scale, width_scale, height_scale], dtype=np.float32) # Extract scores and classes scores = det_scores classes = det_classes for box, score, label, mask in zip(boxes, scores, classes, masks): # Ensure that box coordinates are within the image boundaries box = np.clip(box, 0, [img_w, img_h, img_w, img_h]) box = BoundingBox(label, score, box[0], box[2], box[1], box[3], img_w, img_h) detected_objects.append(box) mask = get_mask(mask, box, img_w, img_h) polygons.append(get_polygon(mask)) return detected_objects, polygons
-
Comparison with Ultralytics Predict: If the predefined
predict
function from Ultralytics provides high-resolution masks, it might be beneficial to compare the internal steps of thepredict
function with your custom implementation. Ensure that the preprocessing and postprocessing steps align closely.
For further details on the AutoBackend
class and dynamic backend selection, you can refer to the Ultralytics documentation.
If the issue persists, please provide a minimum reproducible example so we can investigate further. You can follow the guidelines here: Minimum Reproducible Example.
Feel free to reach out if you have any more questions or need further assistance! π
from ultralytics.
Related Issues (20)
- YOLOv8 Parameter Depth_multiple, Width_multiple, and max_channel HOT 3
- Trying to display it on my laptop's camera HOT 13
- Accelerating valiation speed. HOT 6
- how can i use intel realsense sr305 with yolov10 HOT 11
- YOLO reduce original video's number of frame when inferring HOT 4
- Issue on fine-tuning yolov10 on custom dataset HOT 1
- Usage of seed in retraining model HOT 10
- Problem while Fine-Tuning YoloV8 model HOT 2
- Confidence threshold HOT 4
- While using list.streams detection is not getting performed in all the frames HOT 17
- convert yolov8n hand pose to int8 tflite face value error HOT 8
- intel realsense sr305 with yolov10 use HOT 7
- Detect module is running twice HOT 4
- Joint angle detection HOT 9
- Model interpretability or showing most valuable features HOT 3
- Image URLs without file extension lead to 500 error & server crash HOT 5
- non_max_suppression slow HOT 3
- Why does training accuracy suddently decrease? HOT 7
- how to validate my model on different MAP values ? for ex: at 0.7 , 0.9 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.