1. Connection Test
GET /api/connection_test
Verify API service availability.
Example Request
curl https://api.defect-ai.com/api/connection_test
Success Response
{
"status": "ok",
"message": "connection successful"
}
2. Defect Detection Interface
POST /api/interface
Submit product images for defect detection and analysis.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| product_code | Integer | Product type identifier (required in form data) |
| images | File[] | Array of image files (supported formats: JPEG, PNG, etc.) |
Example Request
curl -X POST \
-F "product_code=1" \
-F "images=@20250222_103428260_0000000001_T0000_01_CAM.png" \
-F "images=@20250222_103428260_0000000001_T0000_02_CAM.png" \
-F "images=@20250222_103428260_0000000001_T0000_03_CAM.png" \
-F "images=@20250222_103428260_0000000001_T0000_04_CAM.png" \
-F "images=@20250222_103428260_0000000001_T0000_05_CAM.png" \
-F "images=@20250222_103428260_0000000001_T0000_06_CAM.png" \
https://api.defect-ai.com/api/interface
Success Response
{
"message": "Inference completed.",
"result": {
"defect_percent": 66.667,
"defect_type": "1-1",
"defect_type_name": "crack",
"interface_result": ["1-1", "1-1", "1-0", "1-1", "1-0", "1-1"],
"interface_result_name": ["crack", "crack", "No defect", "crack", "No defect", "crack"],
"interface_time": 1.07,
"is_defect": true,
"product_name": "syringe",
"product_type": 1,
"threshold_percent": 20.0
},
"status": "success"
}
Error Responses
| Code | Response |
|---|---|
| 400 |
|
| 500 | |
Response Field Definitions
| Field | Type | Description |
|---|---|---|
| is_defect | Boolean | Overall defect status (true if defect percentage ≥ threshold) |
| defect_type | String | Dominant defect type in format "product_type-defect_code" |
| defect_type_name | String | Human-readable name of the dominant defect type (e.g., "crack") |
| interface_result | Array | Raw defect codes detected in all images |
| interface_result_name | Array | Human-readable defect names corresponding to each code in interface_result |
| interface_time | Float | Time taken for inference processing in seconds |
| defect_percent | Float | Percentage of defective items relative to valid items |
| product_name | String | Human-readable name of the product being analyzed |
| product_type | Integer | Product type identifier provided in the request |
| threshold_percent | Float | Current threshold percentage used for determination |
Notes
- Defect codes are filtered by product_type before calculation
- Defect percentage = (defect_count / valid_count) × 100
- valid_count excludes defect codes with mismatched product_type
- Default threshold is set at 20% (configurable server-side)