From 7fcee11cc5919cb850bbfbb42401be1b2fa9d0de Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 1 Feb 2024 16:11:56 +0800 Subject: [PATCH 1/3] update candle nn and core --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4f6652a..47efd5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ default-run = "surya" [dependencies] anyhow = { version = "1.0.79", optional = true } -candle-core = { version = "0.3.2" } -candle-nn = { version = "0.3.2" } +candle-core = { version = "0.3.3" } +candle-nn = { version = "0.3.3" } clap = { version = "4.4.18", features = ["derive"], optional = true } env_logger = { version = "0.11.0" } hf-hub = { version = "0.3.2" } From af98f2da4ad4debac8fdddc70bba5de9577d9cdc Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 1 Feb 2024 16:50:29 +0800 Subject: [PATCH 2/3] default device type --- src/bin/main.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index 1bd5ca1..0df5f1b 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -130,8 +130,12 @@ struct Cli { )] output_dir: PathBuf, - #[arg(long = "device", value_enum, default_value_t = DeviceType::Cpu)] - device_type: DeviceType, + #[arg( + long = "device", + value_enum, + help = "device type, if not specified will try to use GPU or Metal" + )] + device_type: Option, #[arg(long, help = "whether to enable verbose mode")] verbose: bool, @@ -179,7 +183,13 @@ fn main() -> surya::Result<()> { "bbox-area-threshold must be > 0" ); - let device = args.device_type.try_into()?; + let device = match args.device_type { + Some(device_type) => device_type.try_into()?, + None => Device::new_cuda(0) + .or_else(|_| Device::new_metal(0)) + .unwrap_or(Device::Cpu), + }; + debug!("using device {:?}", device); let image_chunks = read_chunked_resized_image(&args.image)?; From c73c8ff6dff1e8f2da0b70640ef151e096d8d013 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 1 Feb 2024 16:56:31 +0800 Subject: [PATCH 3/3] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9b9e0d..ceace8c 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Options: --output-dir output directory, under which the input image will be generating a subdirectory [default: ./surya_output] --device - [default: cpu] [possible values: cpu, gpu, metal] + device type, if not specified will try to use GPU or Metal [possible values: cpu, gpu, metal] --verbose whether to enable verbose mode -h, --help