File size: 711 Bytes
68a6918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import requests

url = "http://localhost:7860/segment"
image_path = "input.png"  # Replace with your local test image path

# Define the bounding box coordinates [xmin, ymin, xmax, ymax]
# Adjust these numbers to fit your test image's target area
payload = {"bbox": "[95, 255, 190, 350]"}

with open(image_path, "rb") as f:
    files = {"file": f}
    print("Sending request to API CALL...")
    response = requests.post(url, data=payload, files=files)

if response.status_code == 200:
    with open("local_test_result.png", "wb") as out:
        out.write(response.content)
    print("Success! Segmented image saved as 'local_test_result.png'")
else:
    print(f"Error {response.status_code}: {response.text}")