Code Report

Table of Contents

1. Project Overview

OVDR (Online Virtual Dressing Room) is a full-stack web application that enables users to virtually try on clothing. It combines user-uploaded full-body images with a selected clothing item to generate a photorealistic try-on result using the StableVITON model. The platform also features intelligent clothing search (powered by CLIP), closet management, and browsing history.

This system aims to improve online fashion shopping experiences through: - AI-powered virtual try-on - Text-based outfit search - Smart closet & history tracking - Personalized recommendations

This system integrates computer vision, recommendation systems, and text-image matching to support a complete virtual fitting experience. It is suitable for online retail platforms looking to enhance user experience and reduce return rates.


Key Tasks & Deliverables

Task Achivements
Web-based application with intuitive UI React frontend + Flask backend
Clothing dataset with corresponding text descriptions Organized dataset (tops, bottoms, dresses) with auto-generated captions
Functional clothing retrieval and recommendation systems CLIP-based similarity search and planned collaborative filtering module
Efficient browsing and try-on with integrated text search Connects search โ†’ try-on โ†’ save/share experience

2. Technology Stack

3. Project Structure

The OVDR project is organized into the following main folders:


๐Ÿ“ OVDR/ (Root Project)

OVDR/
โ”œโ”€โ”€ app.py                          # Project root entrypoint (if needed)
โ”œโ”€โ”€ README.md                       # Project overview
โ”œโ”€โ”€ .gitignore                      # Git ignored files


๐Ÿ“ backend/ โ€” Flask backend

