Spaces:
Runtime error
Runtime error
fixing docker to accept saving files
Browse files- Dockerfile +0 -1
- server.py +10 -1
Dockerfile
CHANGED
@@ -5,7 +5,6 @@ WORKDIR /code
|
|
5 |
COPY ./requirements.txt /code/requirements.txt
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
-
RUN apt update && apt install -y ffmpeg
|
9 |
|
10 |
RUN useradd -m -u 1000 user
|
11 |
USER user
|
|
|
5 |
COPY ./requirements.txt /code/requirements.txt
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
8 |
|
9 |
RUN useradd -m -u 1000 user
|
10 |
USER user
|
server.py
CHANGED
@@ -27,6 +27,7 @@ async def dominant_color(file: UploadFile = File(...), num_colors: int = Form(..
|
|
27 |
"""
|
28 |
Receive an image file and an integer and return the dominant color(s).
|
29 |
"""
|
|
|
30 |
file_content = await file.read()
|
31 |
image_bytes = io.BytesIO(file_content)
|
32 |
im = Image.open(image_bytes)
|
@@ -97,13 +98,21 @@ async def recolor(file: UploadFile = File(...), colors: str = Form(...), model:
|
|
97 |
recolorPaletteBasedTransfer.recolor(image_np, colors)
|
98 |
img_file = open("./result.jpg", "rb")
|
99 |
return StreamingResponse(img_file, media_type="image/jpeg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
import uvicorn
|
106 |
-
|
|
|
107 |
|
108 |
|
109 |
|
|
|
27 |
"""
|
28 |
Receive an image file and an integer and return the dominant color(s).
|
29 |
"""
|
30 |
+
print('num_colors: ', num_colors)
|
31 |
file_content = await file.read()
|
32 |
image_bytes = io.BytesIO(file_content)
|
33 |
im = Image.open(image_bytes)
|
|
|
98 |
recolorPaletteBasedTransfer.recolor(image_np, colors)
|
99 |
img_file = open("./result.jpg", "rb")
|
100 |
return StreamingResponse(img_file, media_type="image/jpeg")
|
101 |
+
@app.get("/test/")
|
102 |
+
async def test():
|
103 |
+
"""
|
104 |
+
Test endpoint to check if the server is running.
|
105 |
+
"""
|
106 |
+
return {"message": "Server is running"}
|
107 |
+
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
if __name__ == "__main__":
|
113 |
import uvicorn
|
114 |
+
print("Server is running")
|
115 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
116 |
|
117 |
|
118 |
|