Spaces:
Paused
Paused
Commit
·
5d928ed
1
Parent(s):
ccd32a3
fixes
Browse files
app.py
CHANGED
@@ -32,8 +32,6 @@ async def upload(background_tasks: BackgroundTasks,
|
|
32 |
token: str = Header(...),
|
33 |
user_id: str = Body(...)):
|
34 |
|
35 |
-
logger.info(f"Uploading video {file.filename} {token} {user_id}")
|
36 |
-
|
37 |
if token != API_KEY:
|
38 |
logger.info(f"Unauthorized {token} {API_KEY}")
|
39 |
return JSONResponse(content={"message": "Unauthorized", "status": 401})
|
|
|
32 |
token: str = Header(...),
|
33 |
user_id: str = Body(...)):
|
34 |
|
|
|
|
|
35 |
if token != API_KEY:
|
36 |
logger.info(f"Unauthorized {token} {API_KEY}")
|
37 |
return JSONResponse(content={"message": "Unauthorized", "status": 401})
|
tasks.py
CHANGED
@@ -12,6 +12,8 @@ def process_video(video_path: str,vitpose: VitPose,user_id: str):
|
|
12 |
|
13 |
logger.info(f"starting task {video_path}")
|
14 |
|
|
|
|
|
15 |
|
16 |
new_file_name = video_path.split(".")[0] + "edited." + video_path.split(".")[1]
|
17 |
new_file_name = os.path.join("static", new_file_name)
|
@@ -23,6 +25,16 @@ def process_video(video_path: str,vitpose: VitPose,user_id: str):
|
|
23 |
|
24 |
logger.info(f"Video processed {annotated_video_path}")
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
with open(annotated_video_path, "rb") as f:
|
27 |
contents = f.read()
|
28 |
|
@@ -32,5 +44,3 @@ def process_video(video_path: str,vitpose: VitPose,user_id: str):
|
|
32 |
response = requests.post(url, files=files, data={"user_id":user_id,"typeMessage":"video_processed","file_name":annotated_video_path}, stream=True)
|
33 |
logger.info(f"Video sent to {url}")
|
34 |
print(response.json())
|
35 |
-
# os.remove(video_path)
|
36 |
-
# os.remove(annotated_video_path)
|
|
|
12 |
|
13 |
logger.info(f"starting task {video_path}")
|
14 |
|
15 |
+
# Create the static directory if it doesn't exist
|
16 |
+
os.makedirs("static", exist_ok=True)
|
17 |
|
18 |
new_file_name = video_path.split(".")[0] + "edited." + video_path.split(".")[1]
|
19 |
new_file_name = os.path.join("static", new_file_name)
|
|
|
25 |
|
26 |
logger.info(f"Video processed {annotated_video_path}")
|
27 |
|
28 |
+
# Add debug logging to check if the file exists
|
29 |
+
if not os.path.exists(annotated_video_path):
|
30 |
+
logger.error(f"File not found at {annotated_video_path}")
|
31 |
+
# Try to find where the file might be
|
32 |
+
logger.info(f"Current working directory: {os.getcwd()}")
|
33 |
+
# Use the output_video_path from vitpose as backup
|
34 |
+
if os.path.exists(vitpose.output_video_path):
|
35 |
+
logger.info(f"Found file at {vitpose.output_video_path}")
|
36 |
+
annotated_video_path = vitpose.output_video_path
|
37 |
+
|
38 |
with open(annotated_video_path, "rb") as f:
|
39 |
contents = f.read()
|
40 |
|
|
|
44 |
response = requests.post(url, files=files, data={"user_id":user_id,"typeMessage":"video_processed","file_name":annotated_video_path}, stream=True)
|
45 |
logger.info(f"Video sent to {url}")
|
46 |
print(response.json())
|
|
|
|