CuriousDolphin commited on
Commit
0c5ad16
·
1 Parent(s): 28210ca

sync to huggingface

Browse files
.github/workflows/deploy_huggingface.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push --force https://CuriousDolphin:[email protected]/spaces/CuriousDolphin/DetrDetectionSegmentation main
Dockerfile CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11 as base-img
2
+ ARG DEBIAN_FRONTEND=noninteractive
3
+ RUN apt-get update && apt-get install -y python3 ffmpeg libxext6 libsm6 libgtk2.0-dev pkg-config libgtk2.0-dev libavcodec-dev python3-opencv libopencv-dev
4
+ RUN apt-get install -y python3-pip
5
+
6
+ RUN pip3 install torch torchvision
7
+
8
+ FROM base-img as app
9
+ RUN useradd -m -u 1000 user
10
+
11
+ # Switch to the "user" user
12
+ USER user
13
+
14
+ # Set home to the user's home directory
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ WORKDIR $HOME/app
19
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
20
+ COPY --chown=user requirements.txt requirements.txt
21
+ COPY --chown=user data data
22
+ COPY --chown=user detr detr
23
+ RUN pip3 install -r requirements.txt
24
+ ENTRYPOINT [ "python","detr/main_gradio.py" ]
Dockerfile.nvidia ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04 as base-img
2
+ ARG DEBIAN_FRONTEND=noninteractive
3
+ RUN apt-get update && apt-get install -y python3 ffmpeg libxext6 libsm6 libgtk2.0-dev pkg-config libgtk2.0-dev libavcodec-dev python3-opencv libopencv-dev
4
+ RUN apt-get install -y python3-pip
5
+ RUN pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu118
6
+
7
+ FROM base-img as app
8
+ WORKDIR /app
9
+ COPY requirements.txt requirements.txt
10
+ COPY data data
11
+ COPY detr detr
12
+ RUN pip3 install -r requirements.txt
13
+ ENTRYPOINT [ "python3","detr/main_gradio.py" ]
README.md CHANGED
@@ -1 +1,9 @@
1
- # detr_gradio
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: DETR (object detections & panoptic segmentation)
3
+ emoji: 🌭
4
+ sdk: docker
5
+ app_port: 7000
6
+ pinned: true
7
+ ---
8
+
9
+ # Simple DETR gradio implementation (object detections & panoptic segmentation)
detr/main_gradio.py CHANGED
@@ -42,11 +42,9 @@ with gr.Blocks() as inference_gradio:
42
 
43
  with gr.Row():
44
  start_btn = gr.Button("Start", variant="primary")
45
-
46
  with gr.Column():
47
  annotated_img = gr.Image(label="Annotated Image")
48
  speed = gr.JSON(label="speed")
49
- json_out = gr.JSON(label="output")
50
  examples = gr.Examples(
51
  examples=[
52
  [path]
@@ -59,7 +57,7 @@ with gr.Blocks() as inference_gradio:
59
  start_btn.click(
60
  fn=run_inference,
61
  inputs=[img_file, conf, model_name],
62
- outputs=[annotated_img, speed, json_out],
63
  )
64
 
65
  if __name__ == "__main__":
 
42
 
43
  with gr.Row():
44
  start_btn = gr.Button("Start", variant="primary")
 
45
  with gr.Column():
46
  annotated_img = gr.Image(label="Annotated Image")
47
  speed = gr.JSON(label="speed")
 
48
  examples = gr.Examples(
49
  examples=[
50
  [path]
 
57
  start_btn.click(
58
  fn=run_inference,
59
  inputs=[img_file, conf, model_name],
60
+ outputs=[annotated_img, speed],
61
  )
62
 
63
  if __name__ == "__main__":
docker-compose.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ detr_cpu:
3
+ build:
4
+ context: .
5
+ ports:
6
+ - 7000:7000
7
+ volumes:
8
+ - ./data:/app/data
9
+ detr_gpu:
10
+ build:
11
+ dockerfile: Dockerfile.nvidia
12
+ target: app
13
+ profiles: [ "gpu" ]
14
+ shm_size: '4gb' # pytorch dataloader crash
15
+ ports:
16
+ - 7000:7000
17
+ volumes:
18
+ - ./data:/app/data
19
+ deploy:
20
+ resources:
21
+ reservations:
22
+ devices:
23
+ - driver: nvidia
24
+ count: 1
25
+ capabilities: [ gpu ]