Spaces:
Sleeping
Sleeping
initial commit
Browse files- Dockerfile +16 -0
- docker-compose.yaml +12 -0
- requirements.txt +4 -0
- src/main.py +33 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
|
6 |
+
ENV HOME=/home/user \
|
7 |
+
PATH=/home/user/.local/bin:$PATH
|
8 |
+
|
9 |
+
WORKDIR $HOME/app
|
10 |
+
|
11 |
+
COPY --chown=user requirements.txt requirements.txt
|
12 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
13 |
+
|
14 |
+
COPY --chown=user . .
|
15 |
+
|
16 |
+
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
docker-compose.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
services:
|
2 |
+
server:
|
3 |
+
build:
|
4 |
+
context: .
|
5 |
+
ports:
|
6 |
+
- 7860:7860
|
7 |
+
environment:
|
8 |
+
- foo=bar
|
9 |
+
develop:
|
10 |
+
watch:
|
11 |
+
- action: rebuild
|
12 |
+
path: .
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.111.*
|
2 |
+
requests==2.*
|
3 |
+
uvicorn[standard]==0.30.*
|
4 |
+
torch
|
src/main.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
import torch
|
4 |
+
|
5 |
+
#from typing import Optional
|
6 |
+
|
7 |
+
from fastapi import FastAPI, Header, HTTPException, BackgroundTasks
|
8 |
+
from fastapi.responses import FileResponse
|
9 |
+
#from huggingface_hub.hf_api import HfApi
|
10 |
+
|
11 |
+
#from .models import config, WebhookPayload
|
12 |
+
|
13 |
+
#WEBHOOK_SECRET = os.getenv("WEBHOOK_SECRET")
|
14 |
+
#HF_ACCESS_TOKEN = os.getenv("HF_ACCESS_TOKEN")
|
15 |
+
#AUTOTRAIN_API_URL = "https://api.autotrain.huggingface.co"
|
16 |
+
#AUTOTRAIN_UI_URL = "https://ui.autotrain.huggingface.co"
|
17 |
+
|
18 |
+
|
19 |
+
app = FastAPI()
|
20 |
+
|
21 |
+
@app.get("/")
|
22 |
+
async def home():
|
23 |
+
|
24 |
+
gpu = 'GPU not available'
|
25 |
+
if torch.cuda.is_available():
|
26 |
+
gpu = 'GPU is available'
|
27 |
+
print("GPU is available")
|
28 |
+
else:
|
29 |
+
print("GPU is not available")
|
30 |
+
|
31 |
+
print('hello world')
|
32 |
+
print(os.getenv("foo"))
|
33 |
+
return {'success': True, 'response': 'hello world 3', 'gpu': gpu}
|