danieaneta commited on
Commit
47e51e3
·
1 Parent(s): 8d48eb7

all updates

Browse files
Files changed (4) hide show
  1. Dockerfile +11 -17
  2. app.py +3 -12
  3. depth_est.py +1 -1
  4. 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-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /test_docker
6
 
7
- # Create a directory for the Hugging Face cache
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
- # Copy the current directory contents into the container at /test_docker
12
- COPY . /test_docker
13
 
14
- # Install any needed packages specified in requirements.txt
15
- RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # Make port 8000 available to the world outside this container
18
- EXPOSE 8000
19
 
20
- # Set environment variable for the Hugging Face home directory
21
- ENV HF_HOME=/test_docker/hf_cache
22
- ENV NAME World
23
 
24
- # Run app.py when the container launches
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
- # @app.get("/depth")
9
- # async def depth(image: str):
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