Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBlenny committed Jun 8, 2022
0 parents commit 80137fa
Show file tree
Hide file tree
Showing 14 changed files with 610 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build
on:
pull_request:
push:
branches:
- main

jobs:
publish:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build
run: ./scripts/build.sh

- name: Run Test
run: docker run nuclio_lighting_flash:latest
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tag & Release

on:
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name. eg) 1.0.0 or 1.0.0-rc.1'
required: true

jobs:
release:
name: Release ${{ github.event.inputs.TAG_NAME }}
runs-on: ubuntu-latest
steps:
- name: Docker Login
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout this repository
uses: actions/[email protected]
with:
path: ${{ github.repository }}

- name: Bump version
env:
VERSION: ${{ github.event.inputs.TAG_NAME }}
DIRECTORY:
run: |
docker build . -t nuclio_lighting_flash
docker tag nuclio_lighting_flash ghcr.io/greenroom-robotics/nuclio_lighting_flash:latest
docker tag nuclio_lighting_flash ghcr.io/greenroom-robotics/nuclio_lighting_flash:${{github.event.inputs.TAG_NAME}}
docker push nuclio_lighting_flash ghcr.io/greenroom-robotics/nuclio_lighting_flash:latest
docker push nuclio_lighting_flash ghcr.io/greenroom-robotics/nuclio_lighting_flash:${{github.event.inputs.TAG_NAME}}
- name: Create a release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.TAG_NAME }}
generate_release_notes: true
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM pytorchlightning/pytorch_lightning:1.6.4-py3.9-torch1.9

COPY ./nuclio_lighting_flash /opt/nuclio

# Remote nvidia lists as they have a borked GPG
RUN rm /etc/apt/sources.list.d/nvidia-ml.list /etc/apt/sources.list.d/cuda.list

# Install opencv deps
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y

# Install lighting flash and it's deps
RUN pip install lightning-flash icevision 'lightning-flash[image]'

WORKDIR /opt/nuclio

CMD python ./test_flash_model_handler.py
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Nuclio Lighting Flash

This repo builds a base image "GreenroomRobotics/nuclio_lighting_flash" which can be used to run flash ObjectDetection models in Nuclio / CVAT


## Usage

* Use [lightningflash-efficientdet-d0](./example/lightningflash-efficientdet-d0) as a reference example
* Modify/create your own as you see fit
* Deploy it:
```bash
nuctl deploy --project-name cvat \
--path example/lightningflash-efficientdet-d0 \
--platform local
```


## Development

### Get started

In order to develop you'll want a nuclio instance running on your local machine...

* `docker-compose up` to start nuclio.
* `./scripts/build.sh` to build `ghcr.io/greenroom-robotics/nuclio_lighting_flash:latest`
* Deploy the example to your nuclio instance:

```bash
nuctl deploy --project-name cvat \
--path example/lightningflash-efficientdet-d0 \
--platform local
```

### Release a version

