Giter Site home page Giter Site logo

xuanandsix / gfpgan-onnxruntime-demo Goto Github PK

View Code? Open in Web Editor NEW
104.0 104.0 16.0 2.04 MB

This is the onnxruntime inference code for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior (CVPR 2021). Official code: https://github.com/TencentARC/GFPGAN

Python 100.00%

gfpgan-onnxruntime-demo's People

Contributors

xuanandsix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gfpgan-onnxruntime-demo's Issues

gfpgan onnx model giving bad results

I have used your script and converted gfpgan pth model into onnx model but I am getting horrible results. Like output image is same as input image (in terms of dimensions/size) and the output gets worst after inference. In short, it is not doing super resolution on the image and also making current input image bad.

@xuanandsix So, what could be the possible reason behind this problem ? ( Btw, I have done all the steps properly that you have mentioned in the readme file.)

Input Image:
depositphotos_389009186-stock-photo-full-length-studio-portrait-handsome

Output Image:
depositphotos_389009186-stock-photo-full-length-studio-portrait-handsome_upscaled_gfpgan

ValueError: This ORT build has...

Running Ubuntu 22.04 LTS I get the following error:

Traceback (most recent call last): File "/home/user/GFPGAN-onnxruntime-demo/torch2onnx.py", line 67, in <module> ort_session = onnxruntime.InferenceSession(onnx_model_path) File "/home/user/miniconda3/envs/richard-roop/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 396, in __init__ raise e File "/home/user/miniconda3/envs/richard-roop/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 383, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "/home/user/miniconda3/envs/richard-roop/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 415, in _create_inference_session raise ValueError( ValueError: This ORT build has ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'], ...)

To fix the issue I modify line 67 in torch2onnx.py:

From:
ort_session = onnxruntime.InferenceSession(onnx_model_path)

To:
ort_session = onnxruntime.InferenceSession(onnx_model_path, providers=['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'])

Batching

I will release a PR which supports the batching of the model via ONNX.
I have a protoype working.

如何将全身照图片做处理?

我按照上述步骤成功将1.4和1.3版本的模型导出成onnx模型了,经过我测试,似乎只在输入的图像仅包含头部的时候效果最好。我有个想法,将一张全身照的图片的头部截下来,调整尺寸到512后运行得到生成的图像,再将图像调整回原来的尺寸后放会原来裁剪的位置,但这种方式会导致裁剪出的图像边缘有条纹,结果如下所示:请问这种问题该如何解决

ori
crop_ori
crop_output
output

infer time

nice work!

i run at 4090,the infer time is: 0.6s,a little long. Is this the normal effect?

Quality decrease

I have noted a quality decrease when comparing the results to GFPGAN 1.4 on Replicate.

Any reasons why that could be happening?

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.