GithubHelp home page GithubHelp logo

alianse777 / darknet-rust Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 8.0 441 KB

A Rust wrapper for Darknet, an open source neural network framework written in C and CUDA.

Home Page: http://pjreddie.com/darknet/

License: MIT License

Python 2.44% Rust 97.56%

darknet-rust's People

Contributors

alianse777 avatar jerry73204 avatar marcusdunn avatar strohel 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

Watchers

 avatar

darknet-rust's Issues

Support running network prediction on an OpenGL texture

Hi, thanks for creating these bindings! I wanted to run a darknet network on an OpenGL texture which I already have in GPU memory, so the round-trip from GPU to CPU and back was a bit heavy for me (as well as the CPU operations to put the image into the right format that darknet expects).

I have a prototype working, but I'm not sure how best to contribute it, and I want to know if it's desired from others or not.

This repo points to a somewhat old version of darknet (04b0b15), but I made my modifications based on that commit. If we were to create new bindings, we would either have to point this repo's submodule to a fork which contains the OpenGL code, or merge the OpenGL work upstream and base it on the latest master branch. In that case, the bindings here would probably need to be updated and it could potentially be more work than expected.

What would you recommend I do?

After all that, the higher level darknet crate would then need to be modified with new functions to support running the network from a texture, but that part is pretty easy.

Is the input for the darknet model RGB or BGR, ranging in [0.0, 1.0] or [0, 255]?

Hi,

I'm trying to construct an image for the darknet model inference.

But I'm not sure if the sequence of the raw image data for the darknet input is RGB or BGR.

And is the range of the pixel value [0.0, 1.0] or [0, 255]

// Create an empty image
let dimg = unsafe { darknet_sys::make_image(640, 480, 3) };

// Fill the data with RGB ranging from [0, 1]
let slice = unsafe { slice::from_raw_parts_mut(dimg.data, 640*480*3) }; 
for i in 0..640*480*3 {
    slice[i] = v.data[i] as f32 / 255.0;
}

// let d_img = unsafe { darknet_sys::resize_image(dimg, 416, 416) };

let img = darknet::Image {
    image: d_img
};

// Make prediction
let detections = net.lock().unwrap().predict(&img, 0.25, 0.5, 0.45, true);

Thanks for your help.

Darknet sys fails to build

Hi, when I try to build the yolo v3 example file, the thread panics. The error I get is Cannot open include file: 'sys/time.h': No such file or directory [C:\Users\Filip Mattsson\Downloads\rust-darknet\target\debug\build\darknet-sys-2b3d282f1cd2812c\out\build\darknet.vcxproj].

Is there any solution to this issue?

Build fails with `darknet-rust` and `opencv` on Arch Linux

Description:

I am encountering a build failure when trying to use the darknet-rust crate in combination with the opencv crate in my Rust project on Arch Linux. The project builds fine when either crate is used independently, but combining them leads to a build error related to libclang.

Environment:

  • OS: Arch Linux - 6.5.9-arch2-1
  • Rust version: 1.73.0
  • clang version: 16.0.6
  • darknet-rust version: 0.4
  • opencv version: 0.85.3

Steps to Reproduce:

  1. Create a new Rust project.
  2. Add darknet-rust and opencv to Cargo.toml.
  3. Run cargo build.

Error Log:

=== Detected OpenCV module header dir at: /usr/include/opencv4/opencv2
=== Found OpenCV version: [version] in headers located at: /usr/include/opencv4
=== Generating code in: [...]/test_darknet/target/debug/build/opencv-[hash]/out
=== Placing generated bindings into: [...]/test_darknet/target/debug/build/opencv-[hash]/out/opencv
=== Using OpenCV headers from: /usr/include/opencv4
thread 'main' panicked at [...]/.cargo/registry/src/index.crates.io-[hash]/clang-sys-1.6.1/src/lib.rs:1735:1:
a `libclang` shared library is not loaded on this thread
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Troubleshooting Steps:

  • Set LIBCLANG_PATH to /usr/lib.
  • Tried different versions of the crates.
  • Installed libclang and verified its presence.

Any help or guidance on resolving this issue would be greatly appreciated.

docs.rs failed to build darknet-0.2.0

