Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

SmartSizer: Revolutionizing Online

Apparel Shopping through an AI-


Enabled Instant Size Estimation Web
App

By
Sara Khan

Department of Information Technology


University Name
April, 2024
SmartSizer: Revolutionizing Online
Apparel Shopping through an AI-
Enabled Instant Size Estimation Web
App

By

Sara Khan
001066263-4

Supervised by
Dr. X

Department of Information Technology


University Name
April, 2024
SmartSizer: Revolutionizing Online
Apparel Shopping through an AI-
Enabled Instant Size Estimation Web
App

By
Sara Khan

A Dissertation Submitted in Partial Fulfilment for the Degree of


BACHELORS/ MASTER OF SCIENCE
IN
COMPUTER SCIENCE

Department of Information Technology


University Name
April, 2024
SmartSizer: Revolutionizing Online
Apparel Shopping through an AI-
Enabled Instant Size Estimation Web
App
By
Sara Khan

CERTIFICATE
A THESIS SUBMITTED IN THE PARTIAL FULFILMENT OF THE
REQUIRMENTS FOR THE DEGREE OF BACHELORS
IN COMPUTER SCIENCE

We accept this dissertation as conforming to the required standards

Supervisor Name Final Year Project


Project Supervisor Coordinator

Examiner Name Head of Department


External Examiner

Department of Information Technology


University Nama
April, 2024
Declaration

I hereby declare that this dissertation is neither as a whole or part thereof has been copied
out from any source. If any part of this thesis is proved to be copied or found to be a report
of some other, we shall bear the consequences. No portion of this work presented in the
thesis has been submitted in support of any application from any other degree of
qualification or any other university or any other institute of learning.
I further declare that this research and all the associated documents with this, reports and
all records are submitted as a partial requirement of the degree of Bachelor/ Masters in
Computer Science. We understand and transfer copyrights for these materials to University
Name and we will not sale this research and documents for getting any financial gains. It
is further declared that I developed this and also this thesis is entirely on the basis of our
personal efforts made under the sincere guidance of the project supervisor Name,
Department of Information Technology, University of Name.

Date: April, 2024 Student1 Name Student2 Name


Signature Signature
Plagiarism Certificate

This thesis has been checked for Plagiarism. Turnitin report endorsed by Supervisor is
attached at the end of thesis.

Date: April, 2024


Student Name(s)

Student Signature

Supervisor Signature
Dedicated to

any one the student intends to dedicate


Acknowledgements

Acknowledgement text start here. It should contain acknowledging people who


facilitated the student in carrying out the project.
Abstract text start here. It should contain what exactly the student is about to do in thesis.
Table of Contents

Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Dedication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 This is the heading of the chapter . . . . . . . . . . . . . . . . . . . . . . . . . . 1
This is the sub-heading . . . . . . . . . . . . . . . . . . .
1.1.1 . . . . . . . . 1
Chapter 2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 3 Proposed System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.1 Requirement Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Chapter 4 Evaluation and Results . . . . . . . . . . . . . . . . . . . . . . . . 36


4.1 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.2 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Chapter 5 Conclusion and Future Work. . . . . . . . . . . . . . . . . . . . . 50
5.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
List of Figures

Figure Description Page


1 Figure 1 description shall be written here 1
2 Figure 2 description shall be written here 2
List of Tables

Table Description Page


1 Table 1 description shall be written here 1
2 Table 2 description shall be written here 2
Chapter 1

Introduction

In a world where every moment counts, online shopping becomes the time-saving magic
wand, transforming our shopping experience into a swift and efficient affair in our bustling
lives. Online shopping platforms have been attracting a continuously growing number of
customers over the years since their introduction at the turn of the century [1]. In the ever-
evolving landscape of online apparel shopping, the search for the perfect fit has been a
persistent challenge for both consumers and retailers alike. Ill-fitting garments not only
lead to customer dissatisfaction but also result in increased return rates, contributing to the
environmental impact of the fashion industry [2]. Recognizing this critical issue, a
revolutionary solution has emerged an AI-enabled body measurement system designed to
redefine the online shopping experience by ensuring precise sizing and a perfect fit for
every individual.
This innovative system utilizes advanced computer vision algorithms and machine learning
models to analyze a user's uploaded images or videos, extracting precise measurements and
anatomical details [3]. Gone are the days of relying solely on generic size charts, as this
AI-driven technology promises to create a personalized and tailored shopping experience
for each customer.
The potential impact of this technology extends far beyond individual satisfaction. By
minimizing the chances of ill-fitting garments, This thesis aim’s to introduce a Real time
AI-enabled body measurement web-based application can significantly reduce return rates,
thereby contributing to a more sustainable and environmentally friendly fashion industry.
The system not only enhances the customer's confidence in their purchase but also
promotes a positive relationship between consumers and brands.

1.1 Problem

The online apparel industry has quickly shifted with the rise of fast fashion where more
and more consumers are seeking more stylish clothing at affordable prices through digital
platforms. In the sphere of online apparel shopping, a persistent challenge has been the lack
of an accurate and standardized method for determining individual body measurements.
The traditional reliance on generic size charts has led to a considerable margin of error,
resulting in ill-fitting garments, customer dissatisfaction, and increase return rates. This
issue not only effects the overall online shopping experience but also poses environmental
concerns due to increased product returns. To address this significant problem, there is an
urgent need for a revolutionary solution an AI-enabled body measurement system that
leverages advanced computer vision and machine learning to provide precise sizing and a
perfect fit, ultimately transforming the online apparel shopping landscape.
On the other hand, online fashion retailers also face substantial return rates that not only
have a significant financial impact but also affect customer satisfaction rates as it can lead
to a negative shopping experience, preventing customers from making future purchases.
‘The problems the customer experienced with the fit or the product meant that they were
unsatisfied with the purchase and returned it’ (Luce, 2019). Another issue this solution will
tackle is the impact of returning items due to size-related issues which will reduce the
amount of environmental consequences, including a reduction in carbon emission from
delivery services, contributing to sustainability concerns. The benefits of all these will lead
to an increase in profit margins as it will reduce the return rates and the associated
operational costs including return processing, potential restocking, and reduction in staff
hours. The product offers a modern way of online shopping to leverage AI technology and
utilize body measurement technologies to bridge the gap between a satisfactory online
shopping experience and the traditional in-store fitting room experience by developing a
system that accurately measures a customer and produces an accurate measurement result
and recommended clothing size that is tailored to each unique individual body type and
dimensions which ultimately leads to an innovative change in the online apparel shopping
industry.

1.2 Role of AI in Revolutionizing Online Apparel Shopping

The role of Artificial Intelligence (AI) in revolutionizing online apparel shopping


is substantial and multifaceted. AI technologies are reshaping the entire shopping
experience, offering unprecedented customization, personalization, and efficiency.
Here are key aspects of how AI is influencing and transforming the landscape of
online apparel shopping.

1. Personalized Recommendations
AI algorithms analyze customer preferences, purchase history, and browsing behavior to
provide highly personalized product recommendations. This enhances the shopping
experience by presenting users with items that align with their style and preferences.

2. Virtual Try-Ons
AI-powered virtual try-on solutions allow customers to visualize how clothing items will
look on them without physically trying them on. This technology uses computer vision to
simulate the fit and appearance of clothing on a user's body.

3. Size and Fit Solutions


AI is addressing the challenge of sizing by providing advanced size recommendation
systems. Through the analysis of historical data and user inputs, AI algorithms can suggest
the most accurate size for a customer, reducing the likelihood of returns due to poor fit.
4. Chatbots and Virtual Assistants
AI-driven chatbots and virtual assistants enhance customer support and engagement. They
can assist shoppers in finding products, offer styling advice, and provide real-time
assistance, creating a more interactive and responsive online shopping environment.

5. Predictive Analytics
AI enables retailers to forecast trends, demand, and inventory needs more accurately.
Predictive analytics helps optimize supply chain management, ensuring that popular items
are adequately stocked, reducing both overstock and understock situations.

6. Fraud Detection and Security


AI algorithms contribute to enhancing the security of online transactions by detecting
fraudulent activities. Machine learning models analyze patterns and behaviors to identify
potential threats, ensuring a safer shopping experience for customers.

7. Visual Search
Visual search powered by AI allows users to search for products using images rather than
text. This technology enables customers to find similar items or explore related styles based
on the appearance of a particular garment.

8. Dynamic Pricing
AI-driven dynamic pricing models analyze market trends, competitor pricing, and
customer behavior to adjust prices in real-time. This helps retailers remain competitive and
optimize revenue based on demand fluctuations.

9. Recommendation Engines
Beyond personalized product recommendations, AI-driven recommendation engines
enhance cross-selling and upselling strategies. By understanding user preferences, these
engines suggest complementary items, increasing the average order value.

