API for soil particle size distribution analysis from images with usage tracking
Powered by grai4 model — outputs 11 PSD classes (softmax) for fine-grained particle size distribution
Developed by Enrico Soranzo
This API now includes comprehensive usage tracking:
/usage-stats endpointppm — auto (default) or numeric value (e.g. 15.0)
ppm — auto (default) or numeric value
x-api-key: YOUR_KEY.
Add API keys to the database or set environment variable API_KEYS_SEED on startup:
API_KEYS_SEED="alice:KEY1,bob:KEY2".
Monitor your API usage with these new endpoints:
/usage-stats?api_key=KEY - Your usage statistics/owner-stats?owner=alice - Statistics by owner (requires admin access)/admin/stats - Overall system statisticsAll statistics include request counts, success rates, response times, and endpoint breakdowns.
Upload an image using cURL:
curl -X POST -H "x-api-key: API_KEY" -F "file=@soil_image.jpeg" https://soranz84-graiAPI.hf.space/analyze
curl -X POST -H "x-api-key: API_KEY" -F "file=@soil_image.jpeg" -F "ppm=15.0" https://soranz84-graiAPI.hf.space/analyze
Use ppm=auto (default) for automatic detection from EXIF/CSV with 70° angle fallback, or provide a numeric value to set the pixel density (pixels per mm) directly.
curl -H "x-api-key: API_KEY" https://soranz84-graiAPI.hf.space/usage-stats?api_key=API_KEY
HUAWEI_p9_Lite_20177, iPad Pro, iPhone 13 mini, iPhone 14, iPhone 14 Pro, iPhone 15 Pro, iPhone 16, iPhone 16 Pro, Motorola Edge, Motorola Edge 60 fusion, Motorola G7+, Motorola G30, Samsung Galaxy A17, Samsung Galaxy A32, Samsung A52, Samsung Galaxy S23, Samsung Galaxy S24, Vivo X60, Xiaomi 15, Xiaomi A2
grai is device-agnostic. An angle of view of 70° is assumed for uncalibrated devices. You can write to enrico@deepsoil.at to update the list of calibrated devices.