โ”œโ”€โ”€ backend/                        # Flask backend
โ”‚   โ”œโ”€โ”€ __init__.py                 # create_app() and app initialization
โ”‚   โ”œโ”€โ”€ config.py                   # Config class for DB, mail, etc.
โ”‚   โ”œโ”€โ”€ exts.py                     # db/mail/cors plugin initialization
โ”‚   โ”œโ”€โ”€ .env                        # Environment variables for secrets
โ”‚
โ”‚   โ”œโ”€โ”€ database/                   # DB schema, data and documentation
โ”‚   โ”‚   โ”œโ”€โ”€ OVDR.sql
โ”‚   โ”‚   โ”œโ”€โ”€ ovdr_structure.sql
โ”‚   โ”‚   โ”œโ”€โ”€ ovdr_data_only.sql
โ”‚   โ”‚   โ”œโ”€โ”€ backup.sql
โ”‚   โ”‚   โ”œโ”€โ”€ ERD.png                 # Database Entity-Relationship Diagram
โ”‚   โ”‚   โ””โ”€โ”€ database.md             # DB documentation
โ”‚
โ”‚   โ”œโ”€โ”€ migrations/                 # Flask-Migrate migration files
โ”‚
โ”‚   โ”œโ”€โ”€ models/                     # Model directories
โ”‚   โ”‚   โ”œโ”€โ”€ clip-vit-large-patch14  # CLIP model
โ”‚   โ”‚   โ””โ”€โ”€ StableVITON/            # StableVITON try-on model
โ”‚
โ”‚   โ”œโ”€โ”€ routes/                     # Flask route blueprints
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py                 # Login/Register routes
โ”‚   โ”‚   โ”œโ”€โ”€ closet.py               # Clothing listing & closet management
โ”‚   โ”‚   โ”œโ”€โ”€ combination.py          # Outfit combination logic
โ”‚   โ”‚   โ”œโ”€โ”€ email.py                # Email sending routes
โ”‚   โ”‚   โ”œโ”€โ”€ forms.py                # WTForms for validation
โ”‚   โ”‚   โ”œโ”€โ”€ history.py              # Browsing history
โ”‚   โ”‚   โ”œโ”€โ”€ process.py              # Try-on image generation
โ”‚   โ”‚   โ”œโ”€โ”€ recommend.py            # Recommendation system
โ”‚   โ”‚   โ”œโ”€โ”€ search.py               # CLIP-based text search
โ”‚   โ”‚   โ””โ”€โ”€ user_image.py           # User image upload & fetch
โ”‚
โ”‚   โ”œโ”€โ”€ scripts/                    # One-time utility scripts
โ”‚   โ”‚   โ”œโ”€โ”€ image_embedding.py
โ”‚   โ”‚   โ”œโ”€โ”€ insert_clothes_data.py
โ”‚   โ”‚   โ”œโ”€โ”€ precompute_similarity.py
โ”‚   โ”‚   โ”œโ”€โ”€ qwen_generate_caption.py
โ”‚   โ”‚   โ”œโ”€โ”€ recommend_clicktime.py
โ”‚   โ”‚   โ”œโ”€โ”€ recommend_sim_algorithm.py
โ”‚   โ”‚   โ”œโ”€โ”€ rename_clothes.py
โ”‚   โ”‚   โ”œโ”€โ”€ save_CLIP_model.py
โ”‚   โ”‚   โ”œโ”€โ”€ search_algorithm.py
โ”‚   โ”‚   โ”œโ”€โ”€ search_api.py
โ”‚   โ”‚   โ””โ”€โ”€ similarity_matrix.npy
โ”‚
โ”‚   โ”œโ”€โ”€ utils/                      # Utility modules
โ”‚   โ”‚   โ”œโ”€โ”€ caption_utils.py        # Caption formatting and generation
โ”‚   โ”‚   โ”œโ”€โ”€ download_utils.py       # Download cloth image from URL
โ”‚   โ”‚   โ”œโ”€โ”€ helpers.py              # URL/path formatting utilities
โ”‚   โ”‚   โ”œโ”€โ”€ image_utils.py          # Save/rename/delete user images
โ”‚   โ”‚   โ”œโ”€โ”€ stableviton_runner.py   # Run StableVITON subprocess
โ”‚   โ”‚   โ”œโ”€โ”€ static_serve.py         # Static image serving utilities
โ”‚   โ”‚   โ”œโ”€โ”€ config.py               # Duplicate? (backend/config.py used)
โ”‚   โ”‚   โ”œโ”€โ”€ exts.py                 # Duplicate? (used for plugin setup)
โ”‚   โ”‚   โ””โ”€โ”€ models.py               # SQLAlchemy models (User, Clothing...)
โ”‚
โ”‚   โ””โ”€โ”€ similarity_matrix.npy       # Precomputed similarity matrix


๐Ÿ“ data/ โ€” Static & dynamic image data

โ”œโ”€โ”€ data/                           # Image assets & user uploads
โ”‚   โ”œโ”€โ”€ clothes/                    # Main clothing image dataset
โ”‚   โ”‚   โ”œโ”€โ”€ tops/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cloth/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cloth-mask/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ model-tryon/
โ”‚   โ”‚   โ”œโ”€โ”€ bottoms/
โ”‚   โ”‚   โ”œโ”€โ”€ dresses/
โ”‚   โ”‚   โ””โ”€โ”€ captions/               # Generated captions JSONs
โ”‚
โ”‚   โ”œโ”€โ”€ users/
โ”‚   โ”‚   โ”œโ”€โ”€ image/                  # Uploaded user full-body images
โ”‚   โ”‚     โ””โ”€โ”€ 1.jpg                 # Named by user_id
โ”‚
โ”‚   โ””โ”€โ”€ combinations/               # Output try-on images
โ”‚       โ””โ”€โ”€ user_1/
โ”‚           โ””โ”€โ”€ 000001.jpg


๐Ÿ“ frontend/ โ€” React-based frontend