10. Customer Insights and Feedback Analysis


AI tools analyze customer feedback, reviews, and social media sentiments to provide
retailers with valuable insights into consumer preferences. This information can be used to
refine product offerings and improve the overall shopping experience.
1.3 Benefit of Smart Sizer Application

Benefit of Smart Sizer Application are as follows.


1. Enhanced Customer Satisfaction and Reduced Returns

The Smart Sizer Application addresses the longstanding issue of inconsistent sizing
in online apparel shopping, significantly improving the accuracy of body
measurements. This results in a notable reduction in ill-fitting garment purchases,
leading to enhanced customer satisfaction and a substantial decrease in product
returns.

2. Sustainable Practices and Environmental Impact

By minimizing the frequency of returns, the Smart Sizer Application contributes to


sustainable fashion practices. This reduction in return rates not only lowers
operational costs for retailers but also significantly decreases the environmental
impact associated with excess packaging, transportation, and the overall carbon
footprint of the fashion industry.

3. Utilization of Cutting-Edge AI Technology

The Smart Sizer Application leverages the rapid advancements in artificial


intelligence, specifically in computer vision and machine learning. By integrating
these technologies, the application transforms the online apparel shopping
experience, offering users a precise and personalized body measurement solution
that aligns with current technological trends.

4. Personalized Shopping Experience

Meeting the growing demand for personalization in online shopping, the Smart
Sizer Application delivers a tailored experience by providing accurate body
measurements. Users can enjoy a customized fit for clothing items, aligning with
modern consumers' expectations for personalized and efficient online retail
interactions.

5. Competitive Advantage for Retailers

Retailers adopting the Smart Sizer Application gain a competitive edge by offering
customers a more accurate and personalized sizing experience. This not only
improves customer satisfaction but also fosters loyalty, positioning these retailers
as leaders in providing an innovative and customer-centric online shopping
environment.
6. Streamlined Shopping Process with Convenience and Efficiency
The Smart Sizer Application streamlines the online shopping process by providing
users with a convenient and efficient solution to determine accurate body
measurements. This user-friendly feature enhances overall efficiency and
convenience, making the application an indispensable tool for a seamless shopping
experience.

7. Alignment with Tech-Savvy Consumer Expectations

The integration of AI into the online apparel shopping experience through the Smart
Sizer Application aligns with the increasing trend of technology in the fashion
industry.

8. Promotion of Sustainable Fashion Industry Practices

Through a substantial reduction in returns, the Smart Sizer Application contributes to more
sustainable and eco-friendly practices within the fashion industry. This aligns with the
global push for environmentally conscious initiatives, making the application an advocate
for positive environmental impact in online retail.
1.4 Motivation

The motivation behind this work is rooted in the desire to revolutionize the online apparel
shopping experience by addressing the persistent challenges of sizing inconsistency and
high return rates. The frustration and dissatisfaction among consumers due to ill-fitting
garments, coupled with the environmental impact of increased returns, highlight the
urgency for an innovative solution. Leveraging the advancements in AI technology, this
project aims to develop a precise body measurement system, offering users a personalized
and accurate sizing experience. By minimizing returns, improving customer satisfaction,
and aligning with sustainability goals, the motivation is to contribute to a more seamless
and environmentally conscious future for online fashion retail.

1.5 Objective

The following outlines the objectives of this thesis that aims to address the problem of ill-
fitting garments and enhance the online apparel shopping experience through the
implementation of an AI-enabled body measurement system. This project is designed with
the purpose to help person to avoid the frustration of receiving an ill-fitting garment by
revolutionizing the way we choose sizes for our clothes. We aim to automate the process,
ensuring a perfect fit every time, transforming the online shopping experience, as well as
reduce the quantity of clothing material, wasted.

The first objective is to develop an algorithm to detect important for the detection points
of the human body and used a method of vector magnitude calculation to provide a correct
measurement data.
1. With the assistance of an AI model, we have developed an algorithm that captures
a human image only when the person is in a standing position, and their hands,
head, and feet are detected within the frame.
2. After capturing the image, the PyTorch machine learning framework will be used
to subtract the background and convert the person's body into a white mask.
3. The output of the white mask image will be further processed, and the image will
be divided into parts. Subsequently, the length of each part will be measured.
The second objective is to design an intuitive and user-friendly interface for the AI-enabled
body measurement system to ensure ease of use for consumers.
1. The interface will be provide users, information about where to stand, the
recommended pose to adopt in front of the camera, and suggestions on what to wear
to achieve optimal results.
2. After capturing the image, the user enters their height, and the model begins
processing to provide the sizes of the person's body parts, including the head,
shoulders, hands, torso, chest, and legs.
The third objective of the project to test the accuracy of the system in different scenarios.

1.6 Structure

This thesis will be structured as follows. In Chapter 2, I will present a literature review that
discusses the functioning of existing systems. This section will delve into the
methodologies employed by these systems and highlight their limitations.

Chapter 3 focuses on the practical solution developed in this work. The program will be
explained component-wise, starting with the proposed methodology that we are using in
this project for implementing the body measurement web based app for online shoping. I
will also discuss the tools that we used in this project such as Python, OpenCV, OpenPose,
Pytorch, YOLO, and Flask framework. Finally, I will conclude the chapter providing an
explanation of the algorithmic realization of the program.

In Chapter 4, we will evaluate the performance of the tool. The analysis will specifically
focus on system testing.

In chapter 5, I will conclude this work by discussing the results and their relevance in the
current state of the art. I will also address the limitations of the tool and provide an outlook
on potential future extensions. Furthermore, I will provide my opinion on which use cases
would benefit the most from the tool.
Chapter 3

Analysis and Requirement Specification

In this section, the analysis process is outlined, encompassing the identification and
categorization of both functional and non-functional requirements. The analysis initiation
involved a brainstorming session, aiding in the delineation of fundamental aspects of the
application. This encompassed defining the application's primary functionalities,
elucidating its purpose, providing guidance on user interactions, specifying the required
input for precise measurements, detailing the system's processing of user input, and
outlining the expected output that the system should generate. The outcome of this analysis
session forms the foundational understanding of the application's core functionalities and
operational characteristics.
This analysis encompasses not only the specific actions the system must perform but also
the non-functional attributes that define its performance, security, and overall user
experience. This comprehensive approach ensures that SmartSizer is not merely a tool but
a reliable and user-friendly solution that aligns with the diverse needs of online shoppers.
Let us explore the functional requirements that form the backbone of this groundbreaking
application.

3.1 Functional Requirements


SmartSizer stands at the forefront of revolutionizing online apparel shopping by
introducing an AI-enabled instant size estimation web application. This innovative system
aims to redefine user experiences by providing accurate and personalized clothing size
recommendations. Following are the intricate details of its functionalities.

1. Interface Introduction and Purpose:

The interface should include a dedicated section that serves as an introduction to


the SmartSizer app. This section aims to provide users with a concise yet
comprehensive overview of the application's purpose, functionality, and the value
it brings to online apparel shopping.

App Overview

Briefly describe the core purpose and features of the SmartSizer app.

User Benefits

Highlight the advantages users gain by utilizing the app, emphasizing aspects such
as personalized size recommendations and enhanced online shopping experiences.

2. Guidance on Usage:

Within the introduction section, incorporate clear guidance on how users can
effectively use the SmartSizer web app. This should serve as a starting point for
users, ensuring they understand the application's primary functions and how to
navigate through its features.

Step-by-Step Instructions

Provide step-by-step instructions on initiating the size estimation process, guiding


users from accessing the app to receiving accurate size predictions.

Navigation Tips

Include tips on navigating the application, emphasizing key buttons, menus, and
sections relevant to size estimation.

3. Visual Elements:

Enhance the introduction section with visual elements to make it more engaging
and user-friendly. Incorporate graphics, images, or icons that represent the
application's purpose and functionality.

Infographics

Use infographics to visually explain the size estimation process and how the app
works.
4. Call-to-Action:

Include a clear call-to-action within the introduction section, encouraging users to


proceed with using the SmartSizer app for their size estimation needs.

"Get Started" Button

Place a prominent button or link that directs users to the next steps, initiating the
size estimation process.

5. Real time image processing:

Introducing a cutting-edge image capture tool that seamlessly integrates with your
webcam, providing users with an alternative and hassle-free experience for
capturing images. The tool not only allows you to snap photos effortlessly through
your webcam but also guides you on the correct posture through a real-time human
body outline displayed on the webcam frame.

Guidance on Posing

The webcam frame will dynamically show an outline of the human body, guiding
users on how to stand in the correct position for the best image capture. This feature
ensures that users can effortlessly strike the optimal pose, resulting in accurate
measurements.

