Comments (10)
PyTorch 1.2 supports dynamic input now, such as:
model = models.resnet18()
dummy_input = torch.zeros(1, 3, 224, 224)
inputs = ['images']
outputs = ['scores']
dynamic_axes = {'images': {0: 'batch'}, 'scores': {0: 'batch'}}
torch.onnx.export(model, dummy_input, 'test.onnx', input_names=inputs, output_names=outputs, dynamic_axes=dynamic_axes)
from pytorch_retinaface.
When training, input is cropped to 840*840 defined in "data/config.py".
from pytorch_retinaface.
how about inference?
from pytorch_retinaface.
i found inference code can recevied any inputshape image.
This may lead some problems in model convert when I use onnx.
Because onnx model is base on static map ,can not auto resize with mutil size image.
I dont know what to do ! Looking forward to help , thx.
By the way! Your project is amazing
from pytorch_retinaface.
When testing, I provide original image size as input in widerface val. You can scale image to a certain size according to the effect and your needs. See "test_widerface.py" for details.
from pytorch_retinaface.
Because of the full convolution structure of network, It don't lead some problems in model convert when I convert model from onnx to NCNN and deploy the model.
from pytorch_retinaface.
Ultimately the model still prefers its training dimensions, but it will work at any resolution. You should set the size based on the minimum face size you desire.
from pytorch_retinaface.
I thought that onnx supports dynamic input sizes now, from:
https://pytorch.org/tutorials/advanced/super_resolution_with_onnxruntime.html
"Note that the input size will be fixed in the exported ONNX graph for all the input’s dimensions, unless specified as a dynamic axes"
Making input fixed makes results worse for datasets with differently sized images (like Widerface). Did anyone tried onnx version with dynamic input sizes?
from pytorch_retinaface.
Because of the full convolution structure of network, It don't lead some problems in model convert when I convert model from onnx to NCNN and deploy the model.
can you share your demo how to load onnx model ,please? thank you
from pytorch_retinaface.
For people who have trouble in exporting to onnx model with arbitrary height and width, You can do the following way:
model.eval()
# Define the input and output names for the ONNX model
input_names = ["input"]
output_names = ["output"]
# Export the PyTorch model to ONNX format
output_path = "retinaface.onnx"
batch_size = 1 # random initialization
dummy_input = torch.randn(batch_size, 3, 640, 640) # This is a random tensor with the same shape as the expected input
dynamic_axes = {'input' : {2 : 'height', 3:'width'}, # enables the model to accept dynamic batch sizes
}
torch.onnx.export(model, dummy_input.to(device), output_path,
do_constant_folding=True,
input_names=input_names, output_names=output_names,
dynamic_axes=dynamic_axes)
The ONNX model can now accept images of any input size just like pytorch. And you don't have to worry about resizing the input images. Just follow the pre- and post-processing steps in detect.py
from pytorch_retinaface.
Related Issues (20)
- Is it ok if we upload your models to Zenodo and distribute them?
- Fine-tuning Resnet 50 model
- Unable to find a compatible Visual Studio installation
- How to fit non-squared input?
- The form of bboxes is wrong!!!
- Mesh decoder HOT 1
- About the ratioHard Example Mining HOT 3
- Why can't we evaluate during the training? HOT 1
- Pretrained Model HOT 1
- [Refactor] Acclerate training based on MMEngine :rocket:
- How to train with custom dataset by using the pretrained model?
- Dataset
- Evaluation 评估失败,在widerface的三个子集上map值都为0 HOT 1
- What maximum FPS have you achieved?
- Why does the forward pass time become shorter with iterations?
- Why loop 100 times while testing begin in detect.py?
- 用celeba数据集训练的模型,摄像头测试时小脸的框会变大框不准 HOT 1
- How can I train using pth pretrained file? (For transfer learning)
- 用预训练的权重直接训练,为什么loss会这么高
- C++ and TensorRT implementation of yolov5face yolov7face yolov8face
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 pytorch_retinaface.