Artisteve commited on
Commit
5b75ce7
·
1 Parent(s): cd247c3

created a docker file with python 3.10.9

Browse files
Files changed (6) hide show
  1. Dockerfile +11 -0
  2. Procfile +1 -0
  3. __pycache__/main.cpython-310.pyc +0 -0
  4. main.py +37 -0
  5. requirements.txt +95 -0
  6. runtime.txt +1 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
__pycache__/main.cpython-310.pyc ADDED
Binary file (1.05 kB). View file
 
main.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ from fastapi import FastAPI, UploadFile, File
4
+ from fastapi.responses import FileResponse
5
+ from fastapi.middleware.cors import CORSMiddleware
6
+
7
+ app = FastAPI()
8
+
9
+ # Set up CORS middleware
10
+ app.add_middleware(
11
+ CORSMiddleware,
12
+ allow_origins=["*"], # Allows all origins
13
+ allow_credentials=True,
14
+ allow_methods=["*"], # Allows all methods
15
+ allow_headers=["*"], # Allows all headers
16
+ )
17
+
18
+ @app.post("/experiments/remove-background/")
19
+ async def remove_background(file: UploadFile = File(...)):
20
+ input_path = f"temp/{file.filename}"
21
+ output_path = f"temp/no-bg-{file.filename}"
22
+
23
+ # Ensure the temp folder exists
24
+ os.makedirs(os.path.dirname(input_path), exist_ok=True)
25
+
26
+ # Save the uploaded file
27
+ with open(input_path, "wb") as buffer:
28
+ buffer.write(await file.read())
29
+
30
+ # Run rembg command
31
+ subprocess.run(["rembg", "i", input_path, output_path], check=True)
32
+
33
+ # Return the processed file
34
+ return FileResponse(output_path)
35
+
36
+ # import subprocess
37
+ # subprocess.run(["rembg", "i", input_path, output_path], check=True)
requirements.txt ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohttp==3.9.1
3
+ aiosignal==1.3.1
4
+ altair==5.2.0
5
+ annotated-types==0.6.0
6
+ anyio==3.7.1
7
+ async-timeout==4.0.3
8
+ asyncer==0.0.2
9
+ attrs==23.1.0
10
+ certifi==2023.11.17
11
+ charset-normalizer==3.3.2
12
+ click==8.1.7
13
+ colorama==0.4.6
14
+ coloredlogs==15.0.1
15
+ contourpy==1.2.0
16
+ cycler==0.12.1
17
+ exceptiongroup==1.2.0
18
+ fastapi==0.105.0
19
+ ffmpy==0.3.1
20
+ filelock==3.13.1
21
+ filetype==1.2.0
22
+ flatbuffers==23.5.26
23
+ fonttools==4.46.0
24
+ frozenlist==1.4.0
25
+ fsspec==2023.12.2
26
+ gradio==4.8.0
27
+ gradio_client==0.7.1
28
+ gunicorn==21.2.0
29
+ h11==0.14.0
30
+ httpcore==1.0.2
31
+ httpx==0.25.2
32
+ huggingface-hub==0.19.4
33
+ humanfriendly==10.0
34
+ idna==3.6
35
+ imageio==2.33.1
36
+ importlib-resources==6.1.1
37
+ Jinja2==3.1.2
38
+ jsonschema==4.20.0
39
+ jsonschema-specifications==2023.11.2
40
+ kiwisolver==1.4.5
41
+ lazy_loader==0.3
42
+ llvmlite==0.41.1
43
+ markdown-it-py==3.0.0
44
+ MarkupSafe==2.1.3
45
+ matplotlib==3.8.2
46
+ mdurl==0.1.2
47
+ mpmath==1.3.0
48
+ multidict==6.0.4
49
+ networkx==3.2.1
50
+ numba==0.58.1
51
+ numpy==1.26.2
52
+ onnxruntime==1.16.3
53
+ opencv-python-headless==4.8.1.78
54
+ orjson==3.9.10
55
+ packaging==23.2
56
+ pandas==2.1.4
57
+ Pillow==10.1.0
58
+ platformdirs==4.1.0
59
+ pooch==1.8.0
60
+ protobuf==4.25.1
61
+ pydantic==2.5.2
62
+ pydantic_core==2.14.5
63
+ pydub==0.25.1
64
+ Pygments==2.17.2
65
+ PyMatting==1.1.12
66
+ pyparsing==3.1.1
67
+ python-dateutil==2.8.2
68
+ python-multipart==0.0.6
69
+ pytz==2023.3.post1
70
+ PyYAML==6.0.1
71
+ referencing==0.32.0
72
+ rembg==2.0.53
73
+ requests==2.31.0
74
+ rich==13.7.0
75
+ rpds-py==0.13.2
76
+ scikit-image==0.22.0
77
+ scipy==1.11.4
78
+ semantic-version==2.10.0
79
+ shellingham==1.5.4
80
+ six==1.16.0
81
+ sniffio==1.3.0
82
+ starlette==0.27.0
83
+ sympy==1.12
84
+ tifffile==2023.12.9
85
+ tomlkit==0.12.0
86
+ toolz==0.12.0
87
+ tqdm==4.66.1
88
+ typer==0.9.0
89
+ typing_extensions==4.9.0
90
+ tzdata==2023.3
91
+ urllib3==2.1.0
92
+ uvicorn==0.24.0.post1
93
+ watchdog==3.0.0
94
+ websockets==11.0.3
95
+ yarl==1.9.4
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-3.10.9