โ”œโ”€โ”€ frontend/                       # React frontend
โ”‚   โ”œโ”€โ”€ node_modules/               # Frontend dependencies
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ src/                        # Main frontend code
โ”‚   โ”‚   โ”œโ”€โ”€ App.js / App.css
โ”‚   โ”‚   โ”œโ”€โ”€ ClothesDetail.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ FullCloset.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ History.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ Home.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ Login.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ Register.js
โ”‚   โ”‚   โ”œโ”€โ”€ SendImage.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ TryOn.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ UploadImage.js / .css
โ”‚   โ”‚   โ”œโ”€โ”€ index.js / index.css
โ”‚   โ”‚   โ””โ”€โ”€ setupTests.js / reportWebVitals.js
โ”‚   โ”œโ”€โ”€ package.json                # React project config
โ”‚   โ”œโ”€โ”€ package-lock.json
โ”‚   โ””โ”€โ”€ README.md                   # Frontend description


๐Ÿ“ docs/ โ€” Project documentation

โ”œโ”€โ”€ docs/                           # Project documentation
โ”‚   โ”œโ”€โ”€ code_report.md              # Final report with structure & logic
โ”‚   โ”œโ”€โ”€ api_documentation.md        # Full REST API documentation
โ”‚   โ””โ”€โ”€ Summary_of_quality_assurance.pdf  # Quality testing doc


๐Ÿ“ website/ โ€” Static information site

โ”œโ”€โ”€ website/                        # Static info website
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ minutes/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ projectindex.html           # Presentation site


4. Frontend Architecture

Please refer to JSdoc at https://csprojects.nottingham.edu.cn/grp-team07-gitlab/grp-team07-gitlab-work/-/tree/main/docs/JSdocs

5. Backend Architecture

5.1 Database Configuration

The OVDR backend system is powered by a MySQL-compatible relational database to store users, clothing metadata, try-on results, and behavioral logs. SQLAlchemy ORM is used for seamless object-relational mapping.

Configuration Method

Database credentials and server details are managed through environment variables in a .env file located under ./backend/, loaded via python-dotenv. This prevents hardcoding sensitive credentials in source code.

In backend/config.py, SQLAlchemy URI is constructed as:

SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{USER_NAME}:{PASSWORD}@{HOSTNAME}:{PORT}/{DATABASE}?charset=utf8mb4"

Initial Database Setup

The database schema and sample data are provided under:

To initialize a local MySQL database:

mysql -u root -p
CREATE DATABASE ovdr;
USE ovdr;
SOURCE path/to/ovdr_structure.sql;
SOURCE path/to/ovdr_data_only.sql;

Once completed, update .env with:

HOSTNAME=localhost

Common Development IPs

The following are commonly used IP addresses during internal development: - 10.176.45.0: used under eduroam - 172.19.108.9: used under UNNC-Living If your system fails to connect to these, migrate to local MySQL using the above steps.

Support

If you encounter access issues, please reach out to the maintainer via email: ssyzd4@nottingham.edu.cn.

6. API Documentation

This section documents all RESTful APIs for the OVDR system. Each subsection corresponds to one module.


๐Ÿ” 1. Authentication API (routes/auth.py)

Manage user login and registration logic


POST /login

Description: Authenticate user using username and password.

Form Data:

Field Type Required Description
username string Yes The user's username
password string Yes Plaintext password input

Response:

{
  "success": "Login successful!",
  "username": "testuser",
  "user_id": 1
}

Error Responses: - 400 Bad Request - Username does not exist - 400 Bad Request - Password entered incorrectly - 400 Bad Request - Invalid input (form validation failed)


POST /register

Description: Register a new user with a unique username and encrypted password.

Form Data:

Field Type Required Description
username string Yes Unique username
password string Yes Password to encrypt

Response:

{
  "message": "User registration succeeded!"
}

Error Response:

{
  "error": [["Username already exists."]]
}

GET /captcha/email

Description: Sends a 4-digit verification code to the provided email address. (To be integrated into registration in future)

Query Parameters:

Name Type Required Description
email string Yes Email to receive code

Response:

success

GET /test

Description: Test email sending (hardcoded email). For development/debugging purposes.

Response:

Send successfully

