Upload 16 files
Browse files
api.py
CHANGED
|
@@ -23,6 +23,10 @@ app.add_middleware(
|
|
| 23 |
|
| 24 |
ROOT = Path("/tmp/veureu")
|
| 25 |
ROOT.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
@app.get("/")
|
| 28 |
def root():
|
|
@@ -41,6 +45,37 @@ async def process_video(
|
|
| 41 |
result = process_video_pipeline(str(tmp_video), config_path=config_path, out_root=out_root, db_dir=db_dir)
|
| 42 |
return JSONResponse(result)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
@app.post("/load_casting")
|
| 45 |
async def load_casting(
|
| 46 |
faces_dir: str = Form("identities/faces"),
|
|
|
|
| 23 |
|
| 24 |
ROOT = Path("/tmp/veureu")
|
| 25 |
ROOT.mkdir(parents=True, exist_ok=True)
|
| 26 |
+
TEMP_ROOT = Path("/tmp/temp")
|
| 27 |
+
TEMP_ROOT.mkdir(parents=True, exist_ok=True)
|
| 28 |
+
VIDEOS_ROOT = Path("/tmp/data/videos")
|
| 29 |
+
VIDEOS_ROOT.mkdir(parents=True, exist_ok=True)
|
| 30 |
|
| 31 |
@app.get("/")
|
| 32 |
def root():
|
|
|
|
| 45 |
result = process_video_pipeline(str(tmp_video), config_path=config_path, out_root=out_root, db_dir=db_dir)
|
| 46 |
return JSONResponse(result)
|
| 47 |
|
| 48 |
+
@app.post("/create_initial_casting")
|
| 49 |
+
async def create_initial_casting(
|
| 50 |
+
video: UploadFile = File(...),
|
| 51 |
+
epsilon: float = Form(...),
|
| 52 |
+
min_cluster_size: int = Form(...),
|
| 53 |
+
):
|
| 54 |
+
# Guardar v铆deo en carpeta de datos
|
| 55 |
+
video_name = Path(video.filename).stem
|
| 56 |
+
dst_video = VIDEOS_ROOT / f"{video_name}.mp4"
|
| 57 |
+
with dst_video.open("wb") as f:
|
| 58 |
+
shutil.copyfileobj(video.file, f)
|
| 59 |
+
|
| 60 |
+
# Crear estructura de carpetas en temp/<uploaded-video>/...
|
| 61 |
+
base = TEMP_ROOT / video_name
|
| 62 |
+
for sub in ("sources", "faces", "voices", "backgrounds"):
|
| 63 |
+
(base / sub).mkdir(parents=True, exist_ok=True)
|
| 64 |
+
|
| 65 |
+
# Aqu铆 en el futuro se puede disparar la l贸gica real de detecci贸n
|
| 66 |
+
return {
|
| 67 |
+
"ok": True,
|
| 68 |
+
"video": str(dst_video),
|
| 69 |
+
"epsilon": float(epsilon),
|
| 70 |
+
"min_cluster_size": int(min_cluster_size),
|
| 71 |
+
"temp_dirs": {
|
| 72 |
+
"sources": str(base / "sources"),
|
| 73 |
+
"faces": str(base / "faces"),
|
| 74 |
+
"voices": str(base / "voices"),
|
| 75 |
+
"backgrounds": str(base / "backgrounds"),
|
| 76 |
+
},
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
@app.post("/load_casting")
|
| 80 |
async def load_casting(
|
| 81 |
faces_dir: str = Form("identities/faces"),
|