6. Height Input:

To enhance precision, we've included a "Enter Your Height" button. Users can click
on this button and input their height in centimeters. To make it crystal clear, we use
bold text to instruct users explicitly to enter their height in centimeters.

Guidance for Entering Height

Bold Text: "Enter your height (in cm):"

Users simply input their height in centimeters, providing the tool with the necessary
information for accurate body measurements.

7. Results:

Upon entering the height, the interface will display the user's accurate size along
with recommended T-shirt and jeans sizes. This tailored approach ensures that users
not only capture the perfect image but also receive personalized size
recommendations based on their unique body measurements.

3.2 Non Functional Requirement.


Non-functional requirements describe the qualities or characteristics that define how a
system performs its functions. These requirements are not directly related to specific
behaviors of the system but focus on attributes such as performance, security, usability,
and reliability. Here are some common categories of non-functional requirements for a
system like SmartSizer.

1. Performance

Response Time

The system should generate size recommendations within 5 seconds after the user
submits the image and enters their height.\

2. Usability

User Interface
The user interface must be intuitive, guiding users through the SmartSizer process
with clear instructions and easy navigation.

Error Handling

The system should provide informative error messages in case of user mistakes or
system failures.

Accessibility

The application should be accessible to users with disabilities, following


established accessibility standards.

3. Security

Secure Communication

All communication between the web application and the SmartSizer server should
be encrypted to prevent data interception.

4. Compatibility

Web Browser Compatibility

The application should be compatible with commonly used web browsers,


including Chrome, Firefox, Safari, and Edge.

5. Portability

Cross-Platform Compatibility

The application should work seamlessly across different operating systems such as
Windows, macOS, and Linux.

3.3 Proposed Methodology


The proposed methodology for the SmartSizer system introduces a streamlined approach
to user input and image capture, deviating from the previous system's requirement of front
and side images along with user details such as age and weight. In the proposed system,
users are now prompted to capture a single front image from webcam of their body. This
reduction in the number of required images simplifies the user experience, aiming to
increase user engagement and adoption. Additionally, the system innovatively shifts the
burden of estimating height from automated algorithms to direct user input. During the size
estimation process, users are now prompted to provide their height, enhancing the accuracy
of predictions. To guide users through this simplified process, the interface offers real-time
feedback and clear instructions for optimal image capture and accurate height input. The
deep learning algorithm driving the size estimation process are dynamically adjusted to
accommodate this streamlined approach. With a focus on user convenience and accuracy,
the proposed system aims to deliver a more efficient and user-friendly experience in the
realm of online apparel shopping.
In our approach, (I) the system captures an image of a person only when they are standing
in a A-pose, with their hands, feet, and legs detected using a webcam camera and a deep
learning model. (ii) Subsequently, to achieve accurate results, the captured image is
converted into a black background, and the detected person's area in the image is
transformed into a white mask. (iii) The system then prompts the user to input their height
to facilitate the calculation of different body part sizes. Finally, the results, including the
estimated sizes of various body parts, are displayed on the user's screen. (iv) Build user-
friendly GUI for users to interact our system easily. The overall pipeline is illustrated in
Figure 1. As part of the data capture process users should wear T-shirt and jean. In terms
of poses, our system requires a so-called “A-pose” for the frontal view capture, while there
are no restrictions for the side views.

3.3.1 Captured Image for Body Measurement.

The SmartSizer Image Capturing process is implemented using Python and leverages
computer vision techniques to analyze video frames from a webcam. The code incorporates
the OpenCV library and employs the YOLOv7 object detection model to identify and label
objects of interest, such as persons, hands, and legs. Additionally, a Haarcascade classifier
is utilized for detecting the entire human body.

The program operates by continuously capturing video frames, applying object detection
algorithms to recognize relevant objects, and drawing bounding boxes around them for
visual representation. A key feature of the code is its ability to assess whether a person is
standing properly based on the detected objects. If the specified conditions are met, the
program saves the frame.

To facilitate easy tracking and retrieval, the captured images are saved in a designated
directory. The code effectively combines YOLOv7-based object detection and
Haarcascade-based human body detection to monitor and capture specific scenarios from
a live video feed, contributing to the overall functionality of the SmartSizer system.

Algorithm 1: Captured Image for Body Measurement


Required: cv2, numpy, os
Ensure: The file are present in specified path.

1. Define save_image(frame, save_dir):


