TexFusion is an AI-powered textile automation platform that integrates fabric defect detection, pattern recognition, and GAN-based design generation. It helps textile industries improve quality control while enabling rapid creation of new fabric patterns. The system provides a unified, intelligent workflow combining computer vision and generative AI.
- About
- Getting Started
- TechStack Used
- System Architecture
- Screenshots and App Demonstration
- Conclusion
- Developed By
- Automated Fabric Defect Detection
- Detects stains, holes, weave faults, horizontal/vertical line defects using a CNN-based inspection model.
- Provides confidence scores and top-3 predictions for improved quality assessment.
- Ensures consistent and reliable defect detection compared to manual inspection.
- Pattern Recognition (19 Textile Categories)
- EfficientNetB3 architecture trained on 19 fabric pattern classes for high-accuracy classification.
- Supports recognition of patterns such as floral, stripes, geometric, checks, abstract, and more.
- Helps designers and manufacturers categorize fabrics for inventory and production workflows.
- AI Design Generation (Conditional DCGAN)
- Generates new textile patterns conditioned on selected pattern categories.
- Produces unique, visually coherent, and creative fabric designs using PyTorch-based GAN models.
- Allows rapid prototyping of designs without manual drawing.
- Color & Style Customization
- Real-time hue, saturation, and brightness adjustments on generated designs.
- Applies enhancement filters such as sharpen, smooth, and stylize for aesthetic refinement.
- Enables quick experimentation with multiple color variations.
- Motif Overlay & Tiling
- Upload custom motifs (PNG) and overlay them on generated backgrounds.
- Supports repeating motifs in tiled or centered formats, ideal for fabric print layouts.
- Creates production-ready textile patterns with both background and motif layers.
- Interactive Web Interface
- Simple upload-based workflow for inspection, pattern recognition, and design generation.
- Displays predictions, confidence levels, and design previews in real time.
- Allows users to download final textile designs instantly.
- Optimized Backend Architecture
- Flask backend integrating CNN, EfficientNetB3, and DCGAN models through dedicated REST APIs.
- Seamless communication with the frontend for fast inference and design generation.
- Robust processing pipeline with image preprocessing, prediction, post-processing, and rendering.
- Improved Fabric Quality Control: Automates defect detection using AI, reducing manual errors and ensuring consistent inspection standards across textile batches.
- Fast & Accurate Pattern Identification: EfficientNetB3-based pattern recognition helps categorize fabrics instantly, supporting designers, manufacturers, and inventory teams.
- AI-Powered Design Innovation: The conditional DCGAN model enables rapid generation of new textile patterns, helping designers explore creative ideas without manual sketching.
- End-to-End Textile Workflow: Combines quality inspection, pattern recognition, and design generation into one unified platform for maximum productivity.
- Customization-Focused Tools: Offers dynamic color tweaking, enhancement filters, and motif overlays, allowing users to create production-ready designs tailored to their needs.
- Fast, Lightweight, and User-Friendly: The web-based interface provides an intuitive workflow with real-time previews, easy image uploads, and instant design downloads.
Before you begin, ensure that the following software and dependencies are installed in your development environment:
- Python 3.8+: Required for running the TexFusion backend and all deep-learning models.
- pip: Python package manager used to install project dependencies.
-
Required Python Libraries:
- TensorFlow / Keras (for CNN & EfficientNetB3 models)
- PyTorch (for Conditional DCGAN)
- OpenCV (for image processing & color adjustments)
- NumPy, Pillow, Flask, Flask-CORS
-
Pretrained Model Files:
- CNN model for fabric defect detection
- EfficientNetB3 pattern recognition model
- DCGAN generator weights for textile design generation
- Any modern web browser (Chrome, Edge, Firefox).
- Basic static server (optional): You can simply open
index.htmldirectly or use VS Code Live Server. - Ensure backend API URLs are updated inside your JavaScript files.
git clone https://github.com/Suhas-Varna/TexFusion.git
cd TexFusion-
Create Virtual Environment (Recommended):
python -m venv venv -
Activate Virtual Environment:
# Windows venv\Scripts\activate # Mac / Linux source venv/bin/activate -
Start the Flask Backend Server:
python app.pyThe backend will run at:
http://127.0.0.1:5000/ -
Ensure Model Paths Are Correct:
Update the paths for: CNN model, EfficientNetB3 model, and DCGAN weights inside
app.py.
- Navigate to the frontend directory (if applicable) or simply open the
index.htmlfile. -
Update API Base URL inside your JavaScript:
const BASE_URL = "http://127.0.0.1:5000"; -
Run the frontend:
- Option 1: Open
index.htmldirectly in browser - Option 2: Use VS Code β Live Server
- Option 1: Open
Python: Core programming language used for building the backend and all AI model pipelines (CNN, EfficientNetB3, DCGAN).
Flask: Lightweight web framework used to serve the three TexFusion APIs β defect detection, pattern recognition, and design generation.
TensorFlow/Keras: Used for training and deploying the CNN defect detection model and EfficientNetB3 pattern recognition classifier.
PyTorch: Framework used to build and run the Conditional DCGAN responsible for textile design generation.
OpenCV: Handles image preprocessing, HSV color adjustments, enhancement filters, and motif overlay operations.
HTML, CSS, JavaScript: Used to create a simple yet interactive web interface that allows users to upload images, preview outputs, and download generated designs.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TexFusion APP β
β βββββββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββββββββ β
β β Home Screen β β β Image Upload Module β β β API Request Layer β β
β βββββββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββββββββ β
β β β β β
β βββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β β Defect Detection β β Pattern Classifierβ β Design Generator β β
β β (CNN) β β (EfficientNetB3) β β (DCGAN Model) β β
β βββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β β β β β
β ββββββββββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββββ β
β β JSON Predictions β β Pattern Labels β β Generated Images β β
β ββββββββββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API CALLS / JSON RESPONSE
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FASTAPI BACKEND β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Request Router & Processing Engine β β
β β β’ Routes user-uploaded images to correct model β β
β β β’ Handles CNN, EfficientNet, and GAN inference β β
β β β’ Returns predictions or generated designs β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β /detect-defect /classify-pattern /generate-design β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
USER UPLOADS FABRIC IMAGE
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TexFusion Frontend β
β β’ Uploads image β
β β’ Selects feature: Defect / Pattern / Design β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β HTTP POST (multipart image)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
β β’ Accepts image β
β β’ Validates and preprocesses β
β β’ Forwards to respective ML module β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MODEL PROCESSING β
β β’ CNN β Detects six defect classes β
β β’ EfficientNetB3 β Predicts 19 textile patterns β
β β’ Conditional DCGAN β Generates new designs β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β JSON Response / Image Output β
β β’ Predicted class + confidence β
β β’ Suggested pattern group β
β β’ Generated textile design image β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TexFusion Frontend β
β β’ Displays results β
β β’ Allows color edits & motif overlays (GAN) β
β β’ Supports download of final design β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TexFusion/ β βββ frontend/ # Web UI (HTML, CSS, JS) β βββ index.html β βββ upload.css β βββ design.js β βββ backend/ # FastAPI Server β βββ main.py # API endpoints β βββ defect_model/ # CNN model files β βββ pattern_model/ # EfficientNetB3 model files β βββ gan_model/ # DCGAN generator + embeddings β βββ utils/ # Preprocessing, helpers β βββ requirements.txt β βββ README.md
Note: Due to large file sizes, the trained model files are excluded from this repository. Please contact us via email to obtain access to the models.
- Secure Model Access:
- All ML models run locally on the server
- No external API dependency
- No cloud upload of user data
- Data Privacy:
- Uploaded images processed in-memory only
- No images or metadata stored on server
- Automatic cleanup of temp files
- API Security:
- CORS restricted to trusted UI origins
- Validation on image size, format, and request type
- Rate-limiting for design generation requests
- Backend Optimizations:
- Efficient batch preprocessing
- Model warm-loading for faster inference
- GPU-accelerated GAN generation (optional)
- Frontend Optimizations:
- Lazy-loaded image previews
- Client-side color filters using Canvas API
- Compressed API responses for faster rendering
TexFusion successfully integrates defect detection, pattern recognition, and AI-driven design generation into a unified textile intelligence platform. By combining CNNs, EfficientNetB3, and a Conditional DCGAN, the system automates critical manufacturing and creative processes with high reliability. Its interactive web interface enables real-time inspection and customizable design generation, reducing manual effort and streamlining workflows. Overall, TexFusion demonstrates how AI can enhance productivity, accuracy, and innovation in the textile industry.