Datasets:
Tasks:
Image Classification
Formats:
imagefolder
Size:
< 1K
Tags:
computer-vision
image-classification
carpet-analysis
textile-classification
material-identification
License:
Update Dataset Card to full English with privacy notices
Browse files3 unmodified lines4567891011111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410512131410810911011111211311415161161171181191201211221231241251261271718192013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916021221621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002324252627282930313233343536204373820620720820921021121221321421521621721821922022122222322422522622722839404142232233234235236434423823924024124224324424545464748495024925025125225325425525625725825926026126226326426526626726826927027151522732742752765354555657585960612792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204213 unmodified lines - image-segmentation - image-classificationtags: - computer-vision - carpet-analysis - defect-detection - unet - sam2 - computer-vision---
# π§΅ Carpet Analysis System
**Sistem AI untuk Analisis & Verifikasi Keaslian Karpet**
[](https://www.python.org/)[](https://pytorch.org/)[](https://onnx.ai/)[](https://fastapi.tiangolo.com/)[](https://streamlit.io/)
---
## π Deskripsi
Sistem berbasis **Deep Learning** untuk menganalisis karpet dari gambar mikroskopis dan makroskopis, kemudian memverifikasi keaslian berdasarkan kombinasi material dan jenis karpet, serta memberikan estimasi harga.
**Fitur Utama:**
- π¬ **Material Detection**: Klasifikasi material (Polypropylene/Nylon/Polyester)- π¨ **Carpet Segmentation**: Segmentasi karpet untuk quality assessment- π·οΈ **Type Classification**: Klasifikasi jenis karpet (6 jenis)- β
**Authentication**: Verifikasi keaslian berdasarkan kombinasi material+jenis- π° **Price Estimation**: Estimasi harga untuk karpet asli
---
## π― Arsitektur Sistem
```ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ STREAMLIT FRONTEND ββ (Upload Images + Display Results) ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β βΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ FASTAPI BACKEND βββββββββββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββββ€β CNN-B (8000) β U-Net (8001) β CNN-A (8002) ββ Material β Segmentation β Type ββ EfficientNet β ResNet34 β EfficientNet βββββββββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββββββ β βΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ SQLITE DATABASE ββ (Analysis History + Product Catalog) ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ```
---
## π Quick Start
### 1. Install Dependencies
```bashpip install -r requirements.txt```
### 2. Start Backend API
```bashpython deploy_all_models_onnx.py```
**Output:**
- Port 8000: CNN-B (Material Classification)- Port 8001: U-Net (Carpet Segmentation)- Port 8002: CNN-A (Type Classification)
### 3. Start Frontend
```bashstreamlit run app.py```
**Access:** http://localhost:8501
---
## π Model Performance
| Model | Task | Architecture | Accuracy | Inference Time || --------- | ----------------------- | ---------------- | ---------- | -------------- || **CNN-B** | Material Classification | EfficientNet-B0 | 100% | ~10ms || **U-Net** | Carpet Segmentation | ResNet34 encoder | 88.66% IoU | ~45ms || **CNN-A** | Type Classification | EfficientNet-B0 | 95.45% | ~15ms |
**Total Processing Time:** ~70ms per image (ONNX optimized)
- automated-inspection---
## ποΈ Database Schema
### Tabel: `analysis_history`
Menyimpan semua hasil analisis karpet
### Tabel: `carpet_products`# π§΅ Carpet Analysis & Defect Segmentation Dataset & Evaluation Pipelines
6 produk karpet yang dijual:
1. Asia Polypropylene (Rp 100K - 200K)2. Malaysia Polyester (Rp 200K - 500K)3. Mie Polypropylene (Rp 50K - 100K)4. Persia Nylon (Rp 400K - 800K)5. Polos Polypropylene (Rp 50K - 100K)6. Sejadah Nylon (Rp 600K - 950K)
### Tabel: `suspicious_patterns`
Log untuk fraud detectionThis repository provides the core metadata, evaluation benchmarks, masking logs, and training pipelines developed for automated carpet defect detection, material classification, and surface segmentation.
---
## π‘ Cara Penggunaan
### Via Web Interface (Streamlit)
1. **Upload Images**
- Mikroskopis: Gambar close-up serat karpet - Makroskopis: Gambar keseluruhan karpet
2. **Analyze**
- Klik tombol "ANALISIS SEKARANG" - Tunggu ~1 detik untuk hasil
3. **View Results** - Material + confidence - Jenis + confidence - Status autentikasi (β
Asli / π¨ Palsu) - Estimasi harga (jika asli)
### Via CLI (Command Line)
```bashpython carpet_analysis_system.py "mikro.jpg" "makro.jpg"```
### Via API (REST)
```pythonimport requests## π Dataset Overview
# Material Detectionresponse = requests.post( "http://localhost:8000/predict", files={'file': open('mikro.jpg', 'rb')})print(response.json())
# Type Classificationresponse = requests.post( "http://localhost:8002/predict", files={'file': open('makro.jpg', 'rb')})print(response.json())```
---
## π Deployment
### Option 1: ngrok (Demo - 2 Jam Session)
```bash# Terminal 1: Backendpython deploy_all_models_onnx.py
# Terminal 2: Frontendstreamlit run app.py
# Terminal 3: Exposengrok http 8501```
**Result:** Public HTTPS URL untuk demo!
### Option 2: Google Cloud Run (Production 24/7)
See [DEPLOYMENT.md](host/DEPLOYMENT.md) for detailed guide.
**FREE TIER:** 2 juta request/bulan - GRATIS!* **Domain:** Computer Vision, Industrial Surface Inspection, Textile Quality Assurance.* **Tasks:** * **Carpet Defect & Surface Segmentation:** High-resolution boundary identification and coverage ratio estimation using U-Net and SAM 2. * **Carpet Style Classification:** Automatic classification across various carpet styles (Asia, Malaysia, Mie, Persia, Polos, Sejadah). * **Material Identification:** Detection of fiber types (Polypropylene, Nylon, Polyester).* **Repository Contents:** * `05_Metadata/`: Integration test benchmarks, masking logs, and statistical evaluations. * `06_Models/`: Export metadata and deployment configuration specifications. * `evaluation/`: Benchmark scripts, metrics calculations, and architectural summaries. * `unet1/` & `unet2/`: Training configurations, transfer learning routines, and comparative performance logs. * `sam/` & `sam2_models/`: Promptable segmentation logs and inference configurations.
---
## π Struktur Folder## π Privacy & Safety Compliance
```Dataset_Karpet_Skripsi/βββ deploy_all_models_onnx.py # Backend API (3 servers)βββ app.py # Frontend Streamlitβββ database.py # Database operationsβββ database_schema.sql # Database schemaβββ carpet_analysis_system.py # CLI versionβββ requirements.txt # Dependenciesβββ DEPLOYMENT.md # Deployment guideβββ SUMMARY.md # Complete documentationββββ 06_Models/exports/β βββ cnn_a_model.onnx # Type classificationβ βββ cnn_b_model.onnx # Material detectionβ βββ unet_v1_resnet34.onnx # Segmentationβ βββ cnn_a_export_metadata.json # Class namesββββ test_set/β βββ mikro/ # Mikroskopis imagesβ βββ makro/ # Makroskopis imagesββββ analysis_results/ # JSON outputs```This public dataset repository contains strictly sanitized code, benchmarking data, and evaluation metadata. All raw media recordings, store video footages, personal identifications, and confidential environment credentials have been completely purged to ensure full privacy compliance.
---
## π§ Requirements
**Python:** 3.11+
**Key Dependencies:**## π Related Resources
- PyTorch 2.8.0- ONNX Runtime 1.23.2- FastAPI 0.115.5- Streamlit 1.41.0- OpenCV 4.10.0- Pillow 11.0.0
See [requirements.txt](requirements.txt) for complete list.* **Pre-trained ONNX Models:** [yosedie/carpet-analysis-api (Model Hub)](https://huggingface.co/yosedie/carpet-analysis-api)* **Live Inference Space:** [yosedie/carpet-analysis-api (Space)](https://huggingface.co/spaces/yosedie/carpet-analysis-api)* **Interactive API Documentation:** [https://yosedie-carpet-analysis-api.hf.space/docs](https://yosedie-carpet-analysis-api.hf.space/docs)
---
## π API Endpoints
### CNN-B API (Port 8000)
**POST** `/predict`
- **Input:** Image file (mikroskopis)- **Output:**
```json{ "material": "Polypropylene", "confidence": 0.9736, "processing_time": 0.011}```
### U-Net API (Port 8001)
**POST** `/segment`
- **Input:** Image file (makroskopis)- **Output:**## π Citation & Usage
```json{ "carpet_coverage": 100.0, "processing_time": 0.214```bibtex@misc{carpet_analysis_system, author = {yosedie}, title = {Carpet Analysis System: Automated Defect Detection and Material Classification}, year = {2026}, publisher = {Hugging Face}, howpublished = {\url{https://huggingface.co/datasets/yosedie/carpet-analysis-api}}}```
### CNN-A API (Port 8002)
**POST** `/predict`
- **Input:** Image file (makroskopis)- **Output:**
```json{ "predicted_class": "Asia", "confidence": 0.9885, "processing_time": 0.031}```
---
## π§ͺ Testing
### Test Database
```bashpython database.py```
### Test Backend API
```bash# Start backend firstpython deploy_all_models_onnx.py
# Test endpointscurl http://localhost:8000/healthcurl http://localhost:8001/healthcurl http://localhost:8002/health```
### Test Complete Pipeline
```bashpython carpet_analysis_system.py test_set/mikro/pp1.jpg test_set/makro/a1.jpg```
**Expected Output:**
- β
Material: Polypropylene (97.36%)- β
Jenis: Asia (98.85%)- β
AUTHENTIC- π° Harga: Rp 100,000 - Rp 200,000
---
## π Teknologi
### Deep Learning
- **Framework:** PyTorch 2.8.0- **Optimization:** ONNX Runtime (7-8x faster inference)- **Models:** EfficientNet-B0, U-Net ResNet34
### Web Framework
- **Backend:** FastAPI (async REST API)- **Frontend:** Streamlit (interactive web app)- **Server:** Uvicorn (ASGI)
### Database
- **Engine:** SQLite3- **ORM:** Native Python sqlite3- **Features:** Views, Indexes, Foreign Keys
### Deployment
- **Demo:** ngrok (HTTPS tunneling)- **Production:** Google Cloud Run- **Alternative:** Hugging Face Spaces
---
## π Performance Benchmarks
**Hardware:** RTX 5070 Ti Laptop (12GB VRAM)
| Operation | Time (ONNX) | Time (PyTorch) | Speedup || --------- | ----------- | -------------- | ------- || CNN-B | 9.6ms | 150ms | 15.6x || U-Net | 45.0ms | 250ms | 5.6x || CNN-A | 29.0ms | 120ms | 4.1x || **Total** | **~84ms** | **~520ms** | **~7x** |
---
## π¨ Troubleshooting
### "Model not loaded"
```bash# Check ONNX files existdir 06_Models\exports\*.onnx```
### "Connection refused"
```bash# Ensure backend is runningcurl http://localhost:8000/health```
### "Database locked"
```bash# Close other connectionspython database.py # Reinitialize```
---
## π Support
- **Documentation:** See [SUMMARY.md](SUMMARY.md)- **Deployment:** See [DEPLOYMENT.md](host/DEPLOYMENT.md)- **Issues:** Check troubleshooting section above
---
## π License
Β© 2025 Carpet Analysis System
---
## π Acknowledgments
- **PyTorch Team** for the deep learning framework- **ONNX** for cross-platform model optimization- **FastAPI** for modern REST API framework- **Streamlit** for rapid web app development
---
**Built with β€οΈ for carpet authentication and price estimation**README.md+30-390