• Stars
    star
    264
  • Rank 151,823 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

thor: C++ helper library, for deep learning purpose

thor Travis Status

**thor** is a C++ helper library which provide huge utilities, algorithms, and visualization functions for deep learning. We recommend install thor from github source since we update thor new APIs a lot. But *thor* will always compatible with older versions, it safe and reliable integrate into your projects and providing useful utilities.

Glad to know this repo was recommended by 爱可可老师! The link is https://weibo.com/1402400261/I8p1gnIkK .

note: Now thor built against protobuf by default (due to we use proto to visualize boxes in C++ for cross-platform), so in your project, you gonna need add following in your CMakeLists.txt:

find_package(Protobuf REQUIRED)
target_link_library(your_executable ${PROTOBUF_LIBRARY} thor)

Roadmap

thor is still need progress and enlarge it's functionality. Current roadmap are:

  • support instance segmentation visualization;
  • upload thor to ubuntu package manager;

Quick Install

Simple version:

./build_simple.sh

You need install libprotobuf-dev and protobuf-compiler first on Ubuntu or linux system. If you got any problems about not found libcurl or protobuf header files, be sure installed libs inside build_simple.sh.

If you want to build thor on JetsonNano, you need manually uncomment CMakeLists.txt link path to your aarch64 system path (normal PC is x86).

image-20201107222319190

image-20201107222409982

If you setup correctly, thor can be successfully installed on JetsonNano as well.

Install

If you are a newbie of C++ or Ubuntu, recommend you using simple mode.

a). If you only need thor independent modules without OpenCV or Eigen or Protobuf or Curl, you can simply run:

./build_simple.sh

this will build a standalone thor.so without link any other libs, but if you call any function that needs opencv or protobuf will leads to an error.

b). If you need full capacity which thor does, including vis, geometry, datum modules, you can run:

./build_full.sh

this will build a full version of thor with link to opencv, protobuf, curl, freetype. so if you call any related function, you gonna need link to that lib first in your cmake file.

note: Our logging module using same micro define as glog, so it will conflicts if you importing them both. If your project doesn't need glog and you are using thor, you can simply deprecate glog and using thor only.

