Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
Β·
e3a01f4
1
Parent(s):
dddd691
Add HEALTHCHECK and app_port
Browse files- .huggingface/space.yaml +1 -2
- Dockerfile +7 -0
- main.py +3 -3
.huggingface/space.yaml
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
sdk: docker
|
2 |
-
|
3 |
-
port: 8000
|
|
|
1 |
sdk: docker
|
2 |
+
app_port: 8000
|
|
Dockerfile
CHANGED
@@ -23,5 +23,12 @@ RUN mkdir -p /models/clip && \
|
|
23 |
RUN python3 -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('bert-base-uncased').save_pretrained('/models/bert-tokenizer')"
|
24 |
RUN python3 -c "from transformers import CLIPProcessor; CLIPProcessor.from_pretrained('openai/clip-vit-base-patch32').save_pretrained('/models/clip')"
|
25 |
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
27 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|
|
|
23 |
RUN python3 -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('bert-base-uncased').save_pretrained('/models/bert-tokenizer')"
|
24 |
RUN python3 -c "from transformers import CLIPProcessor; CLIPProcessor.from_pretrained('openai/clip-vit-base-patch32').save_pretrained('/models/clip')"
|
25 |
EXPOSE 8000
|
26 |
+
|
27 |
+
# Install curl if it's not already installed
|
28 |
+
RUN apt-get update && apt-get install -y curl
|
29 |
+
|
30 |
+
# Add the health check
|
31 |
+
HEALTHCHECK CMD curl --fail http://localhost:8000/ || exit 1
|
32 |
+
|
33 |
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
34 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|
main.py
CHANGED
@@ -20,9 +20,9 @@ app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
|
20 |
# async def landing():
|
21 |
# return Path("vit_captioning/static/landing.html").read_text()
|
22 |
|
23 |
-
@app.get("/")
|
24 |
-
def
|
25 |
-
return {"
|
26 |
|
27 |
# β
Captioning page at `/captioning`
|
28 |
@app.get("/captioning", response_class=HTMLResponse)
|
|
|
20 |
# async def landing():
|
21 |
# return Path("vit_captioning/static/landing.html").read_text()
|
22 |
|
23 |
+
@app.get("/")
|
24 |
+
def read_root():
|
25 |
+
return {"message": "β
Space is working"}
|
26 |
|
27 |
# β
Captioning page at `/captioning`
|
28 |
@app.get("/captioning", response_class=HTMLResponse)
|