Spaces:
Sleeping
Sleeping
danieaneta
commited on
Commit
·
47e51e3
1
Parent(s):
8d48eb7
all updates
Browse files- Dockerfile +11 -17
- app.py +3 -12
- depth_est.py +1 -1
- img3-small.jpg +0 -0
Dockerfile
CHANGED
|
@@ -1,28 +1,22 @@
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
-
|
| 5 |
-
WORKDIR /test_docker
|
| 6 |
|
| 7 |
-
|
| 8 |
-
# Ensure it's writable by setting broad permissions
|
| 9 |
-
RUN mkdir -p /test_docker/hf_cache && chmod -R 777 /test_docker/hf_cache
|
| 10 |
|
| 11 |
-
|
| 12 |
-
COPY . /test_docker
|
| 13 |
|
| 14 |
-
|
| 15 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
-
|
| 18 |
-
EXPOSE 8000
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
ENV NAME World
|
| 23 |
|
| 24 |
-
|
| 25 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
| 26 |
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
|
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.9
|
| 3 |
|
| 4 |
+
WORKDIR /code
|
|
|
|
| 5 |
|
| 6 |
+
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
|
| 9 |
|
| 10 |
+
RUN useradd user
|
|
|
|
| 11 |
|
| 12 |
+
USER user
|
|
|
|
| 13 |
|
| 14 |
+
ENV HOME=/home/user \
|
| 15 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
|
| 16 |
|
| 17 |
+
WORKDIR $HOME/app
|
|
|
|
| 18 |
|
| 19 |
+
COPY --chown=user . $HOME/app
|
| 20 |
+
CMD ['uvicorn', "app:app", "--host", "0,0,0,0", "--port", "7860"]
|
| 21 |
|
| 22 |
|
app.py
CHANGED
|
@@ -5,18 +5,9 @@ import base64
|
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
# depth_base64 = DepthEstimation(image).run_depth()
|
| 12 |
-
# return {"output": depth_base64}
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# @app.get("/depth")
|
| 16 |
-
# async def depth(file: UploadFile):
|
| 17 |
-
|
| 18 |
-
# depth_base64 = DepthEstimation(File).run_depth()
|
| 19 |
-
# return {"output": depth_base64}
|
| 20 |
|
| 21 |
@app.post("/depth")
|
| 22 |
async def depth(file: UploadFile):
|
|
|
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def home():
|
| 10 |
+
return {"message":"Hello World"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
@app.post("/depth")
|
| 13 |
async def depth(file: UploadFile):
|
depth_est.py
CHANGED
|
@@ -7,7 +7,7 @@ import numpy as np
|
|
| 7 |
import os
|
| 8 |
|
| 9 |
|
| 10 |
-
os.environ['HF_HOME'] = '/hf_cache'
|
| 11 |
|
| 12 |
def convert_img_base64(img):
|
| 13 |
with open(img, 'rb') as file:
|
|
|
|
| 7 |
import os
|
| 8 |
|
| 9 |
|
| 10 |
+
# os.environ['HF_HOME'] = '/hf_cache'
|
| 11 |
|
| 12 |
def convert_img_base64(img):
|
| 13 |
with open(img, 'rb') as file:
|
img3-small.jpg
ADDED
|