Updates

  • 2050.01.01: to be continue..

  • 2021.01.11: New thor built with C++14 by default. det.pro added x, y, w, h as attributes.

  • 2020.08.17: thor now supports visualize lane:

    auto resImg = thor::vis::VisualizeLanes(image, res, nullptr, 12, 1.0);

  • 2020.04.15: thor now build with curl and protobuf by default. If you got any question about protobuf link problem, pls fire an issue, I will help u fix that, normally thor should built successfully without any errors, as long as you install default libs:

    sudo apt install libprotobuf-dev
    sudo apt install protobuf-compiler
    sudo apt install libcurl4-openssl-dev
    

    We add protobuf as default built for the introduce of protos which we will using for default data structures:

    Detection2D det1;
    Box box;
    box.set_x1(23);
    box.set_y1(89);
    box.set_x2(99);
    box.set_y2(156);
    det1.set_allocated_box(&box);
    det1.set_cls_id(9);
    det1.set_prob(0.9);
    
    InstanceSegmentation seg1;
    seg1.set_allocated_detection(&det1);
    // float32
    seg1.add_mask(2.3);
    seg1.add_mask(2.3);
    seg1.add_mask(2.3);
    seg1.add_mask(2.3);
    
    LOG(INFO) << seg1.DebugString();

    this will easy transport to other languages:

    detection {
      box {
        x1: 23
        y1: 89
        x2: 99
        y2: 156
      }
      cls_id: 9
      prob: 0.9
    }
    mask: 2.3
    mask: 2.3
    mask: 2.3
    mask: 2.3
    
  • 2019.12.26: We add a functions in thor to enable some tiny functions:

    #include "thor/functions.h"
    
    double values[] = {-0.9381,  0.8967};
    double probs[2];
    thor::functions::softmax_1d(values, probs, 2);
    LOG(INFO) << probs[0] << " " << probs[1];

    Also we update a bug in HWC2CHW, now it works well now.

  • 2019.11.16: We demonstrate how to using thor::vis to draw detections in your algorithm:

    #include "thor/dl.h"
    #include "thor/os.h"
    #include "thor/structures.h"
    #include "thor/vis.h"
    
    using namespace std;
    using namespace cv;
    using namespace thor::vis;
    using namespace thor::dl;
    
    int main() {
        vector<thor::Box> all_detections;
      for (int i = 0; i < num_det; i++) {
        // Show results over confidence threshold
        if (scores[i] >= 0.33f) {
          float x1 = boxes[i * 4 + 0] * scale_x;
          float y1 = boxes[i * 4 + 1] * scale_y;
          float x2 = boxes[i * 4 + 2] * scale_x;
          float y2 = boxes[i * 4 + 3] * scale_y;
          thor::Box one_box{x1, y1, x2, y2, thor::BoxFormat::XYXY};
          one_box.score = scores[i];
          one_box.idx = classes[i] + 1;
          all_detections.emplace_back(one_box);
        }
      }
    
    // draw
    auto res_image = thor::vis::VisualizeDetectionStyleDetectron2(
              image, all_detections, COCO_CLASSES);
    }

    Above is a simple example using thor::vis::VisualizeDetectionStyleDetectron2 draw bounding boxes using detectron2 style. From our experiences, these steps time cost is about 0.0001s, so it's doesn't matter if you generate your box format to thor::Box format first and then call our drawing method.

  • 2019.09.24: I just notice thor has been recommended by 爱可可老师 through weibo, here is link: https://weibo.com/1402400261/I8p1gnIkK , check it out!!! If you like this project, pls give a star!!

  • 2019.08.29: A new header-only args parser lib has been added into thor. Original implementation from here. We did some changes than original, roughly usage can be used like this:

    #include "thor/args.h"
    using namespace thor;
    int main() {
      args::ArgumentParser parser("YoloV3 TensorRT", "args parse from thor");
      args::HelpFlag help(parser, "HELP", "Show this help menu.", {"help"});
      args::ValueFlag<std::string> data(parser, "data", "data.", {'d'}, "");
      args::ValueFlag<std::string> proto_txt(parser, "proto_txt", "proto_txt.", {'p'}, "");
      args::ValueFlag<std::string> model(parser, "model", "caffe model.", {'m'}, "");
      args::ValueFlag<std::string> engine(parser, "engine", "trt engine file.", {"engine"}, "");
        
        try
        {
            parser.ParseCLI(argc, argv);
        }
        catch (const args::Completion& e)
        {
            std::cout << e.what();
            return 0;
        }
        catch (const args::Help&)
        {
            std::cout << parser;
            return 0;
        }
        catch (const args::ParseError& e)
        {
            std::cerr << e.what() << std::endl;
            std::cerr << parser;
            return 1;
        }
    }

    You will see:

    ./examples/trt_yolov3 {OPTIONS}
    
        YoloV3 TensorRT
    
      OPTIONS:
    
          --help                            Show this help menu.
          -d[data]                          data.
          -p[proto_txt]                     proto_txt.
          -m[model]                         caffe model.
          --engine=[engine]                 trt engine file.
        args parse from thor
    

    This is useful when you do not want gflags and glog lib, since those 2 has been integrated into thor!!

  • 2019.08.07: O(∩_∩)O~~!!! A lightweighted logging lib has been integrated into thor!!!!! Now, you can using LOG(INFO) without glog:

    #include "thor/logging.h"
    
    using namespace thor;
    
    int main() {
    	LOG(INFO) << "this is a log.";
    }

    We'll see:

    I 8/7 11:24:46.484 ...thor_simple.cpp main:28]  this is a log
    
  • 2019.08.06: We add precompile define to turn on or off dependencies, such as opencv or protobuf, those dependencies were turned off by default. If you need full version of thor, simple build with build_full.sh ;

  • 2019.06.16: Update CMakeLists.txt fix eigen include issue, now users install will not got eigen include not found problem, simply remember to install libeigen3-dev first.

  • 2019.06.15: Adding HumanPose drawing in thor!!! Here is what it looks like:

    this can be down by simply apply this:

    #include "thor/vis.h"
    using namespace thor::vis;
    int main() {
        // suppose you have detected poses
        std::vector<thor::HumanPose> poses = ..;
        renderHumanPose(poses, image);
    }
  • 2019.05.23: We just add a datum module into thor and providing a series of str_utils which can be very useful for normal C++ development. Do you want judge a point is on a line segment or not? Do you want describe a rotate box and calculate it's area easily?, thor datum is here to help:

    // datum
    #include "thor/datum.h"
    
    using namespace thor::datum;
    using namespace thor::generic;
    
    Vector2d p1(36, 36);
    Vector2d p2(78, 78);
    
    Vector2d p(23, 23);
    LineSegment2d l(p1, p2);
    
    //call LineSegment2d.IsPointIn() check a point is one segment or not
    cout << l.IsPointIn(p) << endl;
    // out: false, since 23 is out of line
    p = Vector2d(46, 46);
    cout << l.IsPointIn(p) << endl;
    // out: true, since 46 is on line.
    
    AABox2d abox1(Vector2d(2, 4), 224, 345);
    cout << abox1.DebugString() << endl;
    cout << "area: " << abox1.area() << endl;

    that's it! Using thor::datum you can do many math and geometry much more easily!! More excitedly, thor::datum data structure is compatible with apollo!!

  • 2019.05.19: There would be a huge updates on thor in recent days. We are trying to integrate all math library in Apollo into thor. So that it can do lots of math calculations. If you got any undefined inference error just open an issue about that. Currently if you want using thor, you gonna need link protobuf in your c++ project.

  • 2019.05.01: Add some geometry utils such as conversion between quaternion and euler angels for robots and autocar:

    Eigen::Matrix3d Quaternion2RotationMatrix(const double x, const double y, const double z, const double w);
    Eigen::Quaterniond EulerAngle2Quaternion(const double yaw, const double pitch, const double roll);                             

    note: this is only available when you have Eigen installed.

  • 2019.01.15: Tracking projects using thor:

  • 2018.09.15: Object detection projects using thor:

