2nzi commited on
Commit
ffb6778
·
verified ·
1 Parent(s): 55b1e30

debug backend

Browse files
Files changed (1) hide show
  1. app.py +28 -3
app.py CHANGED
@@ -235,7 +235,6 @@
235
  # # http://localhost:8000/docs#/
236
  # # (.venv) PS C:\Users\antoi\Documents\Work_Learn\Labeling-Deploy\FastAPI> uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1
237
 
238
-
239
  from fastapi import FastAPI, UploadFile, File, HTTPException
240
  import cv2
241
  import torch
@@ -430,10 +429,36 @@ def convertir_sequences_en_json(dataframe):
430
  # raise HTTPException(status_code=500, detail=f"Failed to upload or analyze video: {str(e)}")
431
 
432
 
433
- # Endpoint pour analyser la vidéo via une URL
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  @app.post("/analyze_video/")
435
  async def analyze_video(user_name: str, video_url: Optional[str] = None):
436
  try:
 
 
 
 
437
  # Assurez-vous d'avoir une URL valide à ce stade
438
  if not video_url:
439
  raise HTTPException(status_code=400, detail="No valid video URL provided.")
@@ -449,10 +474,10 @@ async def analyze_video(user_name: str, video_url: Optional[str] = None):
449
  }
450
 
451
  except Exception as e:
 
452
  raise HTTPException(status_code=500, detail=f"Failed to analyze video: {str(e)}")
453
 
454
 
455
-
456
  # Fonction pour uploader une vidéo vers un dataset Hugging Face
457
  def upload_to_hf_dataset(user_name: str, video_path: str):
458
  dataset_name = "2nzi/Video-Sequence-Labeling"
 
235
  # # http://localhost:8000/docs#/
236
  # # (.venv) PS C:\Users\antoi\Documents\Work_Learn\Labeling-Deploy\FastAPI> uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1
237
 
 
238
  from fastapi import FastAPI, UploadFile, File, HTTPException
239
  import cv2
240
  import torch
 
429
  # raise HTTPException(status_code=500, detail=f"Failed to upload or analyze video: {str(e)}")
430
 
431
 
432
+ # # Endpoint pour analyser la vidéo via une URL
433
+ # @app.post("/analyze_video/")
434
+ # async def analyze_video(user_name: str, video_url: Optional[str] = None):
435
+ # try:
436
+ # # Assurez-vous d'avoir une URL valide à ce stade
437
+ # if not video_url:
438
+ # raise HTTPException(status_code=400, detail="No valid video URL provided.")
439
+
440
+ # # Analyser la vidéo via l'URL
441
+ # dataframe_sequences = identifier_sequences_surfing(video_url, intervalle=1)
442
+ # json_result = convertir_sequences_en_json(dataframe_sequences)
443
+
444
+ # return {
445
+ # "message": "Video analyzed successfully!",
446
+ # "file_url": video_url,
447
+ # "analysis": json_result
448
+ # }
449
+
450
+ # except Exception as e:
451
+ # raise HTTPException(status_code=500, detail=f"Failed to analyze video: {str(e)}")
452
+
453
+
454
+
455
  @app.post("/analyze_video/")
456
  async def analyze_video(user_name: str, video_url: Optional[str] = None):
457
  try:
458
+ # Log for debugging purposes
459
+ print(f"Received user_name: {user_name}")
460
+ print(f"Received video_url: {video_url}")
461
+
462
  # Assurez-vous d'avoir une URL valide à ce stade
463
  if not video_url:
464
  raise HTTPException(status_code=400, detail="No valid video URL provided.")
 
474
  }
475
 
476
  except Exception as e:
477
+ print(f"Error during video analysis: {str(e)}") # Log the error
478
  raise HTTPException(status_code=500, detail=f"Failed to analyze video: {str(e)}")
479
 
480
 
 
481
  # Fonction pour uploader une vidéo vers un dataset Hugging Face
482
  def upload_to_hf_dataset(user_name: str, video_path: str):
483
  dataset_name = "2nzi/Video-Sequence-Labeling"