Spaces:
Sleeping
Sleeping
Miguel Cid Flor commited on
Commit ·
6b54c6f
1
Parent(s): e238ade
typos
Browse files- __pycache__/Models.cpython-312.pyc +0 -0
- __pycache__/PreProcessor.cpython-312.pyc +0 -0
- __pycache__/app.cpython-312.pyc +0 -0
- app.py +12 -2
__pycache__/Models.cpython-312.pyc
ADDED
|
Binary file (13 kB). View file
|
|
|
__pycache__/PreProcessor.cpython-312.pyc
ADDED
|
Binary file (6.98 kB). View file
|
|
|
__pycache__/app.cpython-312.pyc
ADDED
|
Binary file (2.93 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
import cv2
|
|
|
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
import base64
|
| 5 |
from io import BytesIO
|
|
@@ -9,6 +11,14 @@ from Models import ResPoseNet,transform
|
|
| 9 |
from PreProcessor import transform_data
|
| 10 |
app = FastAPI()
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Load your model
|
| 13 |
model = ResPoseNet()
|
| 14 |
model.load_state_dict(torch.load('posev0.01126.pth', map_location=torch.device('cpu')))
|
|
@@ -36,8 +46,8 @@ async def predict(request: Request):
|
|
| 36 |
img = decode_base64_image(data["image"])
|
| 37 |
processed, _ , reverse = transform_data(img,[])
|
| 38 |
|
| 39 |
-
results =
|
| 40 |
keypoints = [reverse(x,y) for x, y in results]
|
| 41 |
|
| 42 |
|
| 43 |
-
return {"keypoints": keypoints
|
|
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
import cv2
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
+
|
| 5 |
import numpy as np
|
| 6 |
import base64
|
| 7 |
from io import BytesIO
|
|
|
|
| 11 |
from PreProcessor import transform_data
|
| 12 |
app = FastAPI()
|
| 13 |
|
| 14 |
+
app.add_middleware(
|
| 15 |
+
CORSMiddleware,
|
| 16 |
+
allow_origins=["http://127.0.0.1:5500"], # The domain from which you're making the request
|
| 17 |
+
allow_credentials=True,
|
| 18 |
+
allow_methods=["*"], # Allow all HTTP methods
|
| 19 |
+
allow_headers=["*"], # Allow all headers
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
# Load your model
|
| 23 |
model = ResPoseNet()
|
| 24 |
model.load_state_dict(torch.load('posev0.01126.pth', map_location=torch.device('cpu')))
|
|
|
|
| 46 |
img = decode_base64_image(data["image"])
|
| 47 |
processed, _ , reverse = transform_data(img,[])
|
| 48 |
|
| 49 |
+
results = predict_keypoints(processed,model)
|
| 50 |
keypoints = [reverse(x,y) for x, y in results]
|
| 51 |
|
| 52 |
|
| 53 |
+
return {"keypoints": keypoints}
|