๐Ÿ‘ค 2. User Image API (routes/user_image.py)

Upload or retrieve user full-body photos

POST /upload_image

Description: Upload a user full-body image and update the database with the saved path.

Form Data:

Field Type Required Description
user_id int Yes ID of the user
file file Yes Image file to be uploaded

Response:

{
  "message": "Image uploaded and path updated successfully",
  "image_path": "data/users/image/1.jpg"
}

Errors: - 400: Missing fields or empty file - 404: User not found


GET /get_user_info

Description: Retrieve user profile information including the uploaded image path.

Query Parameters:

Name Type Required Description
user_id int Yes ID of the user

Response:

{
  "user_id": 1,
  "username": "alice",
  "image_path": "data/users/image/1.jpg"
}

Errors: - 400: Missing user_id - 404: User not found


๐Ÿงฅ 3. Closet API (routes/closet.py)

Endpoints for browsing and managing virtual clothing closet.


GET /api/clothes

Description: Retrieve all clothing items filtered by category.

Query Parameters:

Name Type Required Description
category string No Clothing category: tops, bottoms, dresses (default: tops)

Response:

{
  "message": "Success",
  "items": [
    {
      "id": 1,
      "title": "Red Floral Cotton Blouse with v-neckline and short sleeves",
      "image_path": "http://localhost:5000/data/clothes/tops/model-tryon/00001.jpg",
      "closet_users": 3
    }
  ]
}

GET /detail/<clothing_id>

Description: Retrieve detailed info about a specific clothing item.

Path Parameters:

Name Type Description
clothing_id int Clothing item ID

Response:

{
  "message": "Success",
  "item": {
    "id": 1,
    "labels": ["red", "floral", "cotton", "blouse"],
    "title": "Red Floral Cotton Blouse with v-neckline and short sleeves",
    "cloth_path": "http://localhost:5000/data/clothes/tops/cloth/00001.jpg"
  }
}

POST /add-to-closet

Description: Add a clothing item to a user's closet.

Request Body:

{
  "user_id": 1,
  "clothing_id": 5
}

Constraints: - A user can have up to 5 items per category. - Duplicate additions are not allowed.

Success Response:

{
  "message": "Item added to closet successfully!"
}

Error Responses:

{
  "error": "Item already in closet!"
}
{
  "error": "Max 5 tops items allowed. Remove one to add new."
}

GET /get-closet

Description: Get all clothing items in a user's closet, optionally filtered by category.

Query Parameters:

Name Type Required Description
user_id int Yes ID of the user
category string No Category to filter (default: tops)

Response:

{
  "message": "Success",
  "closet": [
    {
      "id": 5,
      "category": "tops",
      "url": "http://localhost:5000/data/clothes/tops/cloth/00005.jpg"
    }
  ]
}

POST /remove-from-closet

Description: Remove a clothing item from a user's closet.

Request Body:

{
  "user_id": 1,
  "clothing_id": 5
}

Response:

{
  "message": "Item removed from closet successfully."
}

GET /data/clothes/<path:filename>

Description: Serve static clothing images from the /data/clothes/ directory.

Example Request:

GET /data/clothes/tops/model-tryon/00001.jpg

Response: - Returns the image directly if found.

- HTTP 404 if the image is missing.

๐Ÿ•˜ 4. History API (routes/history.py)

Track and retrieve browsing history

POST /add-history

Description:
Adds a clothing item to the user's browsing history.
- Prevents duplicate entries. - Keeps only the latest 20 records per user.

Request Body (JSON):

{
  "user_id": 1,
  "clothing_id": 5
}

Response:

{
  "message": "History recorded successfully."
}

Errors: - 400: Missing user_id or clothing_id. - 500: Database error or insertion failure.


GET /get-history

Description:
Retrieves the latest 20 items viewed by a specific user from their browsing history.

Query Parameters:

Name Type Required Description
user_id int Yes ID of the user

Example Request:

GET /get-history?user_id=1

