### GET /health Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Checks the service health, including GPU status and loaded models. ```APIDOC ## GET /health ### Description Service health check with GPU status. ### Method GET ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/health ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -s https://apim-ai-apis.azure-api.net/v1/image/health \ -H "Authorization: Bearer YOUR_KEY" ``` ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "healthy"). - **gpu** (object) - Information about the GPU status. - **name** (string) - The name of the GPU. - **vram_total_mb** (integer) - Total VRAM in megabytes. - **vram_used_mb** (integer) - Used VRAM in megabytes. - **vram_free_mb** (integer) - Free VRAM in megabytes. - **models** (object) - Status of loaded deep learning models. - **birefnet** (string) - Status of BiRefNet model. - **realesrgan** (string) - Status of Real-ESRGAN model. - **gfpgan** (string) - Status of GFPGAN model. #### Response Example ```json { "status": "healthy", "gpu": { "name": "NVIDIA A10", "vram_total_mb": 24576, "vram_used_mb": 1422, "vram_free_mb": 23154 }, "models": { "birefnet": "loaded", "realesrgan": "loaded", "gfpgan": "loaded" } } ``` ``` -------------------------------- ### GET /health Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Checks the health status of the image processing service, including GPU information. ```APIDOC ## GET /health ### Description Checks the health status of the image processing service. It returns information about the service status and GPU utilization. ### Method GET ### Endpoint /v1/image/health ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -s "https://apim-ai-apis.azure-api.net/v1/image/health" \ -H "Authorization: Bearer YOUR_KEY" ``` ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "ok"). - **gpu** (object) - Information about the GPU. - **name** (string) - The name of the GPU. - **vram_used_mb** (integer) - The amount of VRAM used in MB. - **vram_total_mb** (integer) - The total amount of VRAM in MB. #### Response Example ```json { "status": "ok", "gpu": { "name": "NVIDIA GeForce RTX 3090", "vram_used_mb": 8192, "vram_total_mb": 24576 } } ``` ``` -------------------------------- ### Remove Background from Image (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image using the BiRefNet model. This endpoint accepts multipart/form-data and returns a PNG image with a transparent background. Ensure you have the 'requests' library installed. ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("photo.jpg", "rb")} ) with open("result.png", "wb") as f: f.write(response.content) ``` -------------------------------- ### Available Models Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This section lists the image processing models available through the API, their versions, VRAM requirements, and a brief description of their functionality. ```APIDOC ## Models This endpoint provides information about the available image processing models. ### Method GET ### Endpoint /models ### Parameters None ### Response #### Success Response (200) - **models** (array) - A list of available models. - **model** (string) - The name of the model. - **version** (string) - The version of the model. - **vram** (string) - The VRAM required by the model. - **description** (string) - A description of the model's functionality. #### Response Example ```json { "models": [ { "model": "BiRefNet", "version": "latest", "vram": "~850 MB", "description": "Bilateral Reference Network for salient object detection" }, { "model": "Real-ESRGAN", "version": "x4plus", "vram": "~300 MB", "description": "Enhanced Super-Resolution GAN for 4x upscaling" }, { "model": "GFPGAN", "version": "v1.3", "vram": "~260 MB", "description": "Generative Facial Prior GAN for blind face restoration" } ] } ``` ``` -------------------------------- ### POST /restore-face/base64 Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores and enhances faces using base64 encoding for both input and output. ```APIDOC ## POST /restore-face/base64 ### Description Restore and enhance faces using GFPGAN v1.3 with base64 input/output. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/restore-face/base64 ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** (string) - Required - Base64 encoded image string. ### Request Example ```python import requests import base64 with open("blurry.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("restored.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### Response #### Success Response (200) - **image** (string) - Base64 encoded image string with restored faces. #### Response Example ```json { "image": "base64_encoded_result" } ``` ``` -------------------------------- ### JavaScript: Image Background Removal, Upscaling, and Face Restoration Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This JavaScript code demonstrates how to perform background removal, image upscaling, and face restoration using the BrainiAll Image API. It utilizes the 'fetch' API and requires an API key. The functions handle file input/output and base64 encoding for background removal. ```javascript import fs from "fs"; const BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image"; const API_KEY = "YOUR_KEY"; async function removeBackground(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/remove-background`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Background removed: ${outputPath}`); } async function upscaleImage(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/upscale`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Upscaled: ${outputPath}`); } async function restoreFace(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/restore-face`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Face restored: ${outputPath}`); } async function removeBackgroundBase64(inputPath, outputPath) { const imageBuffer = fs.readFileSync(inputPath); const imageB64 = imageBuffer.toString("base64"); const response = await fetch(`${BASE_URL}/remove-background/base64`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${API_KEY}`, }, body: JSON.stringify({ image: imageB64 }), }); const result = await response.json(); fs.writeFileSync(outputPath, Buffer.from(result.image, "base64")); console.log(`Background removed (base64): ${outputPath}`); } async function checkHealth() { const response = await fetch(`${BASE_URL}/health`, { headers: { Authorization: `Bearer ${API_KEY}` }, }); const health = await response.json(); console.log(`Status: ${health.status}`); console.log(`GPU: ${health.gpu.name}`); console.log( `VRAM: ${health.gpu.vram_used_mb}MB / ${health.gpu.vram_total_mb}MB` ); } // Usage: // await removeBackground("photo.jpg", "nobg.png"); // await upscaleImage("small.jpg", "upscaled.png"); // await restoreFace("blurry.jpg", "restored.png"); // await checkHealth(); ``` -------------------------------- ### POST /upscale/base64 Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an image by 4x using base64 encoding for both input and output. ```APIDOC ## POST /upscale/base64 ### Description Upscale an image by 4x using Real-ESRGAN x4plus with base64 input/output. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/upscale/base64 ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** (string) - Required - Base64 encoded image string. ### Request Example ```python import requests import base64 with open("small.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("upscaled.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### Response #### Success Response (200) - **image** (string) - Base64 encoded upscaled image string. #### Response Example ```json { "image": "base64_encoded_result" } ``` ``` -------------------------------- ### POST /upscale Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an image by 4x using the Real-ESRGAN x4plus model. Accepts multipart/form-data and returns a PNG image at 4x resolution. ```APIDOC ## POST /upscale ### Description Upscale an image by 4x using Real-ESRGAN x4plus. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/upscale ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to upscale. ### Request Example ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("small.jpg", "rb")} ) with open("upscaled.png", "wb") as f: f.write(response.content) ``` ### Response #### Success Response (200) - **image** (PNG) - The upscaled image (4x resolution). #### Response Example (Binary PNG data) ``` -------------------------------- ### POST /upscale Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an image by 4x using the Real-ESRGAN model. Accepts multipart form data. ```APIDOC ## POST /upscale ### Description Upscales an image by 4x using the Real-ESRGAN model. This endpoint accepts the image file as multipart form data. ### Method POST ### Endpoint /v1/image/upscale ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to upscale. ### Request Example ```bash curl -X POST "https://apim-ai-apis.azure-api.net/v1/image/upscale" \ -H "Authorization: Bearer YOUR_KEY" \ -F "file=@small.jpg" ``` ### Response #### Success Response (200) - **image** (binary) - The upscaled image. #### Response Example (Binary image data) ``` -------------------------------- ### Restore Face with Base64 (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores faces in an image using base64 encoded input and output. This method utilizes the GFPGAN v1.3 model and requires 'requests' and 'base64' libraries. ```python import requests import base64 with open("blurry.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("restored.png", "wb") as f: f.write(base64.b64decode(result["image"]))) ``` -------------------------------- ### Python: Batch Image Processing with Progress Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This Python script enables batch processing of images within a directory using multithreading for improved performance. It can apply various operations (e.g., background removal, upscaling, face restoration) to multiple images concurrently and provides real-time progress updates. The script requires input and output directories, the desired operation, and the number of worker threads. ```python import requests from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path import time BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def process_one(input_path, output_dir, operation="remove-background"): """Process a single image.""" name = Path(input_path).stem output_path = Path(output_dir) / f"{name}_{operation}.png" with open(input_path, "rb") as f: resp = requests.post( f"{BASE_URL}/{operation}", headers=HEADERS, files={"file": f}, timeout=30 ) if resp.status_code == 200: with open(output_path, "wb") as f: f.write(resp.content) return str(output_path), True return str(input_path), False def batch_process(input_dir, output_dir, operation="remove-background", workers=5): """Process all images in a directory.""" input_dir = Path(input_dir) output_dir = Path(output_dir) output_dir.mkdir(exist_ok=True) files = list(input_dir.glob("*.jpg")) + list(input_dir.glob("*.png")) print(f"Processing {len(files)} images with {workers} workers...") start = time.time() results = {"success": 0, "failed": 0} with ThreadPoolExecutor(max_workers=workers) as pool: futures = { pool.submit(process_one, str(f), str(output_dir), operation): f for f in files } for future in as_completed(futures): path, success = future.result() if success: results["success"] += 1 else: results["failed"] += 1 print(f" [{results['success'] + results['failed']}/{len(files)}] {Path(path).name}") elapsed = time.time() - start print(f"Done: {results['success']} success, {results['failed']} failed in {elapsed:.1f}s") print(f"Average: {elapsed / len(files):.2f}s per image") # Usage: # batch_process("input_images/", "output_images/", "remove-background", workers=5) # batch_process("input_images/", "output_images/", "upscale", workers=3) # batch_process("input_images/", "output_images/", "restore-face", workers=5) ``` -------------------------------- ### Upscale Image with Base64 (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an image by 4x using base64 encoded input and output. This method uses the Real-ESRGAN x4plus model and requires 'requests' and 'base64' libraries. ```python import requests import base64 with open("small.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("upscaled.png", "wb") as f: f.write(base64.b64decode(result["image"]))) ``` -------------------------------- ### POST /restore-face Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores faces in an image using the GFPGAN model. Accepts multipart form data. ```APIDOC ## POST /restore-face ### Description Restores faces in an image using the GFPGAN model. This endpoint accepts the image file as multipart form data. ### Method POST ### Endpoint /v1/image/restore-face ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file containing faces to restore. ### Request Example ```bash curl -X POST "https://apim-ai-apis.azure-net/v1/image/restore-face" \ -H "Authorization: Bearer YOUR_KEY" \ -F "file=@blurry.jpg" ``` ### Response #### Success Response (200) - **image** (binary) - The image with restored faces. #### Response Example (Binary image data) ``` -------------------------------- ### Python: Complete Image Processing Pipeline Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This snippet defines functions to perform individual image processing tasks such as removing backgrounds, upscaling images by 4x, and restoring faces. It utilizes the `requests` library to send POST requests to a specified API endpoint and saves the processed image to a file. The functions require input and output file paths and an API key for authentication. ```python import requests import base64 from pathlib import Path BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def remove_bg(input_path, output_path): """Remove background from image.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/remove-background", headers=HEADERS, files={"file": f}) with open(output_path, "wb") as f: f.write(resp.content) print(f"Background removed: {output_path}") def upscale(input_path, output_path): """Upscale image 4x.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/upscale", headers=HEADERS, files={"file": f}) with open(output_path, "wb") as f: f.write(resp.content) print(f"Upscaled 4x: {output_path}") def restore(input_path, output_path): """Restore faces in image.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/restore-face", headers=HEADERS, files={"file": f}) with open(output_path, "wb") as f: f.write(resp.content) print(f"Face restored: {output_path}") # Full pipeline: remove bg -> upscale -> restore face # remove_bg("portrait.jpg", "step1_nobg.png") # upscale("step1_nobg.png", "step2_upscaled.png") # restore("portrait.jpg", "step3_restored.png") ``` -------------------------------- ### POST /remove-background/base64 Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image using base64 encoding for both input and output. ```APIDOC ## POST /remove-background/base64 ### Description Removes background from an image using BiRefNet with base64 input/output. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/remove-background/base64 ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** (string) - Required - Base64 encoded image string. ### Request Example ```python import requests import base64 with open("photo.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("result.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### Response #### Success Response (200) - **image** (string) - Base64 encoded result image string. #### Response Example ```json { "image": "base64_encoded_result" } ``` ``` -------------------------------- ### JSON: MCP Server Configuration for Image API Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This JSON configuration defines the settings for an MCP (Message Communication Protocol) server specifically for the BrainiAll image API. It specifies the server URL and necessary headers for communication. ```json { "mcpServers": { "brainiall-image": { "url": "https://apim-ai-apis.azure-api.net/mcp/image/mcp", "headers": { "Accept": "application/json, text/event-stream" } } } } ``` -------------------------------- ### Remove Background with Base64 (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image using base64 encoded input and output. This method is suitable for scenarios where direct file uploads are not feasible. It requires the 'requests' and 'base64' libraries. ```python import requests import base64 with open("photo.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("result.png", "wb") as f: f.write(base64.b64decode(result["image"]))) ``` -------------------------------- ### Upscale Image by 4x (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an image by 4x using the Real-ESRGAN x4plus model. This endpoint accepts multipart/form-data and returns a PNG image with increased resolution. The 'requests' library is required. ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("small.jpg", "rb")} ) with open("upscaled.png", "wb") as f: f.write(response.content) ``` -------------------------------- ### cURL: Image Background Removal, Upscaling, and Face Restoration Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This section provides cURL commands for interacting with the BrainiAll Image API. It covers background removal (both multipart and base64 encoded), image upscaling, face restoration, and health checks. These commands are useful for scripting and command-line operations. ```bash BASE="https://apim-ai-apis.azure-api.net/v1/image" KEY="YOUR_KEY" # Remove background (multipart) curl -X POST "$BASE/remove-background" \ -H "Authorization: Bearer $KEY" \ -F "file=@photo.jpg" \ -o nobg.png # Remove background (base64) B64=$(base64 -i photo.jpg) curl -X POST "$BASE/remove-background/base64" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $KEY" \ -d "{\"image\": \"$B64\"}" | python3 -c " import json, sys, base64 data = json.load(sys.stdin) with open('nobg_b64.png', 'wb') as f: f.write(base64.b64decode(data['image'])) print('Saved nobg_b64.png') " # Upscale 4x curl -X POST "$BASE/upscale" \ -H "Authorization: Bearer $KEY" \ -F "file=@small.jpg" \ -o upscaled.png # Restore face curl -X POST "$BASE/restore-face" \ -H "Authorization: Bearer $KEY" \ -F "file=@blurry.jpg" \ -o restored.png # Health check curl -s "$BASE/health" \ -H "Authorization: Bearer $KEY" | python3 -m json.tool ``` -------------------------------- ### POST /remove-background Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image. Accepts multipart form data. ```APIDOC ## POST /remove-background ### Description Removes the background from an image using the BiRefNet model. This endpoint accepts the image file as multipart form data. ### Method POST ### Endpoint /v1/image/remove-background ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to process. ### Request Example ```bash curl -X POST "https://apim-ai-apis.azure-api.net/v1/image/remove-background" \ -H "Authorization: Bearer YOUR_KEY" \ -F "file=@photo.jpg" ``` ### Response #### Success Response (200) - **image** (binary) - The image with the background removed. #### Response Example (Binary image data) ``` -------------------------------- ### POST /remove-background/base64 Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image provided as a base64 encoded string. ```APIDOC ## POST /remove-background/base64 ### Description Removes the background from an image provided as a base64 encoded string. The result is also returned as a base64 encoded string. ### Method POST ### Endpoint /v1/image/remove-background/base64 ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** (string) - Required - The base64 encoded image string. ### Request Example ```json { "image": "" } ``` ### Response #### Success Response (200) - **image** (string) - The base64 encoded image string with the background removed. #### Response Example ```json { "image": "" } ``` ``` -------------------------------- ### POST /restore-face Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores and enhances faces in an image using the GFPGAN v1.3 model. Accepts multipart/form-data and returns a PNG image with restored faces. ```APIDOC ## POST /restore-face ### Description Restore and enhance faces using GFPGAN v1.3. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/restore-face ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file containing faces to restore. ### Request Example ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("blurry.jpg", "rb")} ) with open("restored.png", "wb") as f: f.write(response.content) ``` ### Response #### Success Response (200) - **image** (PNG) - The image with restored and enhanced faces. #### Response Example (Binary PNG data) ``` -------------------------------- ### POST /remove-background Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an image using the BiRefNet model. Accepts multipart/form-data and returns a PNG image with a transparent background. ```APIDOC ## POST /remove-background ### Description Removes background from an image using BiRefNet. ### Method POST ### Endpoint https://apim-ai-apis.azure-api.net/v1/image/remove-background ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to process. ### Request Example ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("photo.jpg", "rb")} ) with open("result.png", "wb") as f: f.write(response.content) ``` ### Response #### Success Response (200) - **image** (PNG) - The processed image with a transparent background. #### Response Example (Binary PNG data) ``` -------------------------------- ### Restore Face in Image (Python) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores and enhances faces in an image using the GFPGAN v1.3 model. This endpoint accepts multipart/form-data and returns a PNG image with improved facial details. The 'requests' library is needed. ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("blurry.jpg", "rb")} ) with open("restored.png", "wb") as f: f.write(response.content) ``` -------------------------------- ### Check Service Health (Bash) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Performs a health check on the Brainiall Image API service, including GPU status. This endpoint returns JSON data indicating the service status, GPU details, and loaded models. Requires 'curl'. ```bash curl -s https://apim-ai-apis.azure-api.net/v1/image/health \ -H "Authorization: Bearer YOUR_KEY" ``` -------------------------------- ### Batch Image Processing Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Processes multiple images from a directory using a specified operation (remove-background, upscale, restore-face) with a configurable number of workers. ```APIDOC ## Batch Image Processing ### Description This function allows for batch processing of images located in an input directory. It supports various operations like background removal, upscaling, and face restoration. The processing can be parallelized using a specified number of worker threads. ### Method N/A (This is a client-side function that calls multiple API endpoints) ### Endpoint N/A (This function orchestrates calls to: - `/v1/image/remove-background` - `/v1/image/upscale` - `/v1/image/restore-face`) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This function does not directly take a request body for an API call. It processes files from a local directory. - **input_dir** (string) - Required - The path to the directory containing input images. - **output_dir** (string) - Required - The path to the directory where processed images will be saved. - **operation** (string) - Optional - The image processing operation to perform. Defaults to "remove-background". Accepted values: "remove-background", "upscale", "restore-face". - **workers** (integer) - Optional - The number of worker threads to use for parallel processing. Defaults to 5. ### Request Example ```python batch_process("input_images/", "output_images/", "remove-background", workers=5) batch_process("input_images/", "output_images/", "upscale", workers=3) batch_process("input_images/", "output_images/", "restore-face", workers=5) ``` ### Response #### Success Response (200) This function does not return an API response. It prints progress and a summary of processed images to the console. #### Response Example ``` Processing 10 images with 5 workers... [1/10] image1_remove-background.png [2/10] image2_remove-background.png ... Done: 10 success, 0 failed in 15.2s Average: 1.52s per image ``` ``` -------------------------------- ### Image Upscaling Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Upscales an input image by 4x and saves the result to an output path. This endpoint accepts a file upload. ```APIDOC ## POST /v1/image/upscale ### Description Upscales an image by 4x. ### Method POST ### Endpoint /v1/image/upscale ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to process. ### Request Example ``` --boundary Content-Disposition: form-data; name="file"; filename="image.jpg" Content-Type: image/jpeg [binary content of image.jpg] --boundary-- ``` ### Response #### Success Response (200) - **content** (binary) - The upscaled image. #### Response Example [binary content of the upscaled image] ``` -------------------------------- ### Image Processing Endpoint Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt This endpoint allows you to process images using the specified models. You need to provide an API key for authentication. ```APIDOC ## Process Image This endpoint processes an image using a specified model. ### Method POST ### Endpoint /process ### Parameters #### Query Parameters - **api_key** (string) - Required - Your API key for authentication. - **model** (string) - Required - The name of the model to use (e.g., "BiRefNet", "Real-ESRGAN", "GFPGAN"). #### Request Body - **image** (string) - Required - The image data, either as a Base64 encoded string or a URL to the image. ### Request Example ```json { "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" } ``` ### Response #### Success Response (200) - **output_image** (string) - The processed image as a Base64 encoded string. #### Response Example ```json { "output_image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" } ``` ``` -------------------------------- ### Image Background Removal Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Removes the background from an input image and saves the result to an output path. This endpoint accepts a file upload. ```APIDOC ## POST /v1/image/remove-background ### Description Removes the background from an input image. ### Method POST ### Endpoint /v1/image/remove-background ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to process. ### Request Example ``` --boundary Content-Disposition: form-data; name="file"; filename="image.jpg" Content-Type: image/jpeg [binary content of image.jpg] --boundary-- ``` ### Response #### Success Response (200) - **content** (binary) - The processed image with background removed. #### Response Example [binary content of the processed image] ``` -------------------------------- ### Face Restoration Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-image-api/main/llms-full.txt Restores faces in an input image and saves the result to an output path. This endpoint accepts a file upload. ```APIDOC ## POST /v1/image/restore-face ### Description Restores faces in an image. ### Method POST ### Endpoint /v1/image/restore-face ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The image file to process. ### Request Example ``` --boundary Content-Disposition: form-data; name="file"; filename="image.jpg" Content-Type: image/jpeg [binary content of image.jpg] --boundary-- ``` ### Response #### Success Response (200) - **content** (binary) - The image with restored faces. #### Response Example [binary content of the image with restored faces] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.