Skip to content

Commit

Permalink
[docs] Fixes dataset document.
Browse files Browse the repository at this point in the history
Change-Id: Ia84cc5faf2ebb955188ec995fedb7fa8a596f6de
  • Loading branch information
frankfliu committed Mar 14, 2022
1 parent d9fb99f commit b8ccd0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import ai.djl.training.dataset.Batch;
import ai.djl.training.dataset.RandomAccessDataset;
import ai.djl.training.loss.Loss;
import ai.djl.translate.Pipeline;
import ai.djl.translate.TranslateException;
import java.io.IOException;
import java.nio.file.Paths;
Expand All @@ -52,8 +51,8 @@ public void testImageFolder() throws IOException, TranslateException {
ImageFolder dataset =
ImageFolder.builder()
.setRepository(repository)
.optPipeline(
new Pipeline().add(new Resize(100, 100)).add(new ToTensor()))
.addTransform(new Resize(100, 100))
.addTransform(new ToTensor())
.setSampling(1, false)
.build();

Expand Down
16 changes: 7 additions & 9 deletions docs/development/how_to_use_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ The dataset will take the folder name e.g. `boots`, `pumps`, `shoes` in sorted o
Add the following code snippet to your project to use the ImageFolder dataset.

```java
// set the image folder path
Repository repository = Repository.newInstance("folder", Paths.get("/imagefolder");
ImageFolder dataset =
new ImageFolder.Builder()
// input the root string
.setRepository(new SimpleRepository(Paths.get("root")))
.optPipeline(
// create preprocess pipeline you want
new Pipeline()
.add(new Resize(width, height))
.add(new ToTensor()))
.setSampling(batchSize, true)
.build();
.setRepository(repository)
.addTransform(new Resize(100, 100))
.addTransform(new ToTensor())
.setSampling(batchSize, true)
.build();
// call prepare before using
dataset.prepare();

Expand Down

0 comments on commit b8ccd0e

Please sign in to comment.