Views
No views yet
POST https://dixisouls-scene-graph-generator.hf.space/generateimage: The image file to analyze (multipart/form-data)confidence_threshold: A value between 0 and 1 (default: 0.5)use_fixed_boxes: Boolean value (default: false)1{
2 "objects": [
3 {
4 "label": "person",
5 "label_id": 1,
6 "score": 0.91,
7 "bbox": [0.3, 0.4, 0.1, 0.3]
8 },
9 ...
10 ],
11 "relationships": [
12 {
13 "subject": "person",
14 "predicate": "riding",
15 "object": "bicycle",
16 "score": 0.82,
17 "subject_id": 0,
18 "object_id": 1,
19 "predicate_id": 5
20 },
21 ...
22 ],
23 "annotated_image": "base64_encoded_image_data",
24 "graph_image": "base64_encoded_image_data"
25}1import requests
2import base64
3from PIL import Image
4import io
5
6# Prepare the image
7image_path = "your_image.jpg"
8files = {'image': open(image_path, 'rb')}
9
10# Set parameters
11data = {
12 'confidence_threshold': 0.5,
13 'use_fixed_boxes': False
14}
15
16# Make the API call
17api_url = "https://dixisouls-scene-graph-generator.hf.space/generate"
18response = requests.post(api_url, files=files, data=data)
19
20# Process the results
21if response.status_code == 200:
22 result = response.json()
23
24 # Decode and save the images
25 annotated_image = Image.open(io.BytesIO(base64.b64decode(result['annotated_image'])))
26 annotated_image.save("annotated_image.jpg")
27
28 graph_image = Image.open(io.BytesIO(base64.b64decode(result['graph_image'])))
29 graph_image.save("graph_image.jpg")
30
31 # Print information about objects and relationships
32 print(f"Found {len(result['objects'])} objects and {len(result['relationships'])} relationships")
33else:
34 print(f"Error: {response.text}")1curl -X POST \
2 -F "image=@your_image.jpg" \
3 -F "confidence_threshold=0.5" \
4 -F "use_fixed_boxes=false" \
5 https://dixisouls-scene-graph-generator.hf.space/generate