* Run the [Release](./.github/workflows/release.yml) workflow on github
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.3'
services:
nuclio:
container_name: nuclio
image: quay.io/nuclio/dashboard:1.8.15-amd64
restart: always
volumes:
- /tmp:/tmp
- /var/run/docker.sock:/var/run/docker.sock
environment:
NUCLIO_CHECK_FUNCTION_CONTAINERS_HEALTHINESS: 'true'
NUCLIO_DASHBOARD_DEFAULT_FUNCTION_MOUNT_MODE: 'volume'
ports:
- '8070:8070'
117 changes: 117 additions & 0 deletions example/lightningflash-efficientdet-d0/function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
metadata:
name: lightningflash-efficientdet-d0
namespace: cvat
annotations:
name: Flash - EfficientDet d0
type: detector
framework: pytorch
head: efficientdet # any flash ObjectDetector head
backbone: d0 # any flash ObjectDetector backbone
# checkpoint_path: # path to a model checkpoint
spec: |
[
{ "id": 1, "name": "person" },
{ "id": 2, "name": "bicycle" },
{ "id": 3, "name": "car" },
{ "id": 4, "name": "motorcycle" },
{ "id": 5, "name": "airplane" },
{ "id": 6, "name": "bus" },
{ "id": 7, "name": "train" },
{ "id": 8, "name": "truck" },
{ "id": 9, "name": "boat" },
{ "id":10, "name": "traffic_light" },
{ "id":11, "name": "fire_hydrant" },
{ "id":13, "name": "stop_sign" },
{ "id":14, "name": "parking_meter" },
{ "id":15, "name": "bench" },
{ "id":16, "name": "bird" },
{ "id":17, "name": "cat" },
{ "id":18, "name": "dog" },
{ "id":19, "name": "horse" },
{ "id":20, "name": "sheep" },
{ "id":21, "name": "cow" },
{ "id":22, "name": "elephant" },
{ "id":23, "name": "bear" },
{ "id":24, "name": "zebra" },
{ "id":25, "name": "giraffe" },
{ "id":27, "name": "backpack" },
{ "id":28, "name": "umbrella" },
{ "id":31, "name": "handbag" },
{ "id":32, "name": "tie" },
{ "id":33, "name": "suitcase" },
{ "id":34, "name": "frisbee" },
{ "id":35, "name": "skis" },
{ "id":36, "name": "snowboard" },
{ "id":37, "name": "sports_ball" },
{ "id":38, "name": "kite" },
{ "id":39, "name": "baseball_bat" },
{ "id":40, "name": "baseball_glove" },
{ "id":41, "name": "skateboard" },
{ "id":42, "name": "surfboard" },
{ "id":43, "name": "tennis_racket" },
{ "id":44, "name": "bottle" },
{ "id":46, "name": "wine_glass" },
{ "id":47, "name": "cup" },
{ "id":48, "name": "fork" },
{ "id":49, "name": "knife" },
{ "id":50, "name": "spoon" },
{ "id":51, "name": "bowl" },
{ "id":52, "name": "banana" },
{ "id":53, "name": "apple" },
{ "id":54, "name": "sandwich" },
{ "id":55, "name": "orange" },
{ "id":56, "name": "broccoli" },
{ "id":57, "name": "carrot" },
{ "id":58, "name": "hot_dog" },
{ "id":59, "name": "pizza" },
{ "id":60, "name": "donut" },
{ "id":61, "name": "cake" },
{ "id":62, "name": "chair" },
{ "id":63, "name": "couch" },
{ "id":64, "name": "potted_plant" },
{ "id":65, "name": "bed" },
{ "id":67, "name": "dining_table" },
{ "id":70, "name": "toilet" },
{ "id":72, "name": "tv" },
{ "id":73, "name": "laptop" },
{ "id":74, "name": "mouse" },
{ "id":75, "name": "remote" },
{ "id":76, "name": "keyboard" },
{ "id":77, "name": "cell_phone" },
{ "id":78, "name": "microwave" },
{ "id":79, "name": "oven" },
{ "id":80, "name": "toaster" },
{ "id":81, "name": "sink" },
{ "id":83, "name": "refrigerator" },
{ "id":84, "name": "book" },
{ "id":85, "name": "clock" },
{ "id":86, "name": "vase" },
{ "id":87, "name": "scissors" },
{ "id":88, "name": "teddy_bear" },
{ "id":89, "name": "hair_drier" },
{ "id":90, "name": "toothbrush" }
]
spec:
description: "head: efficientdet, backbone: d0"
runtime: 'python:3.6'
handler: main:handler
eventTimeout: 30s
build:
image: cvat/nuclio_lighting_flash
baseImage: ghcr.io/greenroom-robotics/nuclio_lighting_flash:latest

triggers:
myHttpTrigger:
maxWorkers: 2
kind: 'http'
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432 # 32MB