Response:

{
  "message": "Success",
  "history": [
    {
      "id": 5,
      "image": "http://localhost:5000/data/clothes/tops/cloth/00005_top.jpg",
      "title": "Red Floral Cotton Blouse with round neckline and long sleeves",
      "created_at": "2024-03-30 14:23:12",
      "closet_users": 7,
      "category": "tops"
    }
  ]
}

Errors: - 400: Missing user_id. - 500: Database error or malformed caption field.


โœจ 5. Try-On API (routes/process.py)

> Generate virtual try-on results

POST /process_image

Description:
Generate a virtual try-on image by combining a user-uploaded full-body image and a selected clothing item.

You can either: - Provide item_id (recommended): automatically fetch clothing from database. - OR provide cloth_url directly (e.g., from frontend image selection).

Request Body (JSON):

Field Type Required Description
user_id int โœ… Yes ID of the user
item_id int โŒ No Closet item ID to fetch clothing from DB
cloth_url string โŒ No Optional: URL or path to clothing image
item_category string โœ… Yes Type of clothing: "tops", "bottoms", or "dresses"

โš ๏ธ Either item_id or cloth_url must be provided.

Example:

{
  "user_id": 1,
  "item_id": 15,
  "item_category": "tops"
}

Success Response:

{
  "message": "success",
  "image_path": "0000012.jpg"
}

Error Responses:


GET /data/clothes/<filename>

Description:
Serve static clothing images from the /data/clothes/ directory.

Example:
Request: GET /data/clothes/tops/cloth/000001_top.jpg

Returns: Clothing image file.


๐Ÿ” 6. Search API (routes/search.py)

Description:
Search for clothing items using a natural language text query. The backend uses a pretrained CLIP model to match text to clothing image embeddings.

Query Parameters:

Name Type Required Description
query string โœ… Yes Natural language query (e.g. "red hoodie")
top_n int โŒ No Number of results to return (default: 20)

Response: Returns an array of matched clothing items ranked by similarity.

{
  "items": [
    {
      "id": 12,
      "title": "Red Cotton Hoodie",
      "category": "tops",
      "image_path": "http://localhost:5000/data/clothes/tops/cloth/00012_top.jpg",
      "closet_users": 3
    },
    ...
  ]
}

Errors:

Code Description
400 Missing query parameter
500 Internal error (model failure, DB error)

๐ŸŽฏ 7. Recommendation API (routes/recommend.py)

GET /clothing/{id}

{
  "id": 1,
  "name": "White Blouse",
  "category": "tops"
}

GET /recommend/{clothing_id}

{
  "recommendations": [
    {
      "id": 12,
      "url": "http://localhost:5000/data/clothes/tops/000045_top.jpg"
    }
  ]
}

GET /recommend/popular

{
  "recommended_popular": [
    {
      "id": 88,
      "category": "bottoms",
      "url": "http://localhost:5000/data/clothes/bottoms/000088_bottom.jpg"
    }
  ]
}

GET /recommend/user/{user_id}

{
  "personalized_recommendations": [
    {
      "id": 73,
      "category": "dresses",
      "url": "http://localhost:5000/data/clothes/dresses/000073_dress.jpg"
    }
  ]
}

๐Ÿงต 8. Combination API (routes/combination.py)

Save try-on results and show outfit combinations

POST /save-combination

Description: Save a virtual try-on combination to the database.

Request Body (JSON):

Field Type Required Description
user_id int โœ… Yes ID of the user
top_id int โŒ No ID of the top clothing item
bottom_id int โŒ No ID of the bottom clothing item
dress_id int โŒ No ID of the dress item
resultImage string โœ… Yes Relative path to the generated try-on image

Response Example:

{
  "message": "Combination saved!"
}

GET /get-combinations

Description: Retrieve all saved try-on combinations for a given user.

Query Parameters:

Name Type Required Description
user_id int โœ… Yes ID of the user

