makakwastaken commited on
Commit
5e6d15e
·
1 Parent(s): c9be829

Use docker

Browse files
Files changed (6) hide show
  1. .dockerignore +1 -0
  2. Dockerfile +19 -0
  3. README.md +1 -1
  4. predict.py +1 -1
  5. requirements.txt +5 -5
  6. server.py +1 -8
.dockerignore ADDED
@@ -0,0 +1 @@
 
 
1
+ CutLER/
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ # Install git
6
+ RUN apt-get update && apt-get install -y git
7
+
8
+ # Install CutLER
9
+ RUN git clone --recursive https://github.com/Ad-Visual/CutLER
10
+
11
+ RUN pip install --no-cache-dir --upgrade -r /code/CutLER/requirements.txt
12
+
13
+ COPY ./requirements.txt /code/requirements.txt
14
+
15
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
+
17
+ COPY . /code
18
+
19
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -3,7 +3,7 @@ title: MaskCut
3
  emoji: 🌍
4
  colorFrom: pink
5
  colorTo: pink
6
- sdk: gradio
7
  sdk_version: 3.16.2
8
  app_file: app.py
9
  pinned: false
 
3
  emoji: 🌍
4
  colorFrom: pink
5
  colorTo: pink
6
+ sdk: docker
7
  sdk_version: 3.16.2
8
  app_file: app.py
9
  pinned: false
predict.py CHANGED
@@ -17,7 +17,7 @@ def predict(package, image_base64: str, threshold: float, num_objects: int):
17
 
18
  # We copy the image that and fill it with black, to get the dimensions
19
  rgb = np.array(canvas)
20
- model = package.get('model')
21
  masks = model(image, threshold, num_objects)
22
 
23
  for mask in masks:
 
17
 
18
  # We copy the image that and fill it with black, to get the dimensions
19
  rgb = np.array(canvas)
20
+ model : Model = package.get('model')
21
  masks = model(image, threshold, num_objects)
22
 
23
  for mask in masks:
requirements.txt CHANGED
@@ -1,12 +1,12 @@
1
  git+https://github.com/lucasb-eyer/pydensecrf
2
- gradio==3.16.2
3
- numpy==1.23.5
 
4
  opencv-python==4.6.0.66
5
- pycocotools==2.0.6
6
  scikit-image==0.19.2
7
- torch==1.13.1
8
- torchvision==0.14.1
9
  tqdm==4.64.1
 
 
10
  fastapi==0.94.0
11
  pydantic==1.8.2
12
  uvicorn==0.21.0
 
1
  git+https://github.com/lucasb-eyer/pydensecrf
2
+ torch==1.8.1
3
+ torchvision==0.9.1
4
+ numpy==1.24.2
5
  opencv-python==4.6.0.66
 
6
  scikit-image==0.19.2
 
 
7
  tqdm==4.64.1
8
+
9
+ pycocotools==2.0.6
10
  fastapi==0.94.0
11
  pydantic==1.8.2
12
  uvicorn==0.21.0
server.py CHANGED
@@ -17,9 +17,6 @@ import torch
17
  import os
18
  import sys
19
 
20
- # Server Framework
21
- import uvicorn
22
-
23
  app = FastAPI(
24
  title="AdVisual MaskCut Model",
25
  description="Description of the ML Model",
@@ -136,8 +133,4 @@ async def websocket_endpoint(websocket: WebSocket):
136
 
137
  await websocket.close()
138
  except WebSocketDisconnect:
139
- break
140
-
141
- if __name__ == '__main__':
142
- # server api
143
- uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
 
17
  import os
18
  import sys
19
 
 
 
 
20
  app = FastAPI(
21
  title="AdVisual MaskCut Model",
22
  description="Description of the ML Model",
 
133
 
134
  await websocket.close()
135
  except WebSocketDisconnect:
136
+ break