Media Gen SolutionSupported image utilities

Adetailer API

Automatically fix faces and hands using Adetailer

OctoAI’s Adetailer API supports various detection models. Whether you’re interested in identifying faces, or hands, you can choose from options such as face_yolov8n, hand_yolov8n, face_full_mediapipe, face_short_mediapipe, face_mesh_mediapipe, and eyes_mesh_mediapipe. This allows you to tailor the detailing process to your specific needs and preferences.

Adetailer effortlessly identifies faces and hands in images, automatically creating masks to fill in any missing parts. After this, it seamlessly integrates with the SDXL API, applying customized settings to achieve outstanding results. Additionally, OctoAI’s Adetailer API offers flexibility by allowing users to set the maximum number of detections. For example, if there are five people in an image but you only want to focus on two faces, you can easily do so using the max_num_detections parameter. The API prioritizes and corrects faces based on their confidence score and bounding box dimensions.

Python
1import requests
2import json
3import os
4import base64
5import time
6import io
7import PIL.Image
8
9def _process_test(url):
10 image = PIL.Image.open("woman.jpg")
11
12 # Create a BytesIO buffer to hold the image data
13 image_buffer = io.BytesIO()
14 image.save(image_buffer, format='JPEG')
15 image_bytes = image_buffer.getvalue()
16 encoded_image = base64.b64encode(image_bytes).decode('utf-8')
17
18
19 OCTOAI_TOKEN = os.environ.get("OCTOAI_TOKEN")
20
21 payload = {
22 "prompt": "photorealistic, award winning, 8K HDR, best quality, breathtaking",
23 "negative_prompt": "worst quality, bad face, drawing, unrealistic, ugly face, animated",
24 "cfg_scale": 6,
25 "sampler": "DPM_2_ANCESTRAL",
26 "steps": 60,
27 "checkpoint": "RealVisXL",
28 "inpainting_base_model": "sdxl",
29 "style_preset": "base",
30 "detector": "face_yolov8n",
31 "strength": 0.5,
32 "init_image": encoded_image
33 }
34 headers = {
35 "Authorization": f"Bearer {OCTOAI_TOKEN}",
36 "Content-Type": "application/json",
37 "X-OctoAI-Queue-Dispatch": "true"
38 }
39
40 response = requests.post(url, headers=headers, json=payload)
41
42 if response.status_code != 200:
43 print(response.text)
44 print(response.json())
45
46 img_info = response.json()
47 img_bytes = base64.b64decode(img_info["image_b64"])
48 img = PIL.Image.open(io.BytesIO(img_bytes))
49 img.load()
50 img.save(f"result_image.jpg")
51
52if __name__ == "__main__":
53 _process_test("https://image.octoai.run/adetailer")