| import requests |
| import os |
|
|
| HF_SPACE_URL = "https://hf.space/embed/VeuReu/svision/api/" |
| HF_TOKEN = os.environ.get("HF_TOKEN") |
|
|
| def call_svision(endpoint: str, inputs: list): |
| url = HF_SPACE_URL + endpoint |
| headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {} |
| print("URL que se llama:", url) |
| print("Headers enviados:", headers) |
| response = requests.post(url, json={"data": inputs}, headers=headers) |
| response.raise_for_status() |
| return response.json()["data"] |
|
|
|
|
| def extract_scenes(video_path: str, threshold: float = 30.0, offset_frames: int = 10, crop_ratio: float = 0.1): |
| print("Extrayendo escenas...") |
| result = call_svision("scenes_extraction", [video_path, threshold, offset_frames, crop_ratio]) |
| print("Escenas extraídas.") |
| return result |
|
|