Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| STAMP_DETECTION_API = "https://point9-signature-and-stamp-detection.hf.space/api/stamp-detection" # Replace with your space URL | |
| def stamp_detection_remote(state): | |
| filename = state["filename"] | |
| path = state["temp_files"][filename] | |
| with open(path, "rb") as f: | |
| files = {"file": (filename, f, "application/octet-stream")} | |
| headers = {"Authorization": f"Bearer {os.getenv('HUGGINGFACE_API_TOKEN')}"} | |
| resp = requests.post(STAMP_DETECTION_API, files=files, headers=headers) | |
| if resp.status_code != 200: | |
| raise RuntimeError(f"Stamp detection API failed: {resp.text}") | |
| state["stamp_detection"] = resp.json() | |
| return state |