Professional Documents
Culture Documents
4 Thesis-Template (Applied)-2
4 Thesis-Template (Applied)-2
By
Sara Khan
By
Sara Khan
001066263-4
Supervised by
Dr. X
By
Sara Khan
CERTIFICATE
A THESIS SUBMITTED IN THE PARTIAL FULFILMENT OF THE
REQUIRMENTS FOR THE DEGREE OF BACHELORS
IN COMPUTER SCIENCE
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.
This thesis has been checked for Plagiarism. Turnitin report endorsed by Supervisor is
attached at the end of thesis.
Student Signature
Supervisor Signature
Dedicated to
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
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. 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.
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.
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.
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.
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.
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.
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.
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
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.
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
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:
Place a prominent button or link that directs users to the next steps, initiating the
size estimation process.
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.
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.
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
3. Security
Secure Communication
All communication between the web application and the SmartSizer server should
be encrypted to prevent data interception.
4. Compatibility
5. Portability
Cross-Platform Compatibility
The application should work seamlessly across different operating systems such as
Windows, macOS, and Linux.
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.
33. cap.release()
34.cv2.destroyAllWindows()
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 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
i. Static Testing
It is performed before the code is executed and includes activities like code reviews,
inspections, walkthroughs, and document reviews.
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.
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.
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.
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
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.
To create a test for the SmartSizer App, we used a testing framework like pytest.
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.
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.
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
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.
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.
Implementation
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
Starts the Flask application by typing app.py in terminal. Figure 19 shows an example of
run Flask App.
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.
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.
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.
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.
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.
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.
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.
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.
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.
The following scenarios outline the performance analysis conducted on the SmartSizer app.
7.1.1 Case 1
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.
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.
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.
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.
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.
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.
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.
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.