Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
sudo: true
language: rust
cache:
- cargo
- directories:
- cached

rust:
- stable
- beta
- nightly
before_install:
- curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
- unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
- sudo mv protoc3/bin/* /usr/local/bin/
- sudo mv protoc3/include/* /usr/local/include/
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
env:
- RUST_BACKTRACE=1
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo bench &&
travis-cargo doc
after_success:
- travis-cargo --only stable doc-upload
- cargo build
- cargo test
- cargo bench
- cargo doc
matrix:
allow_failures:
- rust: nightly
env:
global:
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
- secure: CpygK2eVbhJ0XBb6ABfoaoEdGGzKeUrv8MXHtMPMsVJjdLSfvcpdqehULeq6AXXvdHPy6Z7RWPpX8KU3S/TCHVD9MpeUvsdzduv4bi0uKTXoOqVSmQvkDihy30FOyQvvs+9floHiMeuOuFao8UVCNgpXDbRV76i/P/qYCJiYGVi1XCVV4dy+ELyo2eC5AxdEcq6TlCkiBTYDpjYqxHAoFdPQAfT3ueCNibG/W0yhDSPvp9NpeN0/CS6o/PoQPtq02b9LOJv8ktDyTt5o+hsIXqHW7uksxpNVtJSkX3gLNFZti4Ya2u3jywP3NUDbP9PoK9z429YdCaknigzvvdXggpzg3IV+F9ym/8NeSvHb8CWu8+RNM8mwIlMEfTjffNYJnuGQZ/+T390a2dyYotwKBJQARrGitbsuaTVH7NR2JjBhNwJwQCdxpUCwmMCN0byn3w9FN4OliKM4zWuKM1NJ4ex7x/p9ry3JdF0iaSRc698vTY69S+8/sogGiy2B1ew8G4+qybUiB9mH5rK69qr7o4C55GUHgYInkXmNzMkK25ljElatnac9OVUKOhBGVkScEZIn9ZXkWuXefeGBlXJVwhKdfhOA+OzKx/da3Cmjh48wIRUpSBE+015ywWKUPhnJEHYgOa57afBbhmC9akSUTkQPmeOtLJHRUXT0W2Q0R5g=
10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = ["Mathieu Poumeyrol <kali@zoy.org>"]
description = "Tiny, no-nonsense, self contained, TensorFlow inference"
repository = "https://github.com/kali/tensorflow-deploy-rust"
keywords = [ "TensorFlow", "NeuralNetworks" ]
build="build.rs"
categories = [ "science" ]
documentation = "http://www.poumeyrol.fr/tensorflow-deploy-rust/tfdeploy/index.html"

Expand All @@ -26,27 +25,22 @@ ndarray = { version = "0.11" }
num-traits = "0.2"
protobuf = "1.4"
tensorflow = { version = "0.8", optional = true }
rand = "*"

[features]
default = [ ]
blas = ["ndarray/blas", "blas-src"]
openblas = ["blas", "openblas-src", "blas-src/openblas" ]
accelerate = ["blas", "accelerate-src", "blas-src/accelerate" ]

[build-dependencies]
protoc-rust = "1.4"
tempdir = "0.3"

[dev-dependencies]
colored = "1"
bencher = { git = "https://github.com/snipsco/bencher" }
dinghy-test = { git="https://github.com/snipsco/dinghy.git", branch="0.3"}
dinghy-test = "0.3"
flate2 = "1.0"
itertools = "0.7"
mio_httpc = { version = "0.6", features = [ "rtls" ] }
tar = "0.4"
proptest = "0.6"
reqwest = "0.8.5"

[[bench]]
harness = false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ easily as practical to small-ish devices (think 30$ boards).

# License

Note: files in the `protos` directory are copied from the
Note: files in the `protos/tensorflow` directory are copied from the
[TensorFlow](https://github.com/tensorflow/tensorflow) project and are not
covered by the following licence statement.

Expand Down
2 changes: 1 addition & 1 deletion benches/inceptionv3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate dinghy_test;
extern crate flate2;
extern crate image;
extern crate itertools;
extern crate mio_httpc;
extern crate reqwest;
extern crate ndarray;
extern crate tar;
extern crate tfdeploy;
Expand Down
22 changes: 8 additions & 14 deletions examples/inceptionv3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ extern crate dinghy_test;
extern crate flate2;
extern crate image;
extern crate itertools;
extern crate mio_httpc;
extern crate reqwest;
extern crate ndarray;
extern crate tar;
extern crate tfdeploy;

use std::{fs, io, path};
use mio_httpc::CallBuilder;
use dinghy_test::test_project_path;

use tfdeploy::errors::*;
Expand All @@ -34,17 +33,9 @@ fn do_download() -> Result<()> {
fs::remove_dir_all(&dir_partial).unwrap();
}
fs::create_dir_all(&dir_partial)?;
let url = "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz";
let (resp, body) = CallBuilder::get()
.timeout_ms(50000)
.url(url)
.map_err(|e| format!("request error: {:?}", e))?
.exec()
.map_err(|e| format!("request error: {:?}", e))?;
if resp.status != 200 {
Err("Could not download inception v3")?
}
let mut archive = ::tar::Archive::new(::flate2::read::GzDecoder::new(&body[..]));
let resp = reqwest::get("https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz")
.map_err(|e| format!("Http error: {:?}", e))?;
let mut archive = ::tar::Archive::new(::flate2::read::GzDecoder::new(resp));
archive.unpack(&dir_partial)?;
fs::rename(dir_partial, dir)?;
Ok(())
Expand All @@ -70,7 +61,10 @@ pub fn load_image<P: AsRef<path::Path>>(p: P) -> ::tfdeploy::Matrix {
}

fn inception_v3_2016_08_28() -> path::PathBuf {
::std::env::temp_dir().join("inception-v3-2016_08_28")
match ::std::env::var("TRAVIS_BUILD_DIR") {
Ok(t) => path::Path::new(&t).join("cached").join("inception-v3-2016_08_28"),
_ => ::std::env::temp_dir().join("inception-v3-2016_08_28")
}
}

pub fn inception_v3_2016_08_28_frozen() -> path::PathBuf {
Expand Down
7 changes: 7 additions & 0 deletions protos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "protos"
version = "0.1.0"
authors = ["Mathieu Poumeyrol <kali@zoy.org>"]

[dependencies]
protoc-rust = "1.5"
13 changes: 6 additions & 7 deletions build.rs → protos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ use std::{fs, io, path};
use std::io::{BufRead, Write};

fn main() {
let inputs: Vec<path::PathBuf> = fs::read_dir("protos/tensorflow/core/framework")
let inputs: Vec<path::PathBuf> = fs::read_dir("tensorflow/core/framework")
.unwrap()
.map(|entry| entry.unwrap().path())
.collect();

let _ = fs::create_dir_all("target/generated");

protoc_rust::run(protoc_rust::Args {
out_dir: &*std::env::var("OUT_DIR").unwrap(),
out_dir: "target/generated",
input: &*inputs
.iter()
.map(|a| a.to_str().unwrap())
.collect::<Vec<&str>>(),
includes: &["protos"],
includes: &["."],
}).expect("protoc");

for input in inputs {
let mut broken =
path::PathBuf::from(std::env::var("OUT_DIR").unwrap()).join(input.file_name().unwrap());
println!("cargo:rerun-if-changed={}", input.to_str().unwrap());
let mut broken = path::PathBuf::from("target/generated").join(input.file_name().unwrap());
let mut fixed = broken.clone();
fixed.set_extension("rs");
broken.set_extension("rs.orig");
println!("rename {:?} {:?}", fixed, broken);
fs::rename(&fixed, &broken).unwrap();
let mut f = fs::File::create(fixed).unwrap();
for line in io::BufReader::new(fs::File::open(broken).unwrap()).lines() {
Expand Down
Loading