API Documentation

Advanced AI-powered leukemia classification using FastAPI and deep learning

PUBLIC ACCESS No Authentication Required Global Access

🌐 Base URL

https://camlas-leukemia-hybridcn-nas.hf.space

Quick Start

Get started with our API in seconds - no authentication required!

cURL

curl -X POST https://camlas-leukemia-hybridcn-nas.hf.space/predict \
  -H "Content-Type: application/json" \
  -d '{"image_base64": "base64_image"}'

Python

import requests

response = requests.post(
  "https://camlas-leukemia-hybridcn-nas.hf.space/predict",
  json={"image_base64": image_b64}
)

JavaScript

fetch("https://camlas-leukemia-hybridcn-nas.hf.space/predict", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({image_base64: imageB64})
})

API Endpoints

Complete list of available endpoints and their specifications

GET

API Information

application/json No Auth

Endpoint Details

GET https://camlas-leukemia-hybridcn-nas.hf.space/

Get API information and status

Content-Type: application/json 200
POST

Base64 Prediction

application/json No Auth

Endpoint Details

POST https://camlas-leukemia-hybridcn-nas.hf.space/predict

Predict from base64 encoded image

Content-Type: application/json 200
POST

File Upload Prediction

multipart/form-data No Auth

Endpoint Details

POST https://camlas-leukemia-hybridcn-nas.hf.space/predict/upload

Predict from uploaded file

Content-Type: multipart/form-data 200
GET

Health Check

application/json No Auth

Endpoint Details

GET https://camlas-leukemia-hybridcn-nas.hf.space/health

Detailed health check and model status

Content-Type: application/json 200

📥 Response Formats

Understanding API responses and data structures

✅ Success Response (200)

{
  "status_code": 200,
  "status": "success",
  "success": true,
  "data": {
    "prediction": {
      "predicted_class": "Benign",
      "confidence": 0.942,
      "confidence_level": "high",
      "description": "Normal healthy white blood cells"
    },
    "probabilities": {
      "Benign": 0.942,
      "Early": 0.035,
      "Pre": 0.018,
      "Pro": 0.005
    },
    "metadata": {
      "image_size": "224x224",
      "model_version": "HybridCN-NAS-v1.0",
      "device": "mps",
      "model_source": "huggingface_hub"
    }
  },
  "timestamp": "2025-06-11T10:30:45.123456+00:00",
  "api_version": "1.0.0",
  "processing_time_ms": 1250.75
}

❌ Error Response (400)

{
  "status_code": 400,
  "status": "error",
  "success": false,
  "error": "Invalid image format",
  "error_code": "INVALID_IMAGE_FORMAT",
  "timestamp": "2025-06-11T10:30:45.123Z",
  "api_version": "1.0.0",
  "processing_time_ms": 45.2
}

✅ Health Check Response (200)

{
	  "status_code": 200,
	  "status": "healthy",
	  "service": "Leukemia Classification API",
	  "api_version": "1.0.0",
	  "model_version": "HybridCN-NAS-v1.0",
	  "models_loaded": true,
	  "models_loaded_count": 3,
	  "total_models_required": 3,
	  "model_sources": {
		"feature_extractor": {
		  "source": "huggingface_hub",
		  "repository": "camlas/leukemia-HybridCN-NAS",
		  "filename": "feature_extractor.pt",
		  "local_path": "models/feature_extractor.pt",
		  "local_exists": true,
		  "loaded": true
		},
		"classifier": {
		  "source": "huggingface_hub",
		  "repository": "camlas/leukemia-HybridCN-NAS",
		  "filename": "classifier.pt",
		  "local_path": "models/classifier.pt",
		  "local_exists": true,
		  "loaded": true
		},
		"scaler": {
		  "source": "huggingface_hub",
		  "repository": "camlas/leukemia-HybridCN-NAS",
		  "filename": "feature_scaler.pt",
		  "local_path": "models/feature_scaler.pt",
		  "local_exists": true,
		  "loaded": true
		}
	  },
	  "repository_info": {
		"repository_id": "camlas/leukemia-HybridCN-NAS",
		"total_models": 3,
		"available_models": ["feature_extractor", "classifier", "scaler"],
		"model_files": {
		  "feature_extractor": "feature_extractor.pt",
		  "classifier": "classifier.pt",
		  "scaler": "feature_scaler.pt"
		},
		"models_directory": "models",
		"models_directory_exists": true
	  },
	  "device": "mps",
	  "timestamp": "2025-06-11T10:30:45.123456+00:00"
	}

