Giter Club home page Giter Club logo

Comments (10)

SnowRipple avatar SnowRipple commented on May 22, 2024 1

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.

biubug6 avatar biubug6 commented on May 22, 2024

When training, input is cropped to 840*840 defined in "data/config.py".

from pytorch_retinaface.

DDFlyInCode avatar DDFlyInCode commented on May 22, 2024

how about inference?

from pytorch_retinaface.

DDFlyInCode avatar DDFlyInCode commented on May 22, 2024

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.

biubug6 avatar biubug6 commented on May 22, 2024

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.

biubug6 avatar biubug6 commented on May 22, 2024

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.

xsacha avatar xsacha commented on May 22, 2024

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.

SnowRipple avatar SnowRipple commented on May 22, 2024

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.

121649982 avatar 121649982 commented on May 22, 2024

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.

venki-lfc avatar venki-lfc commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.