Usage

thor has a very clean and easy-to-use API, it consist of many parts. All parts can be listed as follow:

  • vis: For computer vision, draw boxes or segmentation results on image, should worked with opencv;
  • files;
  • random;
  • color;
  • logging;
  • slam;

You only need add this line to CMakeLists.txt when you have thor installed in your system path.

target_link_libraries(main -lthor)

to build with Makefile, using:

g++ -o a a.cpp `pkg-config thor --cflags --libs`

In case you want integrate but with trouble, find me via wechat: jintianiloveu

Features

We list module thor currently finished here:

  • os
  • color
  • random
  • log
  • string utils
  • geometry (quaternion and euler angle conversion)

Copyright

thor was build by Lucas Jin with ❤️. Under MIT license.

More Repositories

1

tensorflow_poems

中文古诗自动作诗机器人,屌炸天,基于tensorflow1.10 api,正在积极维护升级中,快star,保持更新!
Python
3,595
star
2

yolov7_d2

🔥🔥🔥🔥 (Earlier YOLOv7 not official one) YOLO with Transformers and Instance Segmentation, with TensorRT acceleration! 🔥🔥🔥
Python
3,116
star
3

weibo_terminater

Final Weibo Crawler Scrap Anything From Weibo, comments, weibo contents, followers, anything. The Terminator
Python
2,303
star
4

alfred

alfred-py: A deep learning utility library for **human**, more detail about the usage of lib to: https://zhuanlan.zhihu.com/p/341446046
Python
854
star
5

DCNv2_latest

DCNv2 supports decent pytorch such as torch 1.5+ (now 1.8+)
C++
564
star
6

keras_frcnn

Keras Implementation of faster-rcnn
Python
521
star
7

tensorflow_novelist

模仿莎士比亚创作戏剧!屌炸天的是还能创作金庸武侠小说!快star,保持更新!!
Python
259
star
8

weibo_terminator_workflow

Update Version of weibo_terminator, This is Workflow Version aim at Get Job Done!
Python
258
star
9

faceswap_pytorch

Deep fake ready to train on any 2 pair dataset with higher resolution
Python
242
star
10

nb

Neural Network Blocks - Collect all kinds of fancy model blocks for you to build more powerful neural network model.
Python
231
star
11

pytorch_chatbot

A Marvelous ChatBot implement using PyTorch.
Python
226
star
12

CenterNet_Pro_Max

Experiments based on CenterNet (more backbones, TensorRT deployment and mask head)
221
star
13

LSTM_learn

a implement of LSTM using Keras for time series prediction regression problem
Python
214
star
14

AI-Infer-Engine-From-Zero

关于自建AI推理引擎的手册,从0开始你需要知道的所有事情
206
star
15

movenet

Google's Next Gen Pose Estimation in PyTorch
Python
122
star
16

Spider12306

