Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Latest commit

 

History

History
36 lines (25 loc) · 1.47 KB

examples.rst

File metadata and controls

36 lines (25 loc) · 1.47 KB

The Example

Now you've implemented your task, it's time to add an example showing how cool it is! We usually provide one example in flash_examples/. You can base these off of our template.py examples.

The example should:

  1. download the data (we'll add the example to our CI later on, so choose a dataset small enough that it runs in reasonable time)
  2. load the data into a ~flash.core.data.data_module.DataModule
  3. create an instance of the ~flash.core.model.Task
  4. create a ~flash.core.trainer.Trainer
  5. call ~flash.core.trainer.Trainer.finetune or ~flash.core.trainer.Trainer.fit to train your model
  6. generate predictions for a few examples
  7. save the checkpoint

For our template example we don't have a pretrained backbone, so we can just call ~flash.core.trainer.Trainer.fit rather than ~flash.core.trainer.Trainer.finetune. Here's the full example (flash_examples/template.py):

../../../flash_examples/template.py

We get this output:

['setosa', 'virginica', 'versicolor']

Now that you've got an example showing your awesome task in action, it's time to write some tests! <contributing_tests>