2. save_path = os.path.join(save_dir, "captured_image.jpg")
3. cv2.imwrite(save_path, frame)
4. print("Image captured!")
5. Define is_upper_body_detected(gray_frame, upper_body_cascade):
6. upper_body = upper_body_cascade.detectMultiScale(gray_frame, scaleFactor=1.1,
minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
7. return len(upper_body) > 0
8. Define is_lower_body_detected(gray_frame, lower_body_cascade):
9. lower_body = lower_body_cascade.detectMultiScale(gray_frame, scaleFactor=1.1,
minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
10. return len(lower_body) > 0
11. Define is_person_standing_properly(indexes, class_ids, classes, frame,
human_cascade):
12. gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
13. if is_human_body_detected(gray_frame, human_cascade):
14. for i in range(len(indexes)):
15. if classes[class_ids[indexes[i]]] in ['person', 'hand', 'leg']:
16. return True
17. return False
18. Define roi_find(frame, save_dir, human_cascade):
19. net = cv2.dnn.readNet("/path")
20. net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
21. if is_person_standing_properly(indexes, class_ids, classes, frame, human_cascade):
22. save_image(frame, save_dir)
23. cap = cv2.VideoCapture(0)
24. save_directory = "captured_image"
25. os.makedirs(save_directory, exist_ok=True)
26. human_cascade = cv2.CascadeClassifier( '/path')
27. while True:
28. ret, frame = cap.read()
29. result_frame, indexes = roi_find(frame, save_directory, human_cascade)
30. cv2.imshow('Frame', result_frame)
31. if cv2.waitKey(1) & 0xFF == ord('q'):
32. break

33. cap.release()
34.cv2.destroyAllWindows()

3.3.2 Human Body Detection and Segmentation

Our goal is to measure various body parts such as arms, legs, shoulders, torso, and more
from an input image of a person, ensuring differentiation between upper and lower body
segments. The methodology involves a multi-step process utilizing OpenCV and
OpenPose.

We used image preprocessing technique Gaussian blur and thresholding to create a binary
mask, effectively isolating the human body contours. The contours are then detected, and
Regions of Interest (ROIs) are extracted based on the user's specified height. OpenPose is
utilized to obtain keypoint coordinates representing different body parts.

Then we proceeds to calculate the lengths of body parts such as arms, legs, shoulders, and
torso by leveraging these keypoints and the user's height. Notably, a Haar Cascade
classifier is employed to detect the head, and its length is determined, establishing a
proportion for further body part measurements.

To enhance interpretability, the lengths are converted from pixel values to centimeters,
providing a comprehensive set of body measurements. PyTorch is used for mask creation
and incorporating additional image display functionalities. This implementation effectively
achieves our goal of segmenting the human body into specific regions of interest,
facilitating detailed body part measurements.
Figure 1: Flowchart of SmartSizer Application
3.3.3 Calculation of different body part sizes

In our approach to body measurements, we employed computer vision techniques to


analyze a pre-existing binary mask image. This involved extracting the X and Y
coordinates of white pixels, outlining the contours of a person. Key points on the image,
including the top point and additional test points, were then visualized. The body was
segmented into different regions of interest (ROIs) such as the head, chest, stomach, and
hips, based on the user's specified height. Subsequently, we calculated the lengths of these
body parts in pixels and converted them to centimeters, offering a comprehensive set of
body measurements. Additional functionalities, such as excluding unwanted regions and
utilizing OpenPose for keypoint detection, were integrated into the process. Finally, the
processed image was displayed with visualizations of identified body parts and
measurements.

3.3.4 Interface Design for SmartSizer Application

In our project, we leverage the Flask framework to deploy a Yolo model with a user-
friendly interface. Flask, being a lightweight and versatile web framework for Python,
allows us to seamlessly integrate our deep learning functionality with a web application.
First, we create an instance of the Flask class and define the introductory route to welcome
users to our application. Subsequently, we implement routes to handle both GET and POST
requests. For the deep learning part, we incorporate a model and create an endpoint to
receive user input. Using HTML forms, we design a simple yet effective interface that
enables users to input data for model prediction. The backend, powered by Flask, processes
this input, invokes the deep learning model, and returns the predictions to the user. This
amalgamation of Flask and deep learning not only streamlines deployment but also
provides an accessible and interactive platform for users to interact with the model. Figure
2 show the Interface Design for SmartSizer Application.
Figure 2: Application flow

Chapter 4

Design

SmartSizer is an innovative web application that utilizes artificial intelligence to provide


instant and accurate size estimations for online apparel shoppers. The goal is to enhance
the online shopping experience by reducing sizing-related issues and improving customer
satisfaction. In this thesis we focus on test design techniques (TDTs), which is the core of
testing. Applying a TDT to a Smart Sizer system, results in a test case used to execute the
system and get a verdict. Testing has multiple goals, e.g. ensuring that specific paths
execute correctly, but also attempting to find faults. Furthermore, testing is itself a way to
measure some qualities of the system, by combining several test case executions in suites
that exercises the system. This can result in additional information about the system, in
terms of measures of the code coverage, performance, robustness, usability, functionality
or other aspects and qualities of a software system. The main difference between just
executing the system and testing is that the test case must include a verdict. A verdict means
a way to determine if the system behaves as expected with respect to the specific aspect
and context or if the system fails. Failing means that the expected service is not delivered,
or the system does not behave according to expectation, specification or some defined
measurement or norm.

4.1 Test Design Techniques


The two types of testing serve different purposes in the software development life cycle.

i. Static Testing

It is performed before the code is executed and includes activities like code reviews,
inspections, walkthroughs, and document reviews.

ii. Dynamic Testing

It is performed during the execution of the code and includes activities like unit testing,
integration testing, system testing, and acceptance testing.

For building the SmartSizer system, we have employed both testing techniques. Initially,
we conducted a thorough review of the existing documentation, gaining an understanding
of the methodology, and creating comprehensive test cases for our system. Subsequently,
we applied the walkthrough technique to evaluate and refine our system. As the
development progressed, during the code execution phase, we executed various levels of
testing including unit testing, integration testing, and acceptance testing. This
comprehensive approach ensures that the SmartSizer system is thoroughly tested at
different stages of development, from individual components to the integrated system, to
meet high-quality standards.

4.1.1 Test Cases

Creating test cases for a system like SmartSizer involves considering various scenarios to
ensure thorough testing. Below are test cases for SmartSizer, the AI-enabled instant size
estimation web app. Table 1 show the test cases of SmartSizer Application.

Project Name Test Case Author


Priority High
Test Case Reviewer
Description Test Case Version
Test Objective
Test Execution Date

Test Case Expected


Test Case ID Description Pre-Condition Test Step Actual Results Pass/Fail
Name Result
Ensure Users should
Verify that the The SmartSizer app
access the web app
Launch SmartSizer SmartSizer app 1. Open the should open without
TC001 by navigating to a
App launches SmartSizer app. errors, displaying the
specific URL using a
successfully. introduction screen.
web browser
Check that the The size guide should
1. Navigate to the
size guide is be displayed,
SmartSizer app is introduction screen.
TC002 Access Size Guide accessible from providing clear
launched. 2. Locate and select
the introduction instructions on how to
the size guide.
screen. use SmartSizer.
1. Access the tool
to capture an
Verify that users
image. An image should be
can capture an
SmartSizer app is 2. Follow on- captured successfully
TC003 Capture Image image using the
launched. screen instructions when the user is
image capture
to stand in the right positioned correctly.
tool.
way and capture
the image.
Test the
The system should
functionality to Image is
1. Press the button accurately generate a
TC004 Generate Mask generate a mask successfully
to generate a mask. mask based on the
based on the captured.
user's body shape.
captured image.
Validate the input 1. Enter the user's The system should
Mask is successfully
Enter Height of the user's height in accept valid height
generated.
TC005 height in centimeters. input.
centimeters.

Test the
functionality to The system should
generate size provide accurate size
1. Press the button
Generate Size recommendations Height is recommendations for
to generate size
Recommendations based on the successfully entered. the user's overall size
recommendations.
captured image and specific clothing
and entered items.
TC006 height.
Introduce an error
1. Enter an invalid
by entering The system should
Error Handling - SmartSizer app is height (e.g., non-
invalid height and display an appropriate
Invalid Height launched. numeric
check the error message.
characters).
TC007 system's response.

Table 1: Test cases of SmartSizer Application.

4.1.2 Application Walkthrough

A walkthrough is a step-by-step examination of a system or application to evaluate its


functionality, user interface, and overall user experience. For the SmartSizer app, we
conducted walkthrough to assess its usability and effectiveness.
To create a walkthrough technique, we performed these steps in Chapter 6 we explain the
documented walkthrough results.

1. Review Introduction Section of SmartSizer

Begin with an introduction to SmartSizer, providing users with a brief overview of


the size estimation tool and its purpose in revolutionizing online apparel shopping.
2. Size Guide Explanation:

Walk users through the size guide, explaining how to use SmartSizer effectively.
Highlight key instructions, such as standing posture, capturing images, and entering
additional information like height.
3. Live Video Analysis

Test the tool captures a live video feed from a webcam. This is likely achieved
using OpenCV, a popular computer vision library in Python.
4. Generate Mask

Direct users to press the button to generate a mask based on the captured image.
Evaluate the speed and accuracy of the mask generation process.
5. Height Entry

Instruct users to enter their height in centimeters. Assess the user interface for
simplicity and clarity. Verify that the system gracefully handles valid and invalid
height entries.
6. Results Display
After entering the height, guide users through the results display. Assess how
SmartSizer presents the user's size and provides recommendations for specific
apparel items like T-shirts or jeans.
7. Usability and Navigation
Evaluate the overall usability of the SmartSizer interface. Check for intuitive
navigation, clear labels, and user-friendly design elements. Ensure that users can
easily move through the size estimation process without confusion.
8. Performance Testing

Assess the overall performance, responsiveness, and speed of the SmartSizer


application. Verify that the system generates accurate size recommendations within
an acceptable timeframe.

Through this walkthrough technique, we gain valuable insights into the user experience,
usability, and performance of SmartSizer, helping refine and enhance its functionality for
a more seamless and effective sizing process in online apparel shopping.

4.1.3 Unit Testing

Unit testing is a crucial aspect of software development, ensuring that individual


components or units of code function as intended. When it comes to testing a feature like
SmartSizer in an online apparel shopping application, which involves AI-enabled instant
size estimation.

To create a test for the SmartSizer App, we used a testing framework like pytest.

4.1.3.2 Testing process

In unit testing, assertions play a crucial role in ensuring that the actual outcomes align with
the expected results. If an assertion fails during the execution of a test, it signals a deviation
from the anticipated behavior, prompting the testing framework to report the failure. In the
context of SmartSizer, the code responsible for detecting a person standing in an A-pose
undergoes thorough validation through four assertions.

The "test_save_image" function employs an assertion to verify the existence of the saved
image file at the specified path. The test passes if the condition holds true, indicating that
the image file is successfully saved; otherwise, the test fails. Figure 3 shows an example of
the save image function.
Figure 3 Example of the save image function.

In the "test_is_human_body_detected" function, an assertion checks whether the result of


the "is_human_body_detected" function is an instance of a boolean (bool). A successful
test indicates that the function returns a boolean value, while failure suggests a deviation
from this expected behavior. Figure 4 shows an example of the test is human body detected
function.

Figure 4: Example of the test is human body detected function.

Similarly, the "test_is_person_standing_properly" function utilizes an assertion to confirm


that the result of "is_person_standing_properly" is indeed a boolean. Success implies that
the function produces a boolean output, whereas failure signals a mismatch in the expected
return type. Figure 5 shows an example of the test is person standing properly function.

Figure 5: Example of the test is person standing properly function.

For the "test_roi_find" function, two assertions are employed to ensure that the results of
"roi_find" are instances of NumPy arrays (np.ndarray). The test passes only if both
conditions are met, providing confidence in the correct functionality of the "roi_find"
method. Any deviation leads to test failure, highlighting potential issues in the code. Figure
6 shows an example of the test roi find function.

Figure 6: Example of the test roi find function.

When we run your test suite, we achieved the below figure output indicating which all 4
tests passed in 0.12 seconds. Figure 7 shows output of unit test.
4.2 Design Evaluation

SmartSizer's design undergoes a thorough evaluation across key dimensions to ensure its
efficiency, effectiveness, and applicability in the context of instant size estimation.
Efficiency is assessed through the optimization of image processing algorithms and the
seamless integration of the webcam capture tool, aiming for minimal processing time and
resource utilization. Effectiveness is measured by the accuracy of size predictions and the
clarity of guidance provided to users during the process. Applicability is considered by
evaluating the tool's adaptability to diverse body shapes, stances, and clothing types.
Additionally, robust fault, error, and failure handling mechanisms are implemented,
ensuring the system gracefully handles unexpected scenarios, such as input discrepancies
or communication errors, without compromising the user experience. This holistic
approach to design evaluation reinforces SmartSizer's reliability, usability, and overall
effectiveness in revolutionizing online apparel shopping through AI-enabled instant size
estimation.

4.2.1 Efficiency

Efficiency is a critical aspect of SmartSizer's design, focusing on optimizing resource


utilization and minimizing processing time to provide a swift and seamless user experience.
The image processing algorithms employed for capturing and analyzing user images are
meticulously crafted to operate efficiently, ensuring rapid size estimation without
compromising accuracy. The system prioritizes real-time responsiveness during the
webcam image capture phase, utilizing streamlined code and parallel processing
capabilities where applicable. Additionally, SmartSizer incorporates intelligent caching
mechanisms to store frequently used data, further enhancing response times for recurrent
user interactions. This dedication to efficiency not only enhances the speed of size
estimation but also contributes to a more fluid and enjoyable online apparel shopping
experience for users.

4.2.2 Effectiveness

Effectiveness is a central focus in SmartSizer's design, ensuring the accurate and reliable
estimation of user sizes while providing a user-friendly and intuitive interface. The
effectiveness of the system is reflected in its ability to precisely interpret user images
captured through the webcam, considering factors such as body measurements, posture,
and clothing preferences. SmartSizer employs advanced AI algorithms that leverage
machine learning to continually improve accuracy based on user feedback and diverse
datasets. The user interface is designed with clarity and guidance, facilitating users in
capturing images correctly and entering additional information, such as height, seamlessly.
Regular updates to the system, incorporating the latest advancements in AI and image
processing technologies, contribute to sustained effectiveness in delivering precise size
recommendations for both apparel and body measurements. This commitment to
effectiveness positions SmartSizer as a reliable and trustworthy tool in revolutionizing the
online apparel shopping experience.

4.2.3 Applicability

Applicability is a pivotal consideration in the design of SmartSizer, ensuring that the size
estimation tool is versatile and adaptable to diverse user scenarios within the realm of
online apparel shopping. SmartSizer's applicability extends across a wide range of body
shapes, stances, and clothing types, accommodating the diverse preferences and
characteristics of users. The system is designed to intelligently interpret various clothing
styles, from casual wear to formal attire, enhancing its usefulness across different fashion
categories. The applicability also encompasses the tool's compatibility with different web
browsers and operating systems, ensuring a seamless experience for users on various
platforms. Moreover, SmartSizer's user interface is intuitively designed, making it
accessible and user-friendly for individuals with varying levels of technological expertise.
This broad applicability makes SmartSizer a versatile solution, effectively revolutionizing
the sizing experience for users engaging in online apparel shopping across a spectrum of
preferences and styles.

4.2.4 Fault, Error, Failure

SmartSizer's design incorporates robust mechanisms to handle faults, errors, and potential
failures, ensuring a resilient and reliable user experience. Fault tolerance is achieved
through the implementation of error-checking and validation protocols at each stage of the
size estimation process. The system anticipates and mitigates faults, such as unexpected
user inputs or disruptions in the communication between the web application and
SmartSizer, preventing them from leading to system failures.

In terms of errors, SmartSizer employs thorough input validation to detect and gracefully
handle any inaccuracies or inconsistencies in user-provided data. Clear and informative
error messages are displayed to guide users in correcting their inputs, minimizing
frustration and enhancing the overall user experience.

Furthermore, SmartSizer is designed with a focus on failure recovery. In the event of


unexpected system failures or disruptions, the application is equipped to gracefully degrade
its functionality or initiate recovery processes without compromising the integrity of user
data. Regular system backups and automatic error reporting mechanisms contribute to swift
identification and resolution of potential issues.
Chapter 5

Implementation

In today's diverse landscape of software development, there exist numerous methodologies


for designing and implementing applications. The choices span a wide array of
possibilities, ranging from selecting the application type to deciding on the environment,
programming languages, technologies, and frameworks. This section will delve into these
various considerations.

Specifically addressing the application at hand, it is divided into two integral parts. The
initial component harnesses the power of Artificial Intelligence to craft a system capable
of measuring the human body with increased accuracy, providing detailed output for the
user's body measurements. Furthermore, this segment includes features that suggest the
optimal size for T-shirts and jeans based on the acquired measurements. The second part
of the application is dedicated to the creation of a user-friendly interface, ensuring a
seamless and accessible experience for users.

5.1 Used Technologies


To develop a precise body measurement algorithm, we work on Ubuntu 22.04 we have
chosen to employ the YOLO v7 (You Only Look Once) object detection model in
conjunction with a Haarcascade classifier. This approach aims to detect entire human
bodies, identifying and classifying individuals, hands, and legs. When a person is
recognized in a correct standing position, the current frame is saved as an image file.

1. Python
Python is a high-level, interpreted programming language known for its readability and
versatility. Created by Guido van Rossum, Python emphasizes clean and concise syntax,
making it easy for developers to write and understand code. It supports multiple
programming paradigms, including procedural, object-oriented, and functional
programming. Python's extensive standard library provides built-in modules for a wide
range of tasks, reducing the need for external dependencies. With dynamic typing, object-
oriented features, and cross-platform compatibility, Python is widely used in diverse fields
such as web development, data science, artificial intelligence, and automation, supported
by a vibrant community and a vast ecosystem of third-party libraries and frameworks.
2. Numpy
NumPy, short for Numerical Python, is a powerful and widely-used open-source library
for numerical computing in Python. It provides support for large, multi-dimensional arrays
and matrices, along with a collection of high-level mathematical functions to operate on
these arrays. NumPy is fundamental to many scientific and data-oriented tasks in Python,
serving as the foundation for various other libraries and frameworks in fields such as data
science, machine learning, and scientific research. Its efficient array operations,
broadcasting capabilities, and integration with other tools make it an essential tool for tasks
involving numerical computations, linear algebra, statistical analysis, and more. NumPy
plays a key role in enhancing the performance of numerical operations in Python and is an
integral part of the broader ecosystem for scientific computing.
3. OpenCV
OpenCV, or Open Source Computer Vision Library, is an open-source computer vision
and machine learning software library. Originally developed by Intel, OpenCV is now
maintained by a community of developers. It provides a wide range of tools and functions
for image and video processing, including features like image manipulation, object
detection and recognition, face recognition, image stitching, camera calibration, and
machine learning. OpenCV supports various programming languages, with Python being
one of the most popular choices for its ease of use and extensive libraries.

OpenCV is widely used in computer vision applications across different domains,


including robotics, augmented reality, medical image analysis, and more. Its versatility,
along with a large and active community, makes it a valuable resource for developers and
researchers working on computer vision projects. The library is continuously updated and
improved to keep up with the latest advancements in the field.
4. Openpose
OpenPose is an open-source computer vision library renowned for its real-time multi-
person keypoint detection and pose estimation capabilities. Developed by the Vision and
Perceptual Machines Lab at Carnegie Mellon University, OpenPose excels in
simultaneously identifying key body parts and estimating the poses of multiple individuals
in images and videos. With a focus on real-time processing, the library provides modular
and accessible APIs for various programming languages, including C++ and Python. Its
versatility and open-source nature make it a popular choice for applications requiring
precise body movement analysis, such as sports training, healthcare, human-computer
interaction, and entertainment. OpenPose's continuous development and active community
contribute to its ongoing relevance in the field of computer vision.
5. PyTorch
PyTorch is an open-source deep learning library developed by Facebook's AI Research lab
(FAIR), widely utilized for constructing and training artificial neural networks. Notable for
its dynamic computational graph, PyTorch enables flexible model design and facilitates
easy debugging. The library's tensor operations closely resemble NumPy, providing a
powerful foundation for numerical computations. PyTorch's autograd system automates
gradient computation, streamlining the training of neural networks through automatic
differentiation. With a comprehensive torch.nn module, it supports the creation of intricate
neural network architectures. Renowned for its user-friendly interface and active
community, PyTorch continues to be a popular choice in the deep learning community,
powering research, development, and applications in various domains.
6. Matplotlib
Matplotlib is a popular open-source data visualization library for creating static, interactive,
and animated plots in Python. Developed by John D. Hunter in 2003, Matplotlib provides
a wide range of high-quality charts and plots for visualizing data in a clear and effective
manner. It is often used in scientific computing, data analysis, and machine learning
projects. Matplotlib offers a variety of plot types, including line plots, scatter plots, bar
plots, histograms, 3D plots, and more. It provides fine-grained control over plot
customization, allowing users to adjust colors, styles, labels, and annotations. Matplotlib
can be used both interactively, within Jupyter notebooks, and in script form to generate
publication-quality figures for presentations and reports. Additionally, it integrates well
with NumPy, another popular Python library for numerical computing. Matplotlib's
versatility and ease of use make it a valuable tool for visualizing and communicating data
in the Python ecosystem.
7. Flask
Flask is a lightweight and web framework for Python that is widely used for building web
applications. Created by Armin Ronacher, Flask is known for its simplicity and flexibility,
making it an excellent choice for both beginners and experienced developers. It follows the
WSGI (Web Server Gateway Interface) standard and provides essential tools for routing,
template rendering, and handling HTTP requests and responses. Flask is often referred to
as a "micro" framework because it comes with the basics needed to get a web application
up and running, but it allows developers to choose and integrate additional components
based on their specific requirements. The simplicity of Flask makes it suitable for a variety
of applications, from small projects to more complex web services. Additionally, Flask
extensions and a vibrant community contribute to its popularity and usability in the Python
web development ecosystem.
8. HTML
HTML, or Hypertext Markup Language, is the standard language for creating and
designing web pages. It provides the structure and content of a webpage by using a markup
system of tags. HTML tags are elements enclosed in angle brackets, such as <html>,
<head>, <body>, <p>, etc. These tags define different parts of a webpage, from the overall
structure to paragraphs, headings, links, images, and more. HTML documents are typically
saved with a ".html" extension and can be viewed in web browsers. HTML works in
conjunction with cascading style sheets (CSS) for styling and layout, and JavaScript for
interactivity, collectively forming the core technologies for building web pages and web
applications. The latest version of HTML is HTML5, which introduces new features and
improvements for modern web development.
9. CSS
CSS, or Cascading Style Sheets, is a style sheet language used for describing the
presentation and layout of HTML documents. It allows web developers to control the
appearance of web pages, ensuring a consistent and visually appealing design. CSS
achieves this by defining rules that specify how HTML elements should be displayed on
the screen. These rules include properties such as color, font size, margin, padding, and
more. CSS can be applied to HTML documents in various ways, including inline styles
directly within HTML tags, internal styles embedded within the HTML document's <style>
tag, and external styles through a separate CSS file linked to the HTML. By separating the
content (HTML) from the presentation (CSS), developers can easily update the appearance
of multiple pages on a website by modifying a single style sheet. This separation of
concerns enhances maintainability and flexibility in web development.
10. JavaScript
JavaScript is a versatile and widely-used programming language that is primarily employed
to add interactivity and dynamic behavior to web pages. Initially developed for client-side
scripting in web browsers, JavaScript has evolved to become a versatile language that is
also used for server-side development, mobile app development, and more. It is an essential
part of web development alongside HTML and CSS. JavaScript allows developers to
manipulate the Document Object Model (DOM) of a web page, enabling dynamic updates,
animations, and user interactions. It is often used in conjunction with HTML and CSS to
create interactive and responsive web applications. Modern JavaScript, often referred to as
ECMAScript, is supported by all major browsers and has an extensive ecosystem of
libraries and frameworks, such as React, Angular, and Vue.js, which streamline the
development of complex web applications.

5.1.2 Implementation of SmartSizer Flask-based web application

1. Overview:

The application is a Flask-based web tool designed for sizing recommendations using
computer vision techniques. Its primary functionality involves capturing and analyzing live
video feed from a webcam. Using a combination of OpenCV, YOLOv7, and Haar cascades,
the application detects and segments various body parts, providing real-time feedback on
measurements. Users can toggle image capturing, view body part outlines with confidence
scores, and generate segmentation masks.

In addition to live video analysis, the application calculates body measurements such as
hand, leg, shoulder, torso, and chest lengths based on OpenPose keypoints. These
measurements are then converted to centimeters using the user's input height. The tool
further attempts to locate the head, extract chest regions, and calculate chest and waist
lengths. Ultimately, the application provides sizing recommendations for t-shirts and jeans
based on the analyzed body measurements. It serves as a virtual fitting room, utilizing
computer vision to enhance the online shopping experience by suggesting apparel sizes
tailored to individual body characteristics.

2. Requirements:

Setting up a dedicated Python environment named "sizer" and installing all the required
dependencies is a crucial first step for working with SmartSizer. This ensures a clean and
isolated environment for the application. Once the environment is prepared, the next steps
involve loading the YOLOv7 model with pre-trained weights and configuring it for specific
object detection tasks.

3. Creating a Python Environment

A virtual environment named "sizer" is created to encapsulate the dependencies and


libraries required for SmartSizer. This helps manage dependencies and avoids conflicts
with other Python projects. Figure 8 shows an example of Creating a Python Environment.

Figure 8 Example of Creating a Python Environment.

Activate the sizer environment and all necessary dependencies for SmartSizer are
installed within the "sizer" environment. Figure 8 shows an example of activating a
python environment.
Figure 9 shows an example of activating python environment.

We installed the following libraries of computer vision and machine learning in the sizer
envirnoment.

i. conda install python=3.10.12


ii. pip install opencv
iii. pip install numpy
iv. pip install torch
v. pip install matplotlib
vi. pip install flask

4. Flask Application Setup

Setting up and running the sizing recommendation application on our local machine
involves several steps.

1. Open the terminal and enter the command "mkdir SmartSizer" to create a folder
named SmartSizer on the desktop. Clone the repository from GitHub using the
command "git clone https://github.com/Sergey-Mr/VisualSizer.
2. Once the repository is cloned, copy the roi, pytorch, mask, and main files. Paste
these files into the SmartSizer folder.
3. Download Yolov7 model weight its configuration files, open pose human body
keypoints and full body and haarcascade classifier files.
4. Create four new folders under the SmartSizer folder: static, template, haarcascades,
and model. The static folder in Flask is used to store images used in the interface
design. The template folder contains HTML files for the project. The haarcascades
folder stores the haarcascades classifier file, and the model folder stores YOLOv7
weights and configurations.
5. Create a file named app.py in the SmartSizer directory. Open Visual Studio and set
up the sizer environment in the terminal. Open the index.html file from the template
folder in the terminal and also open app.py.
6. In app.py, import all the required libraries. Figure 9 shows an example of importing
all the required libraries.
Figure 9: Example of importing all the required libraries.

5. Model Implementation for Human Body Detection

With help of OpenCV library we write code to detect and label objects of interest, such as
persons, hands, and legs, using the YOLOv7 object detection model. Additionally, it
utilizes a Haarcascade classifier for detecting the entire human body. The program
continuously captures video frames, applies object detection algorithms to identify relevant
objects, and draws bounding boxes around them. The code includes a function to check if
a person is standing properly based on the detected objects and saves the frame if the
conditions are met. The main loop continuously displays the processed frames and
terminates when the 'q' key is pressed. The captured images are saved in a specified
directory. Figure 10: shows an example of importing all the required libraries. Figure 10
shows an example of human body detection in standing position.
Figure 10: Example of human body detection in standing position.

Define the model path and load the model configuration files in the code. Figure 11
shows an example of configuration model files. Figure 11: shows an example of
configuration model files.

Figure 11: Example of configuration model files.

6. Generate Body Mask

By using PyTorch and torchvision we generate semantic segmentation masks of user


captured image. The image captured from webcam loading and converting it to a PyTorch
tensor, and transposing the dimensions to match the required format. We write one function
named “show” then visualizes the input image, and the code proceeds to employ a pre-
trained FCN-ResNet50 model from torchvision for semantic segmentation. The model is
used to generate segmentation masks, and these masks are visualized with a specific color
map using the draw_segmentation_masks function. The resulting segmented image is
displayed using the show function. We then saves the visualized image as 'output.png'.
Figure 12 shows an example of generating body mask.
Figure 12: Example of generating body mask.

After saving output image we define hands_measurements, for finding the length of the
arm, using the openpose points then we define shoulder_length, measure_chest and
calculate_waist functions. Afterwords calculate the magnitude of vectors and using a
proportion of the given input of the user height to the amount of pixels representing the
height.

7. Body Measurements

The initial step involves processing the image, turning the background into black and the
body into white. This binary representation simplifies the distinction between body and
background pixels. The body is divided into different parts based on the user's height. The
head, chest, waist, and hips regions are identified using specific calculations. To accurately
measure the chest and waist, we eliminate the interference of hands in the image. This is
achieved by iterating over the pixels horizontally from both the left and right sides. The
goal is to detect the beginning of the chest region. Figure 13 show an example of chest
measurement function. The horizontal length of the resulting image is then calculated. This
length represents the chest measurement in pixels. The proportion between the user's height
and the number of pixels is used to convert the pixel length into centimeters. This ensures
that the measurement is scaled according to the user's actual height. By using the user's
height as a reference, we ensures that the measurements are proportional and accurately
represent the physical dimensions of the chest and waist. The calculated chest length in
pixels is converted to centimeters, providing a real-world measurement that is independent
of the image resolution. Figure 14 shows body measurement.

Figure 13: Example of chest measurement function


Figure 14: Body Measurement.

Furthermore, we defines two functions for determining clothing sizes, specifically for T-
shirts and jeans. The determine_tshirt_size function takes two parameters,
chest_length_cm and torso, representing chest length and torso length, respectively. It
checks these measurements against predefined size ranges and returns the appropriate size,
considering criteria such as chest and torso dimensions. The second function,
determine_jeans_size, similarly takes leg and waist_length as parameters, representing leg
length and waist length. It evaluates these measurements against predefined size ranges
and returns the corresponding jeans size, then calculates the T-shirt and jeans sizes for a
user by calling these functions with specific measurements. Figure 15 shows an example
of functions for determining clothing sizes.
Figure 15: Example of functions for determining clothing sizes.

8. Web Routes:

We define /video_feed route for provides the video feed through the REST API and also /:
renders the main web page. The /requests route handles start/stop requests for video feed.
/captured_image route serves the captured image, /generate_mask route generates
segmentation masks from the captured image and /process_height route processes the
user's height based on captured image. Figure 16 shows an example of web routes used in
Flask App.

Figure 16: Example of web routes used in Flask App.

9. Processing Height Function

In route we use method POST for handling HTTP POST requests at the /process_height
endpoint. The route checks if the incoming request method is POST. It retrieves the user
height from the form data sent in the POST request using request.form ['user_height']. Then
the user height is converted to a floating-point number (assuming the height is provided as
a string). Figure 17 shows an example of request user height.
10. HTML Form on the Web Page

Figure 17: shows an example of request user height

Moreover, for user height input we used an HTML form on the client side. This form could
be part of the main web page (index.html). The form has a text input field named
"user_height" where the user can input their height. When the form is submitted, it sends a
POST request to the /process_height endpoint. Figure 18 shows an example of submit user
height.

Figure 18: Example of submit user height.


11. Run Application

Starts the Flask application by typing app.py in terminal. Figure 19 shows an example of
run Flask App.

Figure 19: Example of run Flask App.


Testing and Evaluation

Testing and evaluating the SmartSizer application involves assessing various aspects,
including usability, functionality, and accuracy. We verify each step through a documented
walkthrough, ensuring that each point operates correctly and in the intended manner.

1. Introduction

Evaluate the clarity and conciseness of the introduction to ensure users understand the
purpose of the SmartSizer app. Check for any potential issues with the introductory text,
such as grammar or spelling errors. Figure 20 shows introduction.

Figure 20: Introduction.

2. Size Guide:

Review the size guide content for accuracy and completeness. Ensure that the size guide
provides clear instructions on how to use the Smart Sizer application effectively. Test the
accessibility of the size guide to ensure that it is easily understandable by a wide range of
users. Clearly specify what users should wear during the sizing process. Provide explicit
instructions on the ideal pose and positioning users should adopt when capturing their
image through the webcam. Clearly state the background requirements for the image
capture. Instruct users on the optimal placement of their device during the image capture
process. Include any additional tips or best practices that can enhance the accuracy of the
sizing process. Figure 21, 22, 23, 24 and 25 shows Size Guide of SmartSizer App.

Figure 21: What to wear?

Figure 22: How to pose?

Figure 23: Where to measure?

Figure 24: Where should the device be positioned?


Figure 25: Additional Tips to Generate your perfect Size.

3. Webcam Capture Tool

Test the functionality of the webcam capture tool. Verify that the tool properly detects the
user's position and prompts them to stand in the right way. Check for any issues with the
webcam, such as compatibility problems with certain devices. Figure 26 shows Webcam
Capture Tool.

Figure 26: Webcam Capture Tool


4. Image Capture
Evaluate the image capture process to ensure it accurately captures the user's image. Check
for any delays or issues that may arise during the image capture process. Figure 27 show
Image Capturing process.
Figure 27: Image Capturing process.

Once the image capture process is complete, confirm that a clear and user-friendly message
is displayed on the interface, indicating that the image has been successfully captured.
Figure 28 shows image captured message.

Figure 28: Image Captured message.

6. Generate Mask

Evaluate the button to generate a mask and ensure it works as intended. Check for any
visual artifacts or errors in the generated mask. Figure 29 shows mask Generation process.

Figure 29: Mask Generation process.


7. Height Entry

Test the functionality of the height entry system, ensuring that users can easily input their
height in centimeters. Check for any restrictions or limitations on the acceptable height
range. Figure 30 shows height entry process.

Figure 30: Height Entry process

8 Display Body Measurement Results

Test the section where body measurement results are displayed. Modify or enhance this
section to present the calculated measurements in a user-friendly format. Figure 31 shows
display body measurement results.
9. Manual Results

Evaluate the accuracy of the sizing results provided by the SmartSizer app. Compare the
results with known sizes to ensure they align appropriately. Figure 32 shows manual Sizing
images for SmartSizer Application comparison.

Figure 32: Manual Sizing images for SmartSizer Application comparison.

10. Size Recommendation

Test the system's ability to provide sizing information for both general size and specific
items like T-shirts or jeans. Figure 33 shows Size Recommendation base on your body
measurements.

Figure 33: Size Recommendation base on your body measurements.


By systematically testing these aspects, we can identify and address any issues, ensuring
that the SmartSizer app delivers a reliable and user-friendly experience.

Product Evaluation

Product evaluation for the Smart Sizer app involves a comprehensive examination of its
effectiveness, accuracy, usability, and overall performance. Beyond technical
functionality, the assessment encompasses usability and user experience, ensuring the app's
intuitive nature and accessibility to diverse users. The accuracy of sizing results, privacy
measures, and compliance with regulations are rigorously verified. Performance testing
evaluates the app's responsiveness under various conditions, and market fit is analyzed in
comparison to competitors. User feedback collection and regulatory compliance further
contribute to understanding user experiences and legal obligations. The evaluation also
considers scalability, adaptability to emerging technologies, and the app's long-term
viability, ensuring it remains competitive and relevant in the evolving market.

7.1 Case Scenarios

The following scenarios outline the performance analysis conducted on the SmartSizer app.

7.1.1 Case 1

We conducted tests on the SmartSizer application in various scenarios. Initially, we


assessed its performance using a low-quality camera. The model successfully detected the
person's head, hands, and feet, and it captured the image. However, due to the low-quality
input, the mask generation process did not produce an accurate body mask, leading to
unsatisfactory measurement results. Figure 34 shows SmartSizer results on low quality
camera image.
Figure 34: SmartSizer results on low quality camera image.

To address this issue, we repeated the test with images captured at higher resolution. This
time, SmartSizer performed well, yielding more accurate and satisfactory results. Figure
35 shows results of SmartSizer on good quality camera image.

Figure 35: Results of SmartSizer on good quality camera image.


7.1.2 Case 2

We also tested the person's standing posture. If a person stands with one leg in front and
the other slightly at the back, the camera successfully captures the image. However, in this
condition, the generated mask may portray one leg larger than the other, leading to
inaccurate measurements. To address this issue, it is recommended that the user stands in
an A pose with their legs aligned in a straight line. Figure 36 shows the results of a person
stands with one leg in front and the other slightly at the back.
Figure 36: Results of a person stands with one leg in front and the other slightly at the
back.

7.1.2 Case 3

We also conducted tests by capturing images in various backgrounds. Our analysis revealed
that the image capture process is more efficient when the background is a plain wall or
simple, compared to backgrounds with noise or multiple objects like bottles. In such
complex backgrounds, the system attempts to detect these additional elements, impacting
the image capture process and resulting in failures. Figure 37 shows suitable background
for capturing image.

Figure 37: suitable background for capturing image.


Closing Chapter
This thesis presents a web-based application for personalized online apparel shopping with
a perfect size. SmartSizer has been developed using Python on Flask, enhancing the
application's speed and efficient handling of user responses. Flask, a micro web framework
in Python, simplifies web application creation by providing tools and libraries for
managing HTTP requests, routing, templates, and more. Flask makes it convenient for
developers to integrate AI models into their web applications without extensive code
modifications or complex integration processes. Flask also offers simple integration with
Jinja2 Templates, SQLAlchemy, WTForms, Flask-RESTful, and Flask-Security.

The application design is simple and user-friendly. SmartSizer enables users to obtain the
perfect size by providing recommendations for T-shirts and jeans based on their body
measurements. This application contributes to the benefits of the online fashion industry.

The SmartSizer project is designed with the purpose of alleviating the frustration of
receiving ill-fitting garments by revolutionizing the process of choosing sizes. The goal is
to automate this process, ensuring a perfect fit every time and transforming the online
shopping experience. Additionally, SmartSizer aims to reduce the quantity of wasted
clothing material.

The software size and complexity has a great impact on the effectiveness of an application
development. The software complexity depends on different interfaces used in the
application, complex requirements, maintainability of the code, use of frameworks, data
communication and algorithms. This application is developed on Python and Flask. It
provides a simple and easy platform for web application development. The extensive
libraries of the Flask reduce the size of code and reduce the complexity of the application.
Flask is used RESTful Api encourages a resource-oriented approach to API development.
Resources, representing entities in the system, are defined as classes in Python. HTTP
Methods and Endpoints: Resources in Flask-RESTful map to HTTP methods (GET, POST,
PUT, DELETE, etc.) and are associated with specific endpoints. This helps in defining
clear and predictable API routes. HTML/CSS is used for creating web pages. It offers
simple integration with AI models.

SmartSizer's software size measurement is instrumental in evaluating the application at the


source code level, providing valuable insights into the dimensions of critical systems. This
meticulous assessment serves as the foundation for implementing effective programming
practices. The software development process for SmartSizer follows the Spiral Model, a
choice made to accommodate the intricate nature of the application, which involves
features such as webcam integration, image processing, and size calculation algorithms.
The Spiral Model's iterative and risk-driven approach allows for continuous refinement of
the application. The development involved multiple iterations, with each spiral phase
addressing specific functionalities, including model design, controller design, view design,
page updates, RESTful services, Flask App development, and the seamless integrations.
The Spiral Model's adaptability and emphasis on risk management have played a pivotal
role in ensuring the reliability and efficiency of SmartSizer throughout its development
lifecycle. Figure 38 shows that SmartSizer phases in Spiral model.

Figure 39: SmartSizer phases in Spiral model.


Future Work

In the realm of future enhancements for the SmartSizer app, a key focus lies in elevating
the precision and user experience of the height entry system through advanced post-capture
image processing. The envisaged trajectory involves the implementation of cutting-edge
algorithms designed to intelligently analyze and correct captured images, addressing
nuances such as misaligned body parts and skewed perspectives. A pivotal aspect of this
evolution is the development of an automated pose correction mechanism, ensuring that
the orientation of individuals in images conforms to standardized postures for optimal
measurement accuracy. Furthermore, the incorporation of sophisticated alignment and
scaling algorithms, leveraging computer vision techniques, aims to rectify discrepancies in
body part alignment, facilitating a more accurate representation of users' proportions.
These endeavors align with the overarching goal of SmartSizer to continually refine its
capabilities and offer users an unparalleled and effortless body measurement experience.

Following are the points that will be help to enhance the SmartSizer app in Future.

1. Post-Capture Image Processing

Implement advanced image processing algorithms to analyze and adjust the captured image
for optimal accuracy in body measurements. Address common issues such as misalignment
of body parts, skewed perspectives, or distortions in the image.

2. Automated Pose Correction

Develop a pose correction algorithm that automatically adjusts the orientation of the person
in the image. Correct misalignment in body parts, ensuring that the person's posture adheres
to predefined standards for accurate measurements. Create a sophisticated alignment and
scaling algorithm to address discrepancies in the alignment of body parts, such as legs,
arms, and torso.

3. Feedback Mechanism for Users

Implement a feedback mechanism that informs users about potential issues with the
captured image. Provide guidance on how to improve image quality for better measurement
accuracy.

4. User Interface Enhancements


Enhance the user interface to guide users through the image capture process effectively.
Provide visual feedback on the screen to indicate areas of the body that need proper
alignment or adjustments.

5. User Feedback Loop

Establish a feedback loop with users to collect data on the effectiveness of image
processing and adjustments. Use user feedback to continually improve the algorithm and
address specific challenges faced by users.

6. Cross-Platform Compatibility

Ensure that the body measurement algorithms work seamlessly across different devices
and platforms. Optimize performance for both mobile and desktop environments.

Conclusion

Continued research and development in the SmartSizer app holds the promise of
eliminating the need for users to invest in multiple tools or hire specialized professionals
for image resizing. By doing so, SmartSizer not only provides a cost-effective solution but
also empowers users to effortlessly manage their digital content. The commitment to
regular updates and feature enhancements underscores the app's adaptability in an ever-
evolving digital landscape.

SmartSizer's impact is profound, as it significantly reduces the time and effort required for
resizing images. This functionality ensures that users can promptly tailor their visuals to
meet the specific requirements of diverse platforms such as social media, websites, and
applications. The app's intelligence goes beyond mere resizing; its algorithms consider
crucial factors like resolution, aspect ratio, and file size. This comprehensive approach
ensures that the optimized images maintain a high quality, all while minimizing the impact
on load times.

Furthermore, the user interface of SmartSizer is a testament to thoughtful design,


prioritizing simplicity and intuitiveness. This user-centric approach means that individuals,
irrespective of their technical expertise, can seamlessly navigate the app. This accessibility
ensures that SmartSizer caters to a broad audience, further solidifying its position as an
indispensable tool in the realm of image optimization and resizing. As SmartSizer
continues to evolve, it stands poised to redefine and enhance the way users interact with
their digital visual content.
References
1. Montazerian, M., & Leymarie, F. F. (2023). Designing a Contactless, AI System to Measure
the Human Body using a Single Camera for the Clothing and Fashion Industry.
2. "Android," Wikipedia, [Online]. Available: http://www.wikipedia.com/child app. [Accessed
12 June 2017].
3. Size Designation of clothes–Part 1: Anthropometric Definitions for Body Mea-
surement. International Organization for Standardization
4. Devpost. (2023). VisualSizer. [online] Available at:https://devpost.com/software/body-
measurement [Accessed 6 Nov. 2023]
5.https://www.researchgate.net/publication/314096518_Virtual_Fitting_Pipeline_Body_Dimensi
on_Recognition_Cloth_Modeling_and_On-Body_Simulation
6. Saha, S., Ganguly, P., & Chaudhury, S. (2014, December). Vision based human pose
estimation for virtual cloth fitting. In Proceedings of the 2014 Indian Conference on Computer
Vision Graphics and Image Processing (pp. 1-6).
7. Tiwari, G., Bhatnagar, B. L., Tung, T., & Pons-Moll, G. (2020). Sizer: A dataset and model for
parsing 3d clothing and learning size sensitive 3d clothing. In Computer Vision–ECCV 2020:
16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part III 16 (pp. 1-
18). Springer International Publishing.
8. Karessli, N., Guigourès, R., & Shirvany, R. (2019). Sizenet: Weakly supervised learning of
visual size and fit in fashion images. In Proceedings of the IEEE/CVF Conference on Computer
Vision and Pattern Recognition Workshops (pp. 0-0).
9. Ukita, N., Tsuji, R., & Kidode, M. (2008). Real-time shape analysis of a human body in
clothing using time-series part-labeled volumes. In Computer Vision–ECCV 2008: 10th
European Conference on Computer Vision, Marseille, France, October 12-18, 2008, Proceedings,
Part III 10 (pp. 681-695). Springer Berlin Heidelberg.
10. Foysal, K. H., Chang, H. J., Bruess, F., & Chong, J. W. (2021). Body size measurement using
a smartphone. Electronics, 10(11), 1338.
11. Xia, S.; Guo, S.; Li, J.; Istook, C. Comparison of body measuring techniques: Whole body
scanner, handheld scanner, and tape
measure. In Proceedings of the International Textile and Apparel Association Annual Conference,
St. Petersburg, FL, USA, 14–18
November 2017
12. ieeexplore.ieee.org. (n.d.). A Scalable Virtual Try-on System based on Cloud
Computing. [online] Available at: https://ieeexplore.ieee.org/document/9538487
[Accessed 27 Oct. 2023].
13. Niinimäki, K., Peters, G., Dahlbo, H., Perry, P., Rissanen, T. and Gwilt, A. (2020).
The Environmental Price of Fast Fashion. Nature Reviews Earth & Environment,
[online] 1(4), pp.189–200. doi:https://doi.org/10.1038/s43017-020-0039-9 [Accessed
24 Oct. 2023].
14. Kim, S., Moon, H., Oh, J., Lee, Y., Kwon, H., & Kim, S. (2022). Automatic measurements of
garment sizes using computer vision deep learning models and point cloud data. Applied
Sciences, 12(10), 5286.
15. Choudhury, R. R., Phatak, M., & Joshi, I. (2023). Artificial Intelligence in Retail:
Opportunities and Challenges for the Future. European Economic Letters (EEL), 13(4), 921-936.
16. Karunamoorthy, B., & Ramprabu, J. (2018). A Novel Method Of real Time Cloth Size
Measurement Algorithm Based On Fpga Platform. International Journal of Innovative
Technology and Exploring Engineering (IJITEE), 8.

You might also like