基于Python3的12306抢票爬虫,10个线程开抢,智能过滤凌晨12:00到7:00发车的车次。
Python
106
star
17

pytorch_image_classifier

Minimal But Practical Image Classifier Pipline Using Pytorch, Finetune on ResNet18, Got 99% Accuracy on Own Small Datasets.
Python
106
star
18

kitti-ssd

Train your own data using SSD in a more clear and simple way(not include source code)
Python
101
star
19

TrafficLightsDetection

using SSD and caffe detect traffic lights on LISA dataset
Python
99
star
20

nosmpl

Accelerated SMPL operation, commonly used in generate 3D human mesh, STAR included.
Python
93
star
21

ssds_pytorch

Multiple basenet MobileNet v1,v2, ResNet combined with SSD detection method and it's variants such as RFB, FSSD etc.
Python
80
star
22

simpleocv

Make a minimal OpenCV runable on any where, WIP
C++
72
star
23

yolov3_tf2

Yolov3 implemented with brand new TensorFlow 2.0 API (both train and prediction)
Python
67
star
24

yolov7-face

Next Gen Face detection based on YOLOv7
Python
55
star
25

FruitsNutsSeg

detectron2 support self-define data train
Python
50
star
26

onnxexplorer

Explorer for ONNX, this tool will help you take a deep inside look of any ONNX model.
Python
44
star
27

Q-Learning

An C++ Version of Q-Learning, to Train Robot Play with Flappybird!!
C++
40
star
28

cityscapestococo

This repo contains usable code convert cityscapes to coco format (Detectron and maskrcnn-benchmark were all broken)
Python
36
star
29

tfboys

TensorFlow and Pytorch practice codes with purity and simplicity.
Python
34
star
30

OpenHandMocap

Python
33
star
31

textfrontend

单独维护的中文TTS
Python
31
star
32

bboxer

Pure, Simple yet Powerful Image Bound Box Making Tool, already cross platform, welcome star and keep updating.
C++
31
star
33

fpn_rssd

Rotated Box SSD detection Framework with FPN support, next generation object detection framework
Python
29
star
34

aural

A Tiny Project For ASR model training and Deployment
Python
28
star
35

Shadowless

A Fast and Open Source Autonomous Perception System.
C++
27
star
36

awesome_transformer

A curated list of transformer learning materials, shared blogs, technical reviews.
26
star
37

pt_mobilenetv2_deeplabv3

Fast accurate realtime segmentation with DeepLabV3 and MobileNetV2 backbone
Python
26
star
38

pytorch_cycle_gan

CycleGAN with Productive Generate APIs. Generate Any Image from Your Transfer Model.
Python
26
star
39

yolovn

Just another yolo variant.
25
star
40

wanwu_release

Wanwu models release, code will be released soon
23
star
41

spconv

Pytorch layer needed by Second Lidar detector.
C++
23
star
42

3d_detection_kit

Toolkit to Explore 3D data for 3D object detection, point cloud visualization, bev map gen etc. Using KITTI as dummy data
Python
22
star
43

pytorch_image_caption

Image Caption, Show and Tell.
Python
20
star
44

datasets

A Collection of Datasets.
19
star
45

pilgrim_torch2trt

Pilgrim Project: torch2trt, quick convert your pytorch model to TensorRT engine.
C++
19
star
46

yolov5_mask

Try add Instance Segmentation upon YoloV5
Python
18
star
47

libnms

libnms.so for object detection, can be use in libtorch or caffe or nccn or onnx or TensorRT
Cuda
17
star
48

pt_enet

Realtime segmentation with ENet, the fast and accurate segmentation net.
Python
14
star
49

GreatDarkNet

An Edit Version of darknet, and this version you can train and predict on your own datasets! more easily!
C
14
star
50

VIBE_yolov5

Using YOLOv5 as detection on VIBE
Python
13
star
51

daybreak_release

Daybreak APP release
12
star
52

gofind

gofind - your personal find helper
Go
12
star
53

cabinet

Cabinet, The Ultimate Tool Box.
Rust
12
star
54

tensorflow_yolov3

A Detailed and Optimized Implementation of Yolo-V3 in Original TensorFlow.
Python
12
star
55

pytorch_name_net

A NetWork Generate Names, Based On Conditional RNN, Set Condition And Generate Different Names.
Python
11
star
56

tensorflow_extractor

