Spaces:
Sleeping
Sleeping
Update app.py
Browse filessauvegarde csv dans dataset hugging face
app.py
CHANGED
@@ -624,3 +624,29 @@ async def annotate(
|
|
624 |
except Exception as e:
|
625 |
raise HTTPException(status_code=500, detail=str(e))
|
626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
except Exception as e:
|
625 |
raise HTTPException(status_code=500, detail=str(e))
|
626 |
|
627 |
+
|
628 |
+
@app.post("/upload_csv/")
|
629 |
+
async def upload_csv(
|
630 |
+
video_path: str = Form(...)
|
631 |
+
):
|
632 |
+
try:
|
633 |
+
target_dir = UPLOAD_DIR
|
634 |
+
csv_filename = Path(video_path).stem + ".csv"
|
635 |
+
csv_path = target_dir / csv_filename
|
636 |
+
|
637 |
+
if not csv_path.exists():
|
638 |
+
raise HTTPException(status_code=404, detail="Le fichier CSV n'existe pas.")
|
639 |
+
|
640 |
+
# 🔥 Upload vers Hugging Face
|
641 |
+
api.upload_file(
|
642 |
+
path_or_fileobj=str(csv_path),
|
643 |
+
path_in_repo=f"csv/{csv_filename}",
|
644 |
+
repo_id=DATASET_REPO,
|
645 |
+
repo_type="dataset",
|
646 |
+
token=HF_TOKEN,
|
647 |
+
)
|
648 |
+
|
649 |
+
return {"message": "Fichier CSV uploadé avec succès.", "csv_path": str(csv_path)}
|
650 |
+
|
651 |
+
except Exception as e:
|
652 |
+
raise HTTPException(status_code=500, detail=str(e))
|