🧶 Carpet Analysis System - Deep Learning Models
A collection of pre-trained deep learning models optimized for real-time carpet quality inspection, style classification, material detection, and surface segmentation.
Optimized with ONNX Runtime for low latency and efficient deployment on both CPU and GPU backends.
🚀 Live Demo & API Endpoint
These models power the active production backend deployed on Hugging Face Spaces:
- Live Space: yosedie/carpet-analysis-api
- Interactive Swagger UI: https://yosedie-carpet-analysis-api.hf.space/docs
📦 Model Portfolio
| Model File | Architecture | Task / Objective | Input Resolution | Format |
|---|---|---|---|---|
unet_model.onnx | U-Net | Carpet surface segmentation & defect coverage ratio calculation | 512x512 | ONNX |
cnn_a_model.onnx | Custom CNN | Carpet Style Classification (Asia, Malaysia, Mie, Persia, Polos, Sejadah) | 224x224 | ONNX |
cnn_b_model.onnx | Custom CNN | Fiber Material Identification (Polypropylene, Nylon, Polyester) | 224x224 | ONNX |
sam2_hiera_base_plus.pt | SAM 2 (Hiera Base+) | Zero-shot promptable segmentation for fine-grained boundary extraction | Multi-scale | PyTorch / SAM 2 |
⚡ Quickstart: Python & ONNX Runtime
import onnxruntime as ort
import numpy as np
from PIL import Image
# 1. Initialize U-Net Inference Session
session = ort.InferenceSession("unet_model.onnx", providers=["CPUExecutionProvider"])
# 2. Preprocess Input Image
image = Image.open("sample_carpet.jpg").convert("RGB").resize((512, 512))
img_data = np.array(image, dtype=np.float32) / 255.0
img_data = np.transpose(img_data, (2, 0, 1))
img_data = np.expand_dims(img_data, axis=0)
# 3. Execute Model Prediction
input_name = session.get_inputs()[0].name
output_name = session.get_outputs()[0].name
prediction = session.run([output_name], {input_name: img_data})[0]
# 4. Generate Binary Mask
segmentation_mask = (prediction[0, 0] > 0.5).astype(np.uint8) * 255
print("Inference successful. Mask dimension:", segmentation_mask.shape)
👤 Author
- Developer: yosedie
- GitHub: https://github.com/yosedie