State-of-art and Reliable Text-summary and Information Extraction
Python
11
star
57

RetinaNet

Pytorch Implementation of RetinaNet with CUDA accelerate nms operation.
Python
10
star
58

gluon_ssd

Implement SSD using Gluon in only 300 lines of codes!
Python
10
star
59

m

m editor is a modern, easy to use, fast terminal editor then vim or emacs. written in pure Rust.
Rust
10
star
60

wnnx_models

Various test models in WNNX format. It can view with `pip install wnetron && wnetron`
10
star
61

seg_icnet

ICNet in TensorFlow, Real-Time Segmentation
Python
10
star
62

fusion

Fusion package with transformation between camera and lidar, IMU etc. Autonomous and robot helper.
Python
9
star
63

scraper_toolbox

Python3.6 Scraper Toolbox, You can almost Scrap Anything in this Repo, Welcome Pull Request
Python
9
star
64

blackpearl

The Black Pearl in Golang. Personal Assistant.
Go
9
star
65

mxnet_tiny5

mxnet训练自己的数据集分类,支持模型断点训练和预测单张图片
Python
9
star
66

TTS_CN

A Chinese TTS System!
Python
9
star
67

arxiv_action

企业微信机器人或钉钉机器人定制服务,自动推送arxiv最新paper
Python
9
star
68

papers

Contains many papers with categories in CV, NLP, RL Quantum etc.
8
star
69

pytorch_style_transfer

A Simple Implementation of Neural Style Transfer using Pytorch. You can generate your own art pictures now!
Python
8
star
70

tacotron

TensorFlow implementation of Google Tacotron. Train on Audio and Generate Speech using Text. Which can be Called TTS.
Python
8
star
71

yolov8

7
star
72

numgo

NumPy library in Go.
Go
7
star
73

LLaVA-Magvit2

Python
7
star
74

PoseAILiveLink

PoseAI LiveLink Compatible on macOS
C++
7
star
75

gooooup

Upload load images(files) to cloud, generate permanent link.
Go
7
star
76

mjolnir

Light weighted replacement of original thor C++ library. More simpler, more clean, more light.
C++
7
star
77

UbuntuScripts

Shell
7
star
78

MLLM_Factory

A Dead Simple and Modularized Multi-Modal Training and Finetune Framework. Compatible to any LLaVA/Flamingo/QwenVL/MiniGemini etc series models.
7
star
79

visiontransformers

Vision Transformers that you need.
Python
6
star
80

sherpa_ort

ONNXRuntime ASR C++
C++
6
star
81

minitr

Exploration on Micro Transformers, Unleash the power of mini-transformers!
Python
6
star
82

tensorflow_wgan

A Tensorfow Version of the state-of-art Wasserstein GAN, image super resolution, black image colorful, more function are applying...just star!
Python
6
star
83

tensorflow_classifier

Simple and over-through process for Tensorflow classify images, using own dataset
Python
6
star
84

mxnet_ssd

Another maintained mxnet ssd version
Python
6
star
85

caffe_tiny5

Caffe tutorial for train own data and predict using python
Python
6
star
86

mmc

Next Gen MMD runs on all platforms, Windows, Linux, Mac. Will support exchange between vmd and fbx format.
C++
6
star
87

realrender

3D mesh render without pain.
C++
6
star
88

squeezeseg_pytorch

Realtime Point Cloud Segmentation
Python
6
star
89

vits_cpp

C++ and ONNXRuntime based VITS voice synthesis
C++
6
star
90

tf_pose_realtime

Realtime Openpose with MobileNetV2 backend
PureBasic
6
star
91

AwesomeLLM

6
star
92

mono_odometry

Visual Odometry Using Mono Camera
C++
6
star
93

person_tracking

person tracking in ros
C++
5
star
94

sparrow

The message server in Golang, like WeChat.
JavaScript
5
star
95

algorithm

Contains all kinds of algorithm write in Python and C++, some with Rust.
Python
5
star
96

CaffeHandsOn

This is a Caffe hands on tutorial.
Python
5
star
97

sak

Swiss Army Knife for secret hacking and sniffering
Go
5
star
98

instance_seg_tf

Instance Segmentation with discriminate loss
Python
5
star
99

efficientformers

Collection of efficient transformers.
Python
5
star
100

mumoda

Library to lean big models combined with Text and Image. And then Diffusion!
Python
5
star