Video_sampling scripts added - #16
Conversation
yashsuman15
commented
Oct 2, 2025
- created SDKPython subdir in labellerr
- added utils/client_utils
- added video_sampling/pyscene_detect.py
test: Add integration tests for Labellerr SDK
This commit introduces integration tests for core SDK functionalities:
Features tested:
- Project creation with multiple annotation types:
* Polygon annotations
* Bounding box detection
* Classification (select, dropdown, radio)
* Text input fields
* Combined annotation types
- Project export functionality
- Pre-annotation upload support (COCO JSON format)
Test structure:
/tests
/integration
- Create_Project.py # Project creation test cases
- Export_project.py # Export functionality tests
- Pre_annotation.py # Pre-annotation upload tests
- main.py # Test runner
- cred.py # Credentials config (gitignored)
Requirements:
- Valid API credentials in cred.py
- Test image dataset in test_img/
- Sample annotations in annotations.json
Note: Remember to update cred.py with valid credentials before running tests
-removed __pychace__ -added .gitignore
- added utils/client_utils - added video_sampling/pyscene_detect.py
- add videointelligence module in requirements
| import os | ||
| import cv2 | ||
| from PIL import Image | ||
| from dataclasses import dataclass, asdict |
| mapping = { | ||
| "file_id": result.file_id, | ||
| "output_folder": result.output_folder, | ||
| "total_frames": result.total_frames, | ||
| "total_selected_frames": len(result.selected_frames), | ||
| "detection_method": "Google Cloud Video Intelligence API - Shot Change Detection", |
There was a problem hiding this comment.
use pydantic's model dump
| selected_frames: List[SceneFrame] | ||
|
|
||
|
|
||
| class GeminiSceneDetect: |
There was a problem hiding this comment.
create all singleton classes
| # video_path=video_path, | ||
| # file_id="video_001", | ||
| # credentials_path=cred_json_path # Uses GOOGLE_APPLICATION_CREDENTIALS env var | ||
| # ) |
There was a problem hiding this comment.
detector should know the attrs of the labellerr_file, so that if it requires, video_path, file_id, or frames etc whatever, it can access from the labellerr_file instance itself
| class GeminiSceneDetect: | ||
| """Google Cloud Video Intelligence API scene detection and frame extraction.""" | ||
|
|
||
| def __init__(self, video_path: str, file_id: str, gcs_uri: Optional[str] = None, credentials_path: Optional[str] = None): |
There was a problem hiding this comment.
gcs_uri shouldn't be required in the constructor
| """ | ||
| features = [videointelligence.Feature.SHOT_CHANGE_DETECTION] | ||
|
|
||
| if self.gcs_uri: |
There was a problem hiding this comment.
gcs uri will only be used if the user is using Labellerr's gemini model. For files > 10 mb, and if user is using his own svc account, then we raise an error.
| credentials_path: Path to service account JSON key file. | ||
| If None, uses GOOGLE_APPLICATION_CREDENTIALS environment variable |
There was a problem hiding this comment.
if any svc account file is provided then 10 mb limit is enforced, if not provided then copy the video file to gcs, then send the gcs_uri path to gemini (to be done, when we move this code to the DataOps repo)
| success_count = 0 | ||
| failed_frames = [] | ||
|
|
||
| print(f"Downloading {len(frames_data)} frames to: {save_path}") |
There was a problem hiding this comment.
use multithreading to download all the frames
| # https://api.labellerr.com/data/file_data?file_id=c44f38f6-0186-436f-8c2d-ffb50a539c76&include_answers=false&project_id=gabrila_artificial_duck_74237&uuid=1d4c9b58-c6a4-4ca8-9583-b6b6cd25ef12 | ||
|
|
||
|
|
||
| class FileMetadataService: |
There was a problem hiding this comment.
move this to services/labellerr_files/init.py
| import subprocess | ||
| import os | ||
|
|
||
| class FFMPEG: |
There was a problem hiding this comment.
make it FFMPEGSceneDetect
…SDKPython into feature/LABIMP-7672
yashsuman15
left a comment
There was a problem hiding this comment.
Modify the scripts based on comments
There was a problem hiding this comment.
add versioninig to each requirement
yashsuman15
left a comment
There was a problem hiding this comment.
can you help me how can i implement limit in scene detections file based on density (which you have me told earlier)
currently all the scene change are extracted and i need to select only specific numbers of that.
added the updated client.py added the restructure files
Refactor video sampling services to include dataset ID in output folder structure - Updated FFMPEGSceneDetect to derive dataset ID from video path and include it in the output folder. - Modified PySceneDetect to incorporate dataset ID in the output folder structure. - Adjusted SSIMSceneDetect to also use dataset ID for organizing output folders.
|
Comments on the notebook -
Where is the boilerplate code for using the frames to create ImageDataset from the frames ?
|
…ataset and update related methods in SDK notebook - Updated import statements in __init__.py and SDK.ipynb to reflect the new class name. - Renamed method process_all_videos() to download() in LabellerrDataset class. - Adjusted SDK notebook to use the new download() method for processing videos. - Corrected dataset directory path in SDK notebook. - Added sections for project creation and image dataset handling in the SDK notebook.