Spaces:
Sleeping
Sleeping
Amanpreet Singh
commited on
Commit
·
5a28b6c
1
Parent(s):
573e319
wasp
Browse files- .env +5 -0
- video-to-bvh-converter.ipynb +0 -189
.env
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
KAGGLE_USERNAME=amanu1234
|
2 |
+
KAGGLE_KEY=3f0c756c15be809ec4a5d38fe994f4ce
|
3 |
+
DRIVE_FOLDER_ID=1T6v7Iqc90-NA-F3I-HeHDSvEaIyFibKd
|
4 |
+
DRIVE_CREDENTIALS={"client_id":"139895089923-huvuh3go85dvt35cegmp03qc889hq2f5.apps.googleusercontent.com","project_id":"motioncapturetest-453515","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost:8080"]}
|
5 |
+
GOOGLE_SERVICE_ACCOUNT={"access_token":"ya29.a0AeXRPp5eK0IR7UOeIaD7V3ZOO37FC-rt1sD7tPtI1j4LvplLP9E7_tPG2rrUntaJHkyfmsNxoniVZvYNkzWPZm7paz65QorGwH80JdUJpZmQ4cfYHMfd0iGg66xXExIRCOHKbviIhhT-w7NwVIAThev4AThLcxv9pPoqT4rXaCgYKAYISARASFQHGX2MinmOp3txeX39z5NSXJLwLVw0175","client_id":"139895089923-huvuh3go85dvt35cegmp03qc889hq2f5.apps.googleusercontent.com","client_secret":"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","refresh_token":"1//0gWY-U2AQ2zTSCgYIARAAGBASNwF-L9IrM2ekQEbgTPYOhgcGuRds2WineBX7yvMGNZbfje4p37n_82H17dr6gZbopnMwbzLn5dw","token_expiry":"2025-03-12T18:05:22Z","token_uri":"https://oauth2.googleapis.com/token","scopes":["https://www.googleapis.com/auth/drive"]}
|
video-to-bvh-converter.ipynb
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": null,
|
6 |
-
"id": "89e3002b",
|
7 |
-
"metadata": {
|
8 |
-
"execution": {
|
9 |
-
"iopub.execute_input": "2025-03-14T05:12:16.674040Z",
|
10 |
-
"iopub.status.busy": "2025-03-14T05:12:16.673708Z",
|
11 |
-
"iopub.status.idle": "2025-03-14T05:13:18.208584Z",
|
12 |
-
"shell.execute_reply": "2025-03-14T05:13:18.207541Z"
|
13 |
-
},
|
14 |
-
"papermill": {
|
15 |
-
"duration": 61.539518,
|
16 |
-
"end_time": "2025-03-14T05:13:18.210064",
|
17 |
-
"exception": false,
|
18 |
-
"start_time": "2025-03-14T05:12:16.670546",
|
19 |
-
"status": "completed"
|
20 |
-
},
|
21 |
-
"tags": []
|
22 |
-
},
|
23 |
-
"outputs": [],
|
24 |
-
"source": [
|
25 |
-
"print(\"Notebook starting... Processing video\")\n",
|
26 |
-
"import torch\n",
|
27 |
-
"print(f\"CUDA available: {torch.cuda.is_available()}\")\n",
|
28 |
-
"if not torch.cuda.is_available():\n",
|
29 |
-
" print(\"Error: GPU not enabled!\")\n",
|
30 |
-
" raise SystemExit\n",
|
31 |
-
"\n",
|
32 |
-
"!pip install yacs filterpy\n",
|
33 |
-
"\n",
|
34 |
-
"print(\"Step 1: Setting up credentials\")\n",
|
35 |
-
"import json\n",
|
36 |
-
"from google.oauth2.credentials import Credentials\n",
|
37 |
-
"from googleapiclient.discovery import build\n",
|
38 |
-
"from googleapiclient.http import MediaFileUpload\n",
|
39 |
-
"import requests\n",
|
40 |
-
"import os\n",
|
41 |
-
"\n",
|
42 |
-
"# Your Google Service Account credentials\n",
|
43 |
-
"creds_json_str = '''{\n",
|
44 |
-
" \\\"access_token\\\": \\\"ya29.a0AeXRPp5eK0IR7UOeIaD7V3ZOO37FC-rt1sD7tPtI1j4LvplLP9E7_tPG2rrUntaJHkyfmsNxoniVZvYNkzWPZm7paz65QorGwH80JdUJpZmQ4cfYHMfd0iGg66xXExIRCOHKbviIhhT-w7NwVIAThev4AThLcxv9pPoqT4rXaCgYKAYISARASFQHGX2MinmOp3txeX39z5NSXJLwLVw0175\\\",\n",
|
45 |
-
" \\\"client_id\\\": \\\"139895089923-huvuh3go85dvt35cegmp03qc889hq2f5.apps.googleusercontent.com\\\",\n",
|
46 |
-
" \\\"client_secret\\\": \\\"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\\\",\n",
|
47 |
-
" \\\"refresh_token\\\": \\\"1//0gWY-U2AQ2zTSCgYIARAAGBASNwF-L9IrM2ekQEbgTPYOhgcGuRds2WineBX7yvMGNZbfje4p37n_82H17dr6gZbopnMwbzLn5dw\\\",\n",
|
48 |
-
" \\\"token_uri\\\": \\\"https://oauth2.googleapis.com/token\\\",\n",
|
49 |
-
" \\\"scopes\\\": [\\\"https://www.googleapis.com/auth/drive\\\"]\n",
|
50 |
-
"}'''\n",
|
51 |
-
"creds_json = json.loads(creds_json_str)\n",
|
52 |
-
"credentials = Credentials(\n",
|
53 |
-
" token=creds_json['access_token'],\n",
|
54 |
-
" refresh_token=creds_json['refresh_token'],\n",
|
55 |
-
" client_id=creds_json['client_id'],\n",
|
56 |
-
" client_secret=creds_json['client_secret'],\n",
|
57 |
-
" token_uri=creds_json['token_uri'],\n",
|
58 |
-
" scopes=creds_json['scopes']\n",
|
59 |
-
")\n",
|
60 |
-
"if credentials.expired and credentials.refresh_token:\n",
|
61 |
-
" credentials.refresh(requests.Request())\n",
|
62 |
-
"drive_service = build('drive', 'v3', credentials=credentials)\n",
|
63 |
-
"\n",
|
64 |
-
"print(\"Step 2: Downloading pipeline ZIP\")\n",
|
65 |
-
"ZIP_FILE_ID = \"1KkmkzZLDePje6O3W7u0DvA8wKQJcRg_q\" # Your pipeline.zip file ID\n",
|
66 |
-
"zip_path = \"/kaggle/working/pipeline.zip\"\n",
|
67 |
-
"try:\n",
|
68 |
-
" request = drive_service.files().get_media(fileId=ZIP_FILE_ID)\n",
|
69 |
-
" with open(zip_path, 'wb') as f:\n",
|
70 |
-
" downloader = request.execute()\n",
|
71 |
-
" f.write(downloader)\n",
|
72 |
-
"except Exception as e:\n",
|
73 |
-
" print(f\"Error downloading ZIP: {str(e)}\")\n",
|
74 |
-
" raise SystemExit\n",
|
75 |
-
"\n",
|
76 |
-
"import zipfile\n",
|
77 |
-
"extract_dir = \"/kaggle/working/pipeline\"\n",
|
78 |
-
"os.makedirs(extract_dir, exist_ok=True)\n",
|
79 |
-
"with zipfile.ZipFile(zip_path, 'r') as zip_ref:\n",
|
80 |
-
" zip_ref.extractall(extract_dir)\n",
|
81 |
-
"print(\"Pipeline ZIP extracted successfully\")\n",
|
82 |
-
"\n",
|
83 |
-
"print(\"Step 3: Finding and downloading a video from folder\")\n",
|
84 |
-
"FOLDER_ID = \"1T6v7Iqc90-NA-F3I-HeHDSvEaIyFibKd\"\n",
|
85 |
-
"query = f\"'{FOLDER_ID}' in parents and (mimeType='video/mp4' or mimeType='video/avi' or mimeType='video/quicktime')\"\n",
|
86 |
-
"response = drive_service.files().list(q=query, fields=\"files(id, name)\", pageSize=1).execute()\n",
|
87 |
-
"files = response.get('files', [])\n",
|
88 |
-
"\n",
|
89 |
-
"if not files:\n",
|
90 |
-
" print(f\"Error: No video files found in folder {FOLDER_ID}\")\n",
|
91 |
-
" raise SystemExit\n",
|
92 |
-
"\n",
|
93 |
-
"video_file = files[0]\n",
|
94 |
-
"video_id = video_file['id']\n",
|
95 |
-
"video_name = video_file['name']\n",
|
96 |
-
"video_url = f\"https://drive.google.com/uc?id={video_id}\"\n",
|
97 |
-
"print(f\"Found video: {video_name} (ID: {video_id})\")\n",
|
98 |
-
"\n",
|
99 |
-
"response = requests.get(video_url)\n",
|
100 |
-
"if response.status_code != 200:\n",
|
101 |
-
" print(f\"Error downloading video: {response.status_code}\")\n",
|
102 |
-
" raise SystemExit\n",
|
103 |
-
"video_path = os.path.join(extract_dir, \"input_video.mp4\")\n",
|
104 |
-
"with open(video_path, 'wb') as f:\n",
|
105 |
-
" f.write(response.content)\n",
|
106 |
-
"print(f\"Video downloaded to {video_path}, size: {os.path.getsize(video_path)} bytes\")\n",
|
107 |
-
"\n",
|
108 |
-
"print(\"Step 4: Verifying video with OpenCV\")\n",
|
109 |
-
"import cv2\n",
|
110 |
-
"cap = cv2.VideoCapture(video_path)\n",
|
111 |
-
"if not cap.isOpened():\n",
|
112 |
-
" print(f\"Error: OpenCV cannot open {video_path}\")\n",
|
113 |
-
" print(f\"File exists: {os.path.exists(video_path)}\")\n",
|
114 |
-
" print(f\"File size: {os.path.getsize(video_path) if os.path.exists(video_path) else 'N/A'} bytes\")\n",
|
115 |
-
" raise SystemExit\n",
|
116 |
-
"print(f\"Video verified: {video_path}, frames: {int(cap.get(cv2.CAP_PROP_FRAME_COUNT))}\")\n",
|
117 |
-
"cap.release()\n",
|
118 |
-
"\n",
|
119 |
-
"print(\"Step 5: Running pipeline\")\n",
|
120 |
-
"os.chdir(extract_dir)\n",
|
121 |
-
"import subprocess\n",
|
122 |
-
"cmd = ['python', 'pipeline.py', '-v', video_path]\n",
|
123 |
-
"process = subprocess.run(cmd, capture_output=True, text=True)\n",
|
124 |
-
"print(\"pipeline.py output:\", process.stdout)\n",
|
125 |
-
"if process.stderr:\n",
|
126 |
-
" print(\"pipeline.py errors:\", process.stderr)\n",
|
127 |
-
"if process.returncode != 0:\n",
|
128 |
-
" print(f\"Error running pipeline.py (return code: {process.returncode})\")\n",
|
129 |
-
" raise SystemExit\n",
|
130 |
-
"print(\"Pipeline executed successfully\")\n",
|
131 |
-
"\n",
|
132 |
-
"print(\"Step 6: Uploading BVH\")\n",
|
133 |
-
"bvh_path = os.path.join(extract_dir, \"outputs\", \"bvh\", \"output.bvh\")\n",
|
134 |
-
"if os.path.exists(bvh_path):\n",
|
135 |
-
" file_metadata = {'name': 'output.bvh', 'parents': ['1T6v7Iqc90-NA-F3I-HeHDSvEaIyFibKd']}\n",
|
136 |
-
" media = MediaFileUpload(bvh_path, resumable=True)\n",
|
137 |
-
" file = drive_service.files().create(body=file_metadata, media_body=media, fields='id').execute()\n",
|
138 |
-
" drive_service.permissions().create(fileId=file['id'], body={'type': 'anyone', 'role': 'reader'}).execute()\n",
|
139 |
-
" bvh_url = f\"https://drive.google.com/uc?id={file['id']}\"\n",
|
140 |
-
" print(f\"BVH URL: {bvh_url}\")\n",
|
141 |
-
"else:\n",
|
142 |
-
" print(\"Error: BVH file not generated\")\n",
|
143 |
-
" raise SystemExit"
|
144 |
-
]
|
145 |
-
}
|
146 |
-
],
|
147 |
-
"metadata": {
|
148 |
-
"kaggle": {
|
149 |
-
"accelerator": "gpu",
|
150 |
-
"dataSources": [],
|
151 |
-
"dockerImageVersionId": 30919,
|
152 |
-
"isGpuEnabled": true,
|
153 |
-
"isInternetEnabled": true,
|
154 |
-
"language": "python",
|
155 |
-
"sourceType": "notebook"
|
156 |
-
},
|
157 |
-
"kernelspec": {
|
158 |
-
"display_name": "Python 3",
|
159 |
-
"language": "python",
|
160 |
-
"name": "python3"
|
161 |
-
},
|
162 |
-
"language_info": {
|
163 |
-
"codemirror_mode": {
|
164 |
-
"name": "ipython",
|
165 |
-
"version": 3
|
166 |
-
},
|
167 |
-
"file_extension": ".py",
|
168 |
-
"mimetype": "text/x-python",
|
169 |
-
"name": "python",
|
170 |
-
"nbconvert_exporter": "python",
|
171 |
-
"pygments_lexer": "ipython3",
|
172 |
-
"version": "3.10.12"
|
173 |
-
},
|
174 |
-
"papermill": {
|
175 |
-
"default_parameters": {},
|
176 |
-
"duration": 65.17859,
|
177 |
-
"end_time": "2025-03-14T05:13:19.233309",
|
178 |
-
"environment_variables": {},
|
179 |
-
"exception": null,
|
180 |
-
"input_path": "__notebook__.ipynb",
|
181 |
-
"output_path": "__notebook__.ipynb",
|
182 |
-
"parameters": {},
|
183 |
-
"start_time": "2025-03-14T05:12:14.054719",
|
184 |
-
"version": "2.6.0"
|
185 |
-
}
|
186 |
-
},
|
187 |
-
"nbformat": 4,
|
188 |
-
"nbformat_minor": 5
|
189 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|