Update API URL for Segformer model inference
Browse filesUpdated the API URL to the current Hugging Face router endpoint for the Segformer model.
102 unmodified lines103104105106107108109110111112113114102 unmodified lines# Segformer API Logic# ---------------------------------------------------------------------------def hf_segformer_cutout(image_bytes: bytes, hf_token: str, grow_px: int) -> bytes:API_URL = "https://api-inference.huggingface.co/models/mattmdjaga/segformer_b2_clothes"headers = {"Authorization": f"Bearer {hf_token}"}response = requests.post(API_URL, headers=headers, data=image_bytes)response.raise_for_status()result_json = response.json()if isinstance(result_json, dict) and "error" in result_json:raise ValueError(f"API Error: {result_json['error']}")102 unmodified lines103104105106107108109110111112113114115116102 unmodified lines# Segformer API Logic# ---------------------------------------------------------------------------def hf_segformer_cutout(image_bytes: bytes, hf_token: str, grow_px: int) -> bytes:# Updated to the current Hugging Face router endpointAPI_URL = "https://router.huggingface.co/hf-inference/models/mattmdjaga/segformer_b2_clothes"headers = {"Authorization": f"Bearer {hf_token}"}response = requests.post(API_URL, headers=headers, data=image_bytes)response.raise_for_status()result_json = response.json()if isinstance(result_json, dict) and "error" in result_json:raise ValueError(f"API Error: {result_json['error']}")
app.py+3-1