$ rustc --version
rustc 1.45.0-nightly (99cb9ccb9 2020-05-11)
$ cratesfyi --version
docsrs 0.6.0 (3125c8b 2020-05-08)
$ cratesfyi ...
[INFO] running "docker" "create" "-v" "/home/cratesfyi/workspace/builds/darknet-0.2.0/target:/opt/rustwide/target:rw,Z" "-v" "/home/cratesfyi/workspace/builds/darknet-0.2.0/source:/opt/rustwide/workdir:ro,Z" "-v" "/home/cratesfyi/workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/home/cratesfyi/workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "MAP_USER_ID=1001" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "RUSTFLAGS=" "-e" "RUSTDOCFLAGS=-Z unstable-options --resource-suffix -20200511-1.45.0-nightly-99cb9ccb9 --static-root-path / --cap-lints warn --extern-html-root-url failure=https://docs.rs/failure/0.1.8 --extern-html-root-url num_traits=https://docs.rs/num-traits/0.2.11 --extern-html-root-url image=https://docs.rs/image/0.23.4 --extern-html-root-url argh=https://docs.rs/argh/0.1.3 --extern-html-root-url darknet_sys=https://docs.rs/darknet-sys/0.2.2 --extern-html-root-url sha2=https://docs.rs/sha2/0.8.1 --extern-html-root-url reqwest=https://docs.rs/reqwest/0.10.4 --extern-html-root-url num_derive=https://docs.rs/num-derive/0.3.0 --extern-html-root-url hex=https://docs.rs/hex/0.4.2 --extern-html-root-url libc=https://docs.rs/libc/0.2.69" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "3221225472" "--cpus" "2" "--network" "none" "rustops/crates-build-env" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "doc" "--lib" "--no-deps" "-j2"
[INFO] [stderr] WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[INFO] [stdout] 7f6d1b3cb64f229400509b07d920182fc79547d4068f6f1adfa6ad2a3ba37ff1
[INFO] running "docker" "start" "-a" "7f6d1b3cb64f229400509b07d920182fc79547d4068f6f1adfa6ad2a3ba37ff1"
[INFO] [stderr] sudo: setrlimit(RLIMIT_CORE): Operation not permitted
[INFO] [stderr] Compiling autocfg v1.0.0
[INFO] [stderr] Compiling libc v0.2.69
[INFO] [stderr] Compiling cc v1.0.52
[INFO] [stderr] Compiling proc-macro2 v1.0.12
[INFO] [stderr] Compiling unicode-xid v0.2.0
[INFO] [stderr] Checking cfg-if v0.1.10
[INFO] [stderr] Compiling memchr v2.3.3
[INFO] [stderr] Compiling bitflags v1.2.1
[INFO] [stderr] Compiling syn v1.0.19
[INFO] [stderr] Compiling glob v0.3.0
[INFO] [stderr] Checking lazy_static v1.4.0
[INFO] [stderr] Compiling maybe-uninit v2.0.0
[INFO] [stderr] Compiling version_check v0.9.1
[INFO] [stderr] Compiling log v0.4.8
[INFO] [stderr] Compiling failure_derive v0.1.8
[INFO] [stderr] Compiling byteorder v1.3.4
[INFO] [stderr] Compiling quick-error v1.2.3
[INFO] [stderr] Checking adler32 v1.0.4
[INFO] [stderr] Checking scopeguard v1.1.0
[INFO] [stderr] Compiling unicode-width v0.1.7
[INFO] [stderr] Compiling regex-syntax v0.6.17
[INFO] [stderr] Compiling strsim v0.8.0
[INFO] [stderr] Compiling vec_map v0.8.2
[INFO] [stderr] Compiling rustc-demangle v0.1.16
[INFO] [stderr] Compiling bindgen v0.53.2
[INFO] [stderr] Compiling rayon-core v1.7.0
[INFO] [stderr] Compiling ansi_term v0.11.0
[INFO] [stderr] Compiling termcolor v1.1.0
[INFO] [stderr] Compiling lazycell v1.2.1
[INFO] [stderr] Compiling rustc-hash v1.1.0
[INFO] [stderr] Compiling crc32fast v1.2.0
[INFO] [stderr] Compiling peeking_take_while v0.1.2
[INFO] [stderr] Compiling shlex v0.1.1
[INFO] [stderr] Checking either v1.5.3
[INFO] [stderr] Checking lzw v0.10.0
[INFO] [stderr] Checking color_quant v1.0.1
[INFO] [stderr] Checking scoped_threadpool v0.1.9
[INFO] [stderr] Checking bytemuck v1.2.0
[INFO] [stderr] Compiling crossbeam-utils v0.7.2
[INFO] [stderr] Compiling memoffset v0.5.4
[INFO] [stderr] Compiling crossbeam-epoch v0.8.2
[INFO] [stderr] Compiling num-traits v0.2.11
[INFO] [stderr] Compiling num-integer v0.1.42
[INFO] [stderr] Compiling num-iter v0.1.40
[INFO] [stderr] Compiling num-rational v0.2.4
[INFO] [stderr] Compiling cmake v0.1.42
[INFO] [stderr] Compiling backtrace-sys v0.1.37
[INFO] [stderr] Compiling libloading v0.5.2
[INFO] [stderr] Compiling clang-sys v0.29.3
[INFO] [stderr] Compiling nom v5.1.1
[INFO] [stderr] Compiling thread_local v1.0.1
[INFO] [stderr] Compiling humantime v1.3.0
[INFO] [stderr] Checking miniz_oxide v0.3.6
[INFO] [stderr] Checking inflate v0.4.5
[INFO] [stderr] Compiling textwrap v0.11.0
[INFO] [stderr] Checking gif v0.10.3
[INFO] [stderr] Checking num_cpus v1.13.0
[INFO] [stderr] Compiling atty v0.2.14
[INFO] [stderr] Compiling which v3.1.1
[INFO] [stderr] Compiling aho-corasick v0.7.10
[INFO] [stderr] Compiling quote v1.0.4
[INFO] [stderr] Checking deflate v0.8.4
[INFO] [stderr] Checking tiff v0.4.0
[INFO] [stderr] Compiling clap v2.33.0
[INFO] [stderr] Checking crossbeam-queue v0.2.1
[INFO] [stderr] Compiling regex v1.3.7
[INFO] [stderr] Compiling backtrace v0.3.46
[INFO] [stderr] Checking png v0.16.3
[INFO] [stderr] Compiling cexpr v0.4.0
[INFO] [stderr] Checking crossbeam-deque v0.7.3
[INFO] [stderr] Compiling env_logger v0.7.1
[INFO] [stderr] Compiling synstructure v0.12.3
[INFO] [stderr] Compiling num-derive v0.3.0
[INFO] [stderr] Checking rayon v1.3.0
[INFO] [stderr] Checking jpeg-decoder v0.1.19
[INFO] [stderr] Compiling failure v0.1.8
[INFO] [stderr] Checking image v0.23.4
[INFO] [stderr] Compiling darknet-sys v0.2.2
[INFO] [stderr] error: failed to run custom build command for darknet-sys v0.2.2
[INFO] [stderr]
[INFO] [stderr] Caused by:
[INFO] [stderr] process didn't exit successfully: /opt/rustwide/target/debug/build/darknet-sys-b5554ce9549b0131/build-script-build (exit code: 101)
[INFO] [stderr] --- stdout
[INFO] [stderr] cargo:rerun-if-env-changed=DARKNET_SRC
[INFO] [stderr] cargo:rerun-if-env-changed=DARKNET_INCLUDE_PATH
[INFO] [stderr] cargo:rerun-if-env-changed=/opt/rustwide/target/debug/build/darknet-sys-e2510a97b65838ea/out/bindings.rs
[INFO] [stderr] running: "cmake" "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/darknet-sys-0.2.2/darknet" "-DBUILD_SHARED_LIBS=OFF" "-DCMAKE_INSTALL_PREFIX=/opt/rustwide/target/debug/build/darknet-sys-e2510a97b65838ea/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_BUILD_TYPE=Debug"
[INFO] [stderr] -- The C compiler identification is GNU 9.3.0
[INFO] [stderr] -- The CXX compiler identification is GNU 9.3.0
[INFO] [stderr] -- Check for working C compiler: /usr/bin/cc
[INFO] [stderr] -- Check for working C compiler: /usr/bin/cc -- works
[INFO] [stderr] -- Detecting C compiler ABI info
[INFO] [stderr] -- Detecting C compiler ABI info - done
[INFO] [stderr] -- Detecting C compile features
[INFO] [stderr] -- Detecting C compile features - done
[INFO] [stderr] -- Check for working CXX compiler: /usr/bin/c++
[INFO] [stderr] -- Check for working CXX compiler: /usr/bin/c++ -- works
[INFO] [stderr] -- Detecting CXX compiler ABI info
[INFO] [stderr] -- Detecting CXX compiler ABI info - done
[INFO] [stderr] -- Detecting CXX compile features
[INFO] [stderr] -- Detecting CXX compile features - done
[INFO] [stderr] -- Looking for a CUDA compiler
[INFO] [stderr] -- Looking for a CUDA compiler - NOTFOUND
[INFO] [stderr] -- Looking for pthread.h
[INFO] [stderr] -- Looking for pthread.h - found
[INFO] [stderr] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[INFO] [stderr] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
[INFO] [stderr] -- Looking for pthread_create in pthreads
[INFO] [stderr] -- Looking for pthread_create in pthreads - not found
[INFO] [stderr] -- Looking for pthread_create in pthread
[INFO] [stderr] -- Looking for pthread_create in pthread - found
[INFO] [stderr] -- Found Threads: TRUE
[INFO] [stderr] -- Found Stb: /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/darknet-sys-0.2.2/darknet/3rdparty/stb/include
[INFO] [stderr] -- Found OpenMP_C: -fopenmp (found version "4.5")
[INFO] [stderr] -- Found OpenMP_CXX: -fopenmp (found version "4.5")
[INFO] [stderr] -- Found OpenMP: TRUE (found version "4.5")
[INFO] [stderr] -- ZED SDK not enabled, since it requires CUDA
[INFO] [stderr] -- Configuring incomplete, errors occurred!
[INFO] [stderr] See also "/opt/rustwide/target/debug/build/darknet-sys-e2510a97b65838ea/out/build/CMakeFiles/CMakeOutput.log".
[INFO] [stderr] See also "/opt/rustwide/target/debug/build/darknet-sys-e2510a97b65838ea/out/build/CMakeFiles/CMakeError.log".
[INFO] [stderr]
[INFO] [stderr] --- stderr
[INFO] [stderr] CMake Warning at CMakeLists.txt:103 (find_package):
[INFO] [stderr] By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
[INFO] [stderr] asked CMake to find a package configuration file provided by "OpenCV", but
[INFO] [stderr] CMake did not find one.
[INFO] [stderr]
[INFO] [stderr] Could not find a package configuration file provided by "OpenCV" with any
[INFO] [stderr] of the following names:
[INFO] [stderr]
[INFO] [stderr] OpenCVConfig.cmake
[INFO] [stderr] opencv-config.cmake
[INFO] [stderr]
[INFO] [stderr] Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
[INFO] [stderr] "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
[INFO] [stderr] provides a separate development package or SDK, be sure it has been
[INFO] [stderr] installed.
[INFO] [stderr]
[INFO] [stderr]
[INFO] [stderr] CMake Error: Could not open file for write in copy operation /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/darknet-sys-0.2.2/darknet/src/version.h.tmp
[INFO] [stderr] CMake Error: : System Error: Read-only file system
[INFO] [stderr] CMake Error at CMakeLists.txt:247 (configure_file):
[INFO] [stderr] configure_file Problem configuring file
[INFO] [stderr]
[INFO] [stderr]
[INFO] [stderr] CMake Warning at CMakeLists.txt:459 (export):
[INFO] [stderr] Cannot create package registry file:
[INFO] [stderr]
[INFO] [stderr] /home/crates-build-env/.cmake/packages/Darknet/677700aa285d2d53d8571386ef31c88f
[INFO] [stderr]
[INFO] [stderr] No such file or directory
[INFO] [stderr]
[INFO] [stderr]
[INFO] [stderr]
[INFO] [stderr] thread 'main' panicked at '
[INFO] [stderr] command did not execute successfully, got: exit code: 1
[INFO] [stderr]
[INFO] [stderr] build script failed, must exit now', /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.42/src/lib.rs:861:5
[INFO] [stderr] note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
[INFO] [stderr]
[INFO] running "docker" "inspect" "7f6d1b3cb64f229400509b07d920182fc79547d4068f6f1adfa6ad2a3ba37ff1"
[INFO] running "docker" "rm" "-f" "7f6d1b3cb64f229400509b07d920182fc79547d4068f6f1adfa6ad2a3ba37ff1"
[INFO] [stdout] 7f6d1b3cb64f229400509b07d920182fc79547d4068f6f1adfa6ad2a3ba37ff1

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.