Skip to content

Vikasdh1031/TexFusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TexFusion – AI-Powered Textile Defect Detection, Pattern Recognition & Design Generation

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.

Table of Contents

About

What is TexFusion?

TexFusion is a comprehensive deep-learning system built to modernize textile manufacturing. It analyzes fabric images for defects using CNNs, identifies pattern categories using EfficientNetB3, and generates new textile designs using a conditional DCGAN model. The platform provides fast, accurate, and creative support for both quality assurance and textile design teams.

Features

  • 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.

Why TexFusion?

  • 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.

Getting Started

Prerequisites

Before you begin, ensure that the following software and dependencies are installed in your development environment:

For Backend (Flask + AI Models):

  • 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

For Frontend (Web Interface):

  • Any modern web browser (Chrome, Edge, Firefox).
  • Basic static server (optional): You can simply open index.html directly or use VS Code Live Server.
  • Ensure backend API URLs are updated inside your JavaScript files.

Installation

Clone the Repository:

git clone https://github.com/Suhas-Varna/TexFusion.git
cd TexFusion

Backend Setup (Flask)

  1. Create Virtual Environment (Recommended):

    python -m venv venv
  2. Activate Virtual Environment:

    # Windows
    venv\Scripts\activate
    # Mac / Linux
    source venv/bin/activate
  3. Start the Flask Backend Server:

    python app.py

    The backend will run at: http://127.0.0.1:5000/

  4. Ensure Model Paths Are Correct:

    Update the paths for: CNN model, EfficientNetB3 model, and DCGAN weights inside app.py.

Frontend Setup

  1. Navigate to the frontend directory (if applicable) or simply open the index.html file.
  2. Update API Base URL inside your JavaScript:

    const BASE_URL = "http://127.0.0.1:5000";
  3. Run the frontend:

    • Option 1: Open index.html directly in browser
    • Option 2: Use VS Code β†’ Live Server

TechStack - Built With Python Flask TensorFlow JS

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.

System Architecture

πŸ—οΈ High-Level Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                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        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Data Flow Diagram

  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                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—‚οΈ Project Structure

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.

πŸ” TexFusion Security Architecture

  • 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

⚑ TexFusion Performance Optimizations

  • 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

App Demonstration

Screenshots

Conclusion

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.

The Team

Suhas Varna

GitHub LinkedIn

Seeripi Ganesh Kumar

GitHub LinkedIn

Vikas D H

GitHub LinkedIn

Sanjay J

GitHub LinkedIn

About

AI-powered textile quality inspection and pattern recognition system using Flask, TensorFlow, OpenCV, and Computer Vision.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors