Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jimexist committed Mar 3, 2024
1 parent 79fe76a commit 4c51d7a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
19 changes: 12 additions & 7 deletions candle-examples/examples/segformer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
- [`mit-b0` - An encoder only pretrained model][encoder]
- [`segformer-b0-finetuned-ade-512-512` - A fine tuned model for segmentation][ade512]

[segformer]: https://huggingface.co/docs/transformers/model_doc/segformer
[encoder]: https://huggingface.co/nvidia/mit-b0
[ade512]: https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512
## How to run the example

## How to run
If you want you can use the example images from this [pull request][pr], download them and supply the path to the image as an argument to the example.

```bash
# run image classification task
cargo run --example segformer classify candle-examples/examples/segformer/assets/burger.jpg
# run the image classification task
cargo run --example segformer classify <path-to-image>
# run the segmentation task
cargo run --example segformer segment <path-to-image>
```

Example output:
Example output for classification:

```text
classification logits [3.275261e-5, 0.0008562019, 0.0008868563, 0.9977506, 0.0002465068, 0.0002241473, 2.846596e-6]
label: hamburger
```

[pr]: https://github.com/huggingface/candle/pull/1617
[segformer]: https://huggingface.co/docs/transformers/model_doc/segformer
[encoder]: https://huggingface.co/nvidia/mit-b0
[ade512]: https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512
Binary file not shown.
Binary file removed candle-examples/examples/segformer/assets/burger.jpg
Binary file not shown.
Binary file removed candle-examples/examples/segformer/assets/output.png
Binary file not shown.
16 changes: 3 additions & 13 deletions candle-examples/examples/segformer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,9 @@ struct SegmentationArgs {
default_value = "candle-examples/examples/segformer/assets/labels.json"
)]
label_path: PathBuf,
#[arg(
long,
help = "path to for the output mask image",
default_value = "candle-examples/examples/segformer/assets/output.png"
)]
#[arg(long, help = "path to for the output mask image")]
output_path: PathBuf,
#[arg(
help = "path to image as input",
default_value = "candle-examples/examples/segformer/assets/ADE_val_00000001.jpg"
)]
#[arg(help = "path to image as input")]
image: PathBuf,
}

Expand All @@ -53,10 +46,7 @@ struct ClassificationArgs {
default_value = "paolinox/segformer-finetuned-food101"
)]
model_name: String,
#[arg(
help = "path to image as input",
default_value = "candle-examples/examples/segformer/assets/burger.jpg"
)]
#[arg(help = "path to image as input")]
image: PathBuf,
}

Expand Down

0 comments on commit 4c51d7a

Please sign in to comment.