platform:
attributes:
restartPolicy:
name: always
maximumRetryCount: 3
mountMode: volume
117 changes: 117 additions & 0 deletions example/lightningflash-from-checkpoint/function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
metadata:
name: lightningflash-from-checkpoint
namespace: cvat
annotations:
name: Flash - From Checkout
type: detector
framework: pytorch
# head: efficientdet # any flash ObjectDetector head
# backbone: d0 # any flash ObjectDetector backbone
checkpoint_path: http://some-path-to-a-model.pt # path to a model checkpoint
spec: |
[
{ "id": 1, "name": "person" },
{ "id": 2, "name": "bicycle" },
{ "id": 3, "name": "car" },
{ "id": 4, "name": "motorcycle" },
{ "id": 5, "name": "airplane" },
{ "id": 6, "name": "bus" },
{ "id": 7, "name": "train" },
{ "id": 8, "name": "truck" },
{ "id": 9, "name": "boat" },
{ "id":10, "name": "traffic_light" },
{ "id":11, "name": "fire_hydrant" },
{ "id":13, "name": "stop_sign" },
{ "id":14, "name": "parking_meter" },
{ "id":15, "name": "bench" },
{ "id":16, "name": "bird" },
{ "id":17, "name": "cat" },
{ "id":18, "name": "dog" },
{ "id":19, "name": "horse" },
{ "id":20, "name": "sheep" },
{ "id":21, "name": "cow" },
{ "id":22, "name": "elephant" },
{ "id":23, "name": "bear" },
{ "id":24, "name": "zebra" },
{ "id":25, "name": "giraffe" },
{ "id":27, "name": "backpack" },
{ "id":28, "name": "umbrella" },
{ "id":31, "name": "handbag" },
{ "id":32, "name": "tie" },
{ "id":33, "name": "suitcase" },
{ "id":34, "name": "frisbee" },
{ "id":35, "name": "skis" },
{ "id":36, "name": "snowboard" },
{ "id":37, "name": "sports_ball" },
{ "id":38, "name": "kite" },
{ "id":39, "name": "baseball_bat" },
{ "id":40, "name": "baseball_glove" },
{ "id":41, "name": "skateboard" },
{ "id":42, "name": "surfboard" },
{ "id":43, "name": "tennis_racket" },
{ "id":44, "name": "bottle" },
{ "id":46, "name": "wine_glass" },
{ "id":47, "name": "cup" },
{ "id":48, "name": "fork" },
{ "id":49, "name": "knife" },
{ "id":50, "name": "spoon" },
{ "id":51, "name": "bowl" },
{ "id":52, "name": "banana" },
{ "id":53, "name": "apple" },
{ "id":54, "name": "sandwich" },
{ "id":55, "name": "orange" },
{ "id":56, "name": "broccoli" },
{ "id":57, "name": "carrot" },
{ "id":58, "name": "hot_dog" },
{ "id":59, "name": "pizza" },
{ "id":60, "name": "donut" },
{ "id":61, "name": "cake" },
{ "id":62, "name": "chair" },
{ "id":63, "name": "couch" },
{ "id":64, "name": "potted_plant" },
{ "id":65, "name": "bed" },
{ "id":67, "name": "dining_table" },
{ "id":70, "name": "toilet" },
{ "id":72, "name": "tv" },
{ "id":73, "name": "laptop" },
{ "id":74, "name": "mouse" },
{ "id":75, "name": "remote" },
{ "id":76, "name": "keyboard" },
{ "id":77, "name": "cell_phone" },
{ "id":78, "name": "microwave" },
{ "id":79, "name": "oven" },
{ "id":80, "name": "toaster" },
{ "id":81, "name": "sink" },
{ "id":83, "name": "refrigerator" },
{ "id":84, "name": "book" },
{ "id":85, "name": "clock" },
{ "id":86, "name": "vase" },
{ "id":87, "name": "scissors" },
{ "id":88, "name": "teddy_bear" },
{ "id":89, "name": "hair_drier" },
{ "id":90, "name": "toothbrush" }
]
spec:
description: "object detector from checkpoint"
runtime: 'python:3.6'
handler: main:handler
eventTimeout: 30s
build:
image: cvat/nuclio_lighting_flash
baseImage: ghcr.io/greenroom-robotics/nuclio_lighting_flash:latest

triggers:
myHttpTrigger:
maxWorkers: 2
kind: 'http'
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432 # 32MB

platform:
attributes:
restartPolicy:
name: always
maximumRetryCount: 3
mountMode: volume
Binary file added nuclio_lighting_flash/fixtures/giraffe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 80137fa

Please sign in to comment.