Skip to content

Commit cd58249

Browse files
committed
Add CI
1 parent ac41bc6 commit cd58249

File tree

131 files changed

+179
-11321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+179
-11321
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Mirroring
2+
3+
on: [push, delete]
4+
5+
jobs:
6+
to_gitlab:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
12+
- uses: pixta-dev/repository-mirroring-action@v1
13+
with:
14+
target_repo_url:
15+
git@gitlab.talos.basic.ai:basicai/xtreme1/image-object-detection.git
16+
ssh_private_key:
17+
${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

.ops/.gitlab-ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
stages:
2+
- build-image
3+
- deploy
4+
5+
variables:
6+
APP_NAME: "image-object-detection"
7+
APP_VERSION: "0.5.1"
8+
IMAGE_NAME: $CI_REGISTRY_IMAGE
9+
IMAGE: $IMAGE_NAME:$CI_COMMIT_SHORT_SHA
10+
KUBERNETES_NAMESPACE: "basicai-xtreme1"
11+
12+
docker-build:
13+
stage: build-image
14+
tags:
15+
- docker
16+
rules:
17+
- if: $CI_COMMIT_BRANCH =~ /^dev/
18+
- if: $CI_COMMIT_BRANCH =~ /^main/
19+
- if: $CI_COMMIT_TAG
20+
variables:
21+
DOCKER_HOST: tcp://docker:2376
22+
DOCKER_TLS_CERTDIR: "/certs"
23+
DOCKER_TLS_VERIFY: 1
24+
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
25+
services:
26+
- docker:20-dind
27+
before_script:
28+
- until docker info; do sleep 1; done
29+
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
30+
script:
31+
- docker pull $IMAGE_NAME:latest || true
32+
- docker build --cache-from $IMAGE_NAME:latest -t $IMAGE_NAME:$CI_COMMIT_REF_NAME -t $IMAGE_NAME:$CI_COMMIT_SHORT_SHA -t $IMAGE_NAME:latest .
33+
- docker push $IMAGE_NAME:$CI_COMMIT_REF_NAME
34+
- docker push $IMAGE_NAME:$CI_COMMIT_SHORT_SHA
35+
- docker push $IMAGE_NAME:latest
36+
37+
.deploy:
38+
stage: deploy
39+
tags:
40+
- kubectl
41+
before_script:
42+
- cd .ops/$ENV
43+
- sed -i 's/$APP_NAME/'"$APP_NAME"'/g' deployment.yml
44+
- sed -i 's/$APP_VERSION/'"$APP_VERSION"'/g' deployment.yml
45+
- sed -i 's|$IMAGE|'"$IMAGE"'|g' deployment.yml
46+
47+
deploy-alidev:
48+
extends: .deploy
49+
rules:
50+
- if: $CI_COMMIT_BRANCH =~ /^dev/
51+
variables:
52+
ENV: alidev
53+
script:
54+
- kubectl apply -f deployment.yml -n $KUBERNETES_NAMESPACE --kubeconfig=$KUBECONFIG_ALIYUN_DEVELOPMENT

.ops/alidev/deployment.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: $APP_NAME
5+
spec:
6+
replicas: 1
7+
strategy:
8+
type: Recreate
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: xtreme1
12+
app.kubernetes.io/instance: xtreme1
13+
app.kubernetes.io/component: $APP_NAME
14+
template:
15+
metadata:
16+
labels:
17+
app.kubernetes.io/name: xtreme1
18+
app.kubernetes.io/instance: xtreme1
19+
app.kubernetes.io/component: $APP_NAME
20+
spec:
21+
nodeSelector:
22+
dedicated: model
23+
affinity:
24+
podAntiAffinity:
25+
preferredDuringSchedulingIgnoredDuringExecution:
26+
- weight: 100
27+
podAffinityTerm:
28+
labelSelector:
29+
matchExpressions:
30+
- key: "app.kubernetes.io/name"
31+
operator: In
32+
values:
33+
- xtreme1
34+
- key: "app.kubernetes.io/instance"
35+
operator: In
36+
values:
37+
- xtreme1
38+
- key: "app.kubernetes.io/component"
39+
operator: In
40+
values:
41+
- $APP_NAME
42+
topologyKey: "kubernetes.io/hostname"
43+
imagePullSecrets:
44+
- name: basicai-registry
45+
containers:
46+
- name: $APP_NAME
47+
image: $IMAGE
48+
resources:
49+
requests:
50+
memory: 1Gi
51+
cpu: 100m
52+
limits:
53+
aliyun.com/gpu-mem: 8
54+
aliyun.com/gpu-core.percentage: 50
55+
ports:
56+
- name: http
57+
containerPort: 5000
58+
---
59+
apiVersion: v1
60+
kind: Service
61+
metadata:
62+
name: $APP_NAME
63+
spec:
64+
selector:
65+
app.kubernetes.io/name: xtreme1
66+
app.kubernetes.io/instance: xtreme1
67+
app.kubernetes.io/component: $APP_NAME
68+
ports:
69+
- name: http
70+
port: 80
71+
targetPort: 5000

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
FROM basicai/xtreme1-image-object-detection:base
1+
FROM basicai/xtreme1-image-object-detection-base
2+
23
RUN pip install flask_cors
3-
COPY ./ /yolor
4-
WORKDIR /yolor/src
5-
CMD ["python","-u","server.py","--device=0","--weights=../coco80.pt","--conf-thres=0.5","--port=5000"]
4+
5+
WORKDIR /app
6+
RUN wget https://basicai-asset.s3.us-west-2.amazonaws.com/xtreme1/model/coco80.pth
7+
COPY . ./
8+
9+
WORKDIR /app/src
10+
CMD ["python", "-u", "server.py", "--device=0", "--weights=../coco80.pt", "--conf-thres=0.5", "--port=5000"]

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Image Object Detection
2+
3+
Create base image:
4+
```bash
5+
cd base_image
6+
docker build -t basicai/xtreme1-image-object-detection-base .
7+
```
8+
9+
Using base container to run model service:
10+
```bash
11+
docker run -it --rm -p 5000:5000 -v .:/app --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 -m 32G --memory-reservation 8G --cpu-shares=80 --shm-size=32G xtreme1-image-object-detection-base env LANG=C.UTF-8 /bin/bash
12+
13+
# The following commands run in the container
14+
cd /app
15+
wget https://basicai-asset.s3.us-west-2.amazonaws.com/xtreme1/model/coco80.pth
16+
17+
cd src
18+
python -u server.py --device=0 --weights=../coco80.pt --conf-thres=0.5 --port=5000
19+
20+
# Test
21+
python client_demo.py
22+
```

docker/Dockerfile_cuda_10.2 renamed to base_image/Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,23 @@ FROM nvcr.io/nvidia/pytorch:19.11-py3
22

33
USER root
44
ENV DEBIAN_FRONTEND noninteractive
5-
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
6-
RUN apt-get clean && apt-get update && apt-get install -y zip htop screen libgl1-mesa-glx net-tools lrzsz
5+
RUN apt-get clean && \
6+
apt-get update && \
7+
apt-get install -y zip htop screen libgl1-mesa-glx net-tools lrzsz
78

8-
RUN pip uninstall torch torchtext torchvision --y
9-
COPY pip.conf /etc/pip.conf
9+
RUN pip uninstall torch torchtext torchvision --y
1010
RUN pip install seaborn thop torch torchvision torchaudio
1111

1212
RUN git clone https://github.com/JunnYu/mish-cuda
13-
RUN git clone https://github.com/fbcotter/pytorch_wavelets
14-
1513
RUN cd mish-cuda && python setup.py build install --record mish-install.log
14+
15+
RUN git clone https://github.com/fbcotter/pytorch_wavelets
1616
RUN cd pytorch_wavelets && pip install .
1717

1818
WORKDIR /home
1919

2020
ENV PATH="/home/.local/bin:${PATH}"
2121

22-
#USER root
2322
RUN mkdir /logs && chmod -R 777 /logs
2423

25-
# Set a fixed model cache directory.
2624
ENV FVCORE_CACHE="/tmp"
27-

coco80.pt

-71.7 MB
Binary file not shown.

docker/Dockerfile_cuda_11.1

Lines changed: 0 additions & 25 deletions
This file was deleted.

docker/pip.conf

Lines changed: 0 additions & 9 deletions
This file was deleted.

docker/pytorch_wavelets/.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker/pytorch_wavelets/LICENSE

Lines changed: 0 additions & 28 deletions
This file was deleted.

docker/pytorch_wavelets/MANIFEST.in

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)