Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker set up to support reading checkpoint_file from config.json and documentation #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions label_studio_ml/default_configs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ COPY supervisord.conf /etc/supervisor/conf.d/

WORKDIR /app

COPY /models/*.pt /app/data/models/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntlex What if /models doesn't exist? Looks like it's a very user/system specific folder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I could remove this line since it is elaborated in the the README.md to ensure that the user either has to volumize or copy the model dir in the docker application.

Copy link
Member

@makseq makseq Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's better to check existence of this folder? and then COPY it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misunderstood your initial comment about the user specific directory. I have corrected the directory's path to ./models/*.pt on the latest commit. Let me know if this is what you had in mind.

COPY *.py /app/
COPY *.json /app/

EXPOSE 9090

Expand Down
19 changes: 18 additions & 1 deletion label_studio_ml/default_configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ label-studio start --init new_project --ml-backends http://localhost:9090 --temp

## API guidelines


#### Inference module
In order to create module for inference, you have to declare the following class:

Expand Down Expand Up @@ -73,6 +72,24 @@ class MyModel(BaseModel):
return predictions
```

#### Docker backend

To run the backend via docker:

```bash
cd new_project
docker-compose build
docker-compose up
```

##### Model `checkpoint_file`

When deploying the backend through docker, you can pass the path to the model's `checkpoint_file` (if required as class argument in your inference model, [see OpenMMLab example](https://labelstud.io/tutorials/object-detector.html)) in the `config.json`. Additionally, make sure to make the model's checkpoint file available inside the docker container, either by copying the file to `/app/data/models` or by creating a volume of the model's directory.

##### Cloud storage credentials

If label studio is set up to read images from a cloud storage, please make sure to grant docker access to your storage credentials as `environment` parameters in `docker-compose.yml`.

#### Training module
Training could be made in a separate environment. The only one convention is that data iterator and working directory are specified as input arguments for training function which outputs JSON-serializable resources consumed later by `load()` function in inference module.

Expand Down
6 changes: 5 additions & 1 deletion label_studio_ml/default_configs/_wsgi.py.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json
import argparse
import logging
import logging.config
Expand Down Expand Up @@ -116,11 +117,14 @@ if __name__ == "__main__":
app.run(host=args.host, port=args.port, debug=args.debug)

else:
kwargs = get_kwargs_from_config()

# for uWSGI use
app = init_app(
model_class={model_class},
model_dir=os.environ.get('MODEL_DIR', os.path.dirname(__file__)),
redis_queue=os.environ.get('RQ_QUEUE_NAME', 'default'),
redis_host=os.environ.get('REDIS_HOST', 'localhost'),
redis_port=os.environ.get('REDIS_PORT', 6379)
redis_port=os.environ.get('REDIS_PORT', 6379),
**kwargs
)
3 changes: 3 additions & 0 deletions label_studio_ml/default_configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"checkpoint_file": "./models/checkpoint_file_name"
}