🔬 Classification Classes

Benign

Normal healthy white blood cells

Medical significance for Benign classification

Early

Early stage leukemia cells

Medical significance for Early classification

Pre

Pre stage leukemia cells

Medical significance for Pre classification

Pro

Pro stage leukemia cells

Medical significance for Pro classification

📊 HTTP Status Codes & Error Handling

HTTP Status Codes

200 Success

Request completed successfully

400 Bad Request

Invalid input (missing/corrupt image, wrong format)

500 Internal Server Error

Server-side processing error

503 Service Unavailable

Models not loaded or system unavailable

Error Codes & Solutions

MISSING_IMAGE

No image provided in request

Solution: Include base64 image or upload file

INVALID_IMAGE_FORMAT

Image format not supported or corrupted

Solution: Use JPEG/PNG format, check encoding

IMAGE_TOO_SMALL

Image dimensions too small

Solution: Use images ≥ 10x10 pixels

MODEL_NOT_LOADED

AI models not initialized

Solution: Wait for system restart or contact support

INTERNAL_ERROR

Unexpected server error

Solution: Retry request or contact support

🌐 Integration Examples

Ready-to-use code examples in multiple programming languages

Python - Complete Example

import requests
	import base64
	
	API_URL = "https://camlas-leukemia-hybridcn-nas.hf.space"
	
	def predict_leukemia_base64(image_path):
		"""Predict leukemia classification using base64 endpoint"""
		# Encode image
		with open(image_path, "rb") as f:
			image_b64 = base64.b64encode(f.read()).decode()
		
		# Simple API request - no authentication needed
		response = requests.post(
			f"{API_URL}/predict",
			json={"image_base64": image_b64},
			headers={"Content-Type": "application/json"},
			timeout=30
		)
		
		return response.json()
	
	def predict_leukemia_upload(image_path):
		"""Predict leukemia classification using file upload endpoint"""
		with open(image_path, "rb") as f:
			files = {"file": ("image.jpg", f, "image/jpeg")}
			response = requests.post(f"{API_URL}/predict/upload", files=files, timeout=30)
		
		return response.json()
	
	def check_api_health():
		"""Check API health status"""
		response = requests.get(f"{API_URL}/health", timeout=30)
		return response.json()
	
	# Usage Examples
	if __name__ == "__main__":
		# Health check
		health = check_api_health()
		print(f"API Status: {health['status']}")
		print(f"Models Loaded: {health['models_loaded_count']}/{health['total_models_required']}")
		
		# Prediction
		result = predict_leukemia_base64("cell_image.jpg")
		if result["status_code"] == 200:
			prediction = result["data"]["prediction"]
			print(f"Class: {prediction['predicted_class']}")
			print(f"Confidence: {prediction['confidence']:.1%}")
			print(f"Description: {prediction['description']}")
		else:
			print(f"Error: {result['error']}")
	

📈 Confidence Levels & Model Performance

high Confidence

> 80%

Model is very confident in prediction

medium Confidence

60-80%

Moderate confidence, consider additional analysis

low Confidence

< 60%

Low confidence, manual review recommended

🏗️ Technical Specifications

HybridCN-NAS-v1.0

Model Version

224×224×3

Input Size

~192.3M

Parameters

3-10s

Inference Time

Ready to Integrate Our API?

Start using our leukemia classification API in your applications today - no authentication required!

Public API: This API is publicly accessible for research and educational purposes. For commercial use or high-volume requests, please contact our team.