Spaces:
Sleeping
Sleeping
Download draft_computation/draft_computation_app/main.py from PauloFN/draft-estimation: direct link, hf CLI and curl.
- Browser
- Download file 904 Bytes
-
https://huggingface.co/spaces/PauloFN/draft-estimation/resolve/main/draft_computation/draft_computation_app/main.py
- Command line
-
hf download hf://spaces/PauloFN/draft-estimation/draft_computation/draft_computation_app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/PauloFN/draft-estimation/resolve/main/draft_computation/draft_computation_app/main.py
904 Bytes
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| import numpy as np | |
| import cv2 | |
| from draft_computation_app import calculate_draft | |
| def create_dummy_data(): | |
| """ | |
| Creates dummy data for testing. | |
| """ | |
| pose_results = np.array([ | |
| [[100, 200, 1], [100, 220, 1], [100, 240, 1], [100, 260, 1], [100, 280, 1]], | |
| [[200, 300, 1], [200, 320, 1], [200, 340, 1], [200, 360, 1], [200, 380, 1]], | |
| ]) | |
| segment_mask = np.zeros((500, 500), dtype=np.uint8) | |
| segment_mask[400:, :] = 1 # Water line at y=400 | |
| original_image = np.zeros((500, 500, 3), dtype=np.uint8) | |
| return pose_results, segment_mask, original_image | |
| if __name__ == "__main__": | |
| pose_results, segment_mask, original_image = create_dummy_data() | |
| draft = calculate_draft(pose_results, segment_mask, original_image) | |
| print(f"The draft is: {draft} meters") | |