Comments (6)
Can you elaborate on what "deploy it" means? Have you used our examples to Export YoloNAS to ONNX
and YoloNAS_Inference_using_TensorRT or did you write some your own code for this?
Based on previous similar issues, usually it's the error on the user side (E.g missing image normalization, wrong size preprocessing etc) that affects the model accuracy. On our end we have integration tests that verify exported ONNX model provides the same results as regular pytorch model.
from super-gradients.
You should be using same or nearly same image resolution during training/validation & inference. These images looks really different in size. Without seeing the full code you are using for export and inference it is impossible for me to help you.
Here is what can help to understand what is going on
- Export code
- Result of
model.export(...)
call. E.gprint(model.export(...))
- Inference code
Thanks i will post it as soon as i can :D
from super-gradients.
Ohh i see, i'll check the TensorRT, i follow the ONNX notebook to export the model, but maybe i done it wrong, i need that the inference time be less than a second, i'm using fastapi framework to users can use the model, but the time of response increase with 50 users at time, this is a basic example of the code
ml_models["num"] = models.get( 'yolo_nas_s', num_classes=10, checkpoint_path=f"newmodels/num.pth" ).eval()
await asyncio.to_thread(number, image, model_name, return_digits)
number is the inference function is a not async, and i can't use GPU, only the CPU of the Pod
from super-gradients.
This is how it looks normal
This is how it looks with onnx
I already using preprocessing true and postprocessing
from super-gradients.
You should be using same or nearly same image resolution during training/validation & inference.
These images looks really different in size. Without seeing the full code you are using for export and inference it is impossible for me to help you.
Here is what can help to understand what is going on
- Export code
- Result of
model.export(...)
call. E.gprint(model.export(...))
- Inference code
from super-gradients.
@BloodAxe This is the export_result
`Model exported successfully to numb.onnx
Model expects input image of shape [1, 3, 640, 640]
Input image dtype is torch.uint8
Exported model already contains preprocessing (normalization) step, so you don't need to do it manually.
Preprocessing steps to be applied to input image are:
Sequential(
(0): CastTensorTo(dtype=torch.float32)
(1): ChannelSelect(channels_indexes=tensor([2, 1, 0]))
)
Exported model contains postprocessing (NMS) step with the following parameters:
num_pre_nms_predictions=1000
max_predictions_per_image=1000
nms_threshold=0.65
confidence_threshold=0.5
output_predictions_format=batch
Exported model is in ONNX format and can be used with ONNXRuntime
To run inference with ONNXRuntime, please use the following code snippet:
import onnxruntime
import numpy as np
session = onnxruntime.InferenceSession("numb.onnx", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])
inputs = [o.name for o in session.get_inputs()]
outputs = [o.name for o in session.get_outputs()]
example_input_image = np.zeros((1, 3, 640, 640)).astype(np.uint8)
predictions = session.run(outputs, {inputs[0]: example_input_image})
Exported model has predictions in batch format:
num_detections, pred_boxes, pred_scores, pred_classes = predictions
for image_index in range(num_detections.shape[0]):
for i in range(num_detections[image_index,0]):
class_id = pred_classes[image_index, i]
confidence = pred_scores[image_index, i]
x_min, y_min, x_max, y_max = pred_boxes[image_index, i]
print(f"Detected object with class_id={class_id}, confidence={confidence}, x_min={x_min}, y_min={y_min}, x_max={x_max}, y_max={y_max}")`
from super-gradients.
Related Issues (20)
- How to define a search space
- `super_gradients.training.utils.predict.prediction_pose_estimation_results.ImagePoseEstimationPrediction.save()` not correctly handling optional parameters and saving image incorrectly
- Fine tuning HyperParameters HOT 2
- Warning: Could not set preprocessing pipeline from the validation dataset: 'AlbumentationsAdaptor' object HOT 5
- quadrangular polygon object detection HOT 2
- WANDB logging not showing HOT 1
- Enable class agnostic NMS HOT 1
- Recipe should be saved to additional_configs_to_log before instantiating it
- RuntimeError: Given groups=1, weight of size [48, 3, 3, 3], expected input[2, 640, 640, 640] to have 3 channels, but got 640 channels instead
- Change Quantization Precision HOT 1
- knowledge distillation to object detection(YOLONAS) HOT 1
- Clarification on license for modifications to Yolo-NAS with pre-trained weights HOT 6
- Error training yolo_nas_l HOT 4
- Issues with Bounding Box Coordinates Exceeding Image Dimensions After ONNX Export
- DiceLoss is unknown object type HOT 2
- SSD MobileNet V2 recipe HOT 1
- Any model for instance segmentation?
- DataParallel Multi-gpu training problem HOT 4
- Incorrect arguments in super_gradients/training/utils/distributed_training_utils.py HOT 1
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 super-gradients.