Response Example:

{
  "message": "Success",
  "combinations": [
    {
      "id": 12,
      "top_id": 3,
      "bottom_id": 5,
      "dress_id": null,
      "url": "data/combinations/user_1/000023.jpg"
    }
  ]
}

DELETE /delete-combination

Description:
Delete a previously saved outfit combination by its ID.

Request Body:

{
  "id": 12
}
Field Type Required Description
id int โœ… Yes The ID of the combination to delete

Response (Success):

{
  "message": "Combination deleted successfully."
}

Error Responses: - 400 Bad Request:

{ "error": "Missing combination ID" }
  


GET /show_image/<userid>/<filename>

Description: Serve generated outfit image from the /data/combinations/user_<userid>/ folder.

Path Parameters:

Name Type Description
userid int User ID, used to locate the user directory
filename string File name of the image (URL-encoded if needed)

Example:

GET /show_image/1/000003.jpg

Returns: The image file if found.


๐Ÿ“ฉ 9. Email API (routes/email.py)

POST /send-email

Description:
Send a try-on result image to a specified email address. This endpoint expects a base64-encoded image (JPEG) and recipient email.

Request Body:

{
  "email": "user@example.com",
  "imageBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}

Response: - On success:

{
  "success": true,
  "message": "Email sent successfully!"
}
{
  "success": false,
  "message": "Missing email or image"
}

Notes: - Make sure your Flask app is configured with SMTP credentials:

MAILSERVER = "smtp.qq.com"
  MAILPORT = 465
  MAILUSERNAME = "youremail@qq.com"
  MAILPASSWORD = "yourapppassword"
  MAILUSE_SSL = True
  

7. Database Design

Overview

The OVDR (Online Virtual Dressing Room) database is designed to store user information, virtual try-on data, and clothing items. It supports features like: - User information (user name, hash password and full body image) - Clothing item storage with corresponding text descriptions (captions) - Virtual try-on outfit combinations - User wardrobe (Closet) management - History tracking


Database Schema

The following tables are included in the OVDR database (obsolete or temporarily unused tables are not included):

1. users (User Table)

Stores user credentials and profile data.

Column Type Constraints Description
user_id INT (PK, AUTO_INCREMENT) Primary key Unique ID for each user
username VARCHAR(255) UNIQUE, NOT NULL Unique username for login
password_hash VARCHAR(255) NOT NULL Hashed password
image_path VARCHAR(255) DEFAULT NULL Path to user's full-body image

2. clothing (Clothing Items)

Stores clothing data and AI-generated descriptions.

Column Type Constraints Description
cid INT (PK, AUTO_INCREMENT) Primary key Unique clothing item ID
category ENUM('tops', 'bottoms', 'dresses') NOT NULL Clothing category
caption JSON NULL AI-generated clothing description
closet_users INT DEFAULT 0 Number of users who added this to wardrobe
cloth_path VARCHAR(255) NOT NULL Path to clothing image

3. closet (User Wardrobe)

Tracks clothing items added to users' wardrobes.

Column Type Constraints Description
id INT (PK, AUTO_INCREMENT) Primary key Record ID
user_id INT NOT NULL, FK โ†’ users(user_id) User who owns this wardrobe
clothing_id INT NOT NULL, FK โ†’ clothing(cid) ON DELETE CASCADE Clothing item

Trigger: Limit closet items to 5 per category

DELIMITER //
CREATE TRIGGER limit_closet_items
AFTER INSERT ON Closet
FOR EACH ROW
BEGIN
    DELETE FROM Closet
    WHERE user_id = NEW.user_id
    AND id NOT IN (
        SELECT id FROM (
            SELECT id FROM Closet
            WHERE user_id = NEW.user_id
            ORDER BY added_at DESC
            LIMIT 5
        ) AS temp_table
    );
END;
//
DELIMITER ;

4. history (User View History)

Tracks which clothing items users have viewed.

Column Type Constraints Description
id INT (PK, AUTO_INCREMENT) Primary key Record ID
user_id INT NOT NULL, FK โ†’ users(user_id) User who viewed clothing
clothing_id INT NOT NULL, FK โ†’ clothing(cid) ON DELETE CASCADE Clothing item
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP Timestamp of viewing

Trigger: Automatically keep only the latest 20 records

DELIMITER //
CREATE TRIGGER limit_history_records
AFTER INSERT ON `history`
FOR EACH ROW
BEGIN
    DELETE FROM `history`
    WHERE user_id = NEW.user_id
    AND id NOT IN (
        SELECT id FROM (
            SELECT id FROM history
            WHERE user_id = NEW.user_id
            ORDER BY created_at DESC
            LIMIT 20
        ) AS temp_table
    );
END;
//
DELIMITER ;

### Entity Relationship Diagram (ERD)

ERD Diagram


8. ORM Data Models

./backend/models.py

This project uses SQLAlchemy ORM to manage database tables. Below is a summary of the key models used in the system.

3.2.1 User Table

Field Type Constraints Description
user_id Integer Primary Key Unique user ID
username String Not Null, Unique Username for login
password String Not Null Hashed password
image_path String Nullable Path to uploaded full-body image

3.2.2 Clothing Table

Field Type Constraints Description
cid Integer Primary Key Clothing item ID
category Enum Not Null 'tops', 'bottoms', or 'dresses'
caption JSON Nullable Structured description of the item
closet_users Integer Default 0 Number of users who added this to closet
cloth_path String Nullable Flat cloth image path
clothmaskpath String Nullable Binary mask path
modeltryonpath String Nullable Model try-on image path

3.2.3 Closet Table

Field Type Constraints Description
id Integer Primary Key Closet entry ID
user_id Integer Foreign Key (User) Owner of this closet item
clothing_id Integer Foreign Key (Clothing) Clothing item stored
added_at TIMESTAMP Auto Timestamp Time added to closet

3.2.4 Combination Table

Field Type Constraints Description
id Integer Primary Key Combination record ID
user_id Integer Foreign Key (User) User who created this outfit
top_id Integer FK (Clothing, Nullable) Top clothing item
bottom_id Integer FK (Clothing, Nullable) Bottom clothing item
dress_id Integer FK (Clothing, Nullable) Dress clothing item
outfit_path String Not Null Path to generated try-on image
created_at TIMESTAMP Auto Timestamp Creation time

3.2.5 History Table

Field Type Constraints Description
id Integer Primary Key History record ID
user_id Integer Foreign Key (User) User who viewed the item
clothing_id Integer Foreign Key (Clothing) Clothing item that was viewed
created_at TIMESTAMP Auto Timestamp Time of browsing

9. Model Integration

10. Deployment & Setup

cd frontend
npm install -g concurrently
npm run dev  # Starts both backend and frontend

11. Team Contributions

This section outlines both the overall system components and the specific responsibilities undertaken by each team member during development.

System Components Developed

Backend Architecture

๐Ÿ‘ค User Management

๐Ÿงฅ Closet Module

๐Ÿ“– Browsing History

๐Ÿง  Caption Generation

๐Ÿ” Search Module (CLIP)

โœจ Virtual Try-On (StableVITON)

๐Ÿงต Combination Management

๐Ÿ“ฉ Email Module


๐Ÿ‘ฅ Individual Responsibilities

Team Member Responsibilities
Zixin Ding Backend architecture, dataset and database, caption generation, user auth, upload, closet and history logic, frontend improvement, bug fixing, Code Report, README, Installation Manual, Final Report
Zhihao Cao StableVITON try-on module, image I/O handling, bug fixing, Final Report
Peini She React frontend development, combination and email routing, bug fixing, User Manual writing

Jinghao Liu & Zihan Zhou Search and Reccomendation module with CLIP, embedding logic, semantic search, Quality Assurance

12. Appendix