Giter VIP home page Giter VIP logo

libtorch_examples's Introduction

Libtorch C++ Examples

Build Status

TODO

  • implement Resnet50
  • load Onnx and call forward
  • implement LSTM
  • implement custom dataloader for images, sound and text

libtorch_examples's People

Contributors

dendisuhubdy 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libtorch_examples's Issues

opencv to torch tensor doesn't look quite right

Hi,

Thanks for providing these examples. I'm wondering if the yolo3.cpp is working because I'm looking at the conversion from the opencv image to torch tensor and it doesn't quite look right. The snipit of code is below (which is lines 56 to 67 of yolo3.cpp). Looks like you use opencv to convert the data to float, but then the torch::from_blob call is expecting byte data (and the subsequent step converts to float). Maybe just change the torch::from_blob call to take float and then skip the subsequent conversion?

Thanks,
Marc

    origin_image = cv::imread(argv[1]);
    
    cv::cvtColor(origin_image, resized_image,  cv::COLOR_RGB2BGR);
    cv::resize(resized_image, resized_image, cv::Size(input_image_size, input_image_size));

    cv::Mat img_float;
    resized_image.convertTo(img_float, CV_32F, 1.0/255);

    // auto img_tensor = torch::CPU(torch::kFloat32).tensorFromBlob(img_float.data, {1, input_image_size, input_image_size, 3});
    auto img_tensor = torch::from_blob(img_float.data, {1, input_image_size, input_image_size, 3}, at::kByte);
    img_tensor = img_tensor.to(torch::kFloat32);
    img_tensor = img_tensor.permute({0,3,1,2});

Development Env

Hi,

May I ask which environment you used? and which IDE?
I am asking since I do have some problem with indexing in Linux with Eclipse and running problem in Windows with Eclipse.

Best,
Afshin

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.