Spaces:
Runtime error
Runtime error
Download main.py from Anm5/yogafrontend: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/Anm5/yogafrontend/resolve/main/main.py
- Command line
-
hf download hf://spaces/Anm5/yogafrontend/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Anm5/yogafrontend/resolve/main/main.py
1.23 kB
| def run(image: np.ndarray, model_complexity: int, enable_segmentation: bool, | |
| min_detection_confidence: float, background_color: str) -> np.ndarray: | |
| with mp_pose.Pose( | |
| static_image_mode=True, | |
| model_complexity=model_complexity, | |
| enable_segmentation=enable_segmentation, | |
| min_detection_confidence=min_detection_confidence, | |
| ) as pose: | |
| results = pose.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) | |
| res = image.copy() | |
| if enable_segmentation and results.segmentation_mask is not None: | |
| mask = results.segmentation_mask | |
| if background_color == 'white': | |
| bg_color = (255, 255, 255) | |
| elif background_color == 'black': | |
| bg_color = (0, 0, 0) | |
| elif background_color == 'green': | |
| bg_color = (0, 255, 0) | |
| else: | |
| raise ValueError("Invalid background color") | |
| res[mask <= 0.1] = bg_color | |
| if results.pose_landmarks: | |
| mp_drawing.draw_landmarks( | |
| res, results.pose_landmarks, mp_pose.POSE_CONNECTIONS, | |
| landmark_drawing_spec=mp_drawing_styles.get_default_pose_landmarks_style() | |
| ) | |
| return res | |
| # Adapt your existing pose classification code as needed. | |