tatammmmy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # ML report 簡報講稿 [link](https://hackmd.io/sqfElB69ToGbbq_tHCLXLA?edit) [簡報](https://www.canva.com/design/DAFVjnB-BBI/PWRX2_IrnmRzEo2RIKzjkQ/edit?utm_content=DAFVjnB-BBI&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton) ## abstract(簡介研究內容,不能提到後面正文沒提到的) This research subjects mainly focus on biologically Asian males in the age between 18 to 40 years old. We collect some clear front face photos of our subjects(inculding homosexual and heterosexual) as input data, and these data sources are coming from public figures and dating apps. Then in our model, online pre-trained facial recognition model used, and with our own design added, it could be able to classify into two groups by facial features(e.g. noses and eyes). ## Introduction(人臉辨識的歷史脈絡) There is a study from Stanford University which can correctly distinguish between straight and gay, it's accuracy can be as high as 81% for men and 74% for girl. They used deep neural networks based on a sample that have more than 35,000 facial images to complete this model. The purpose of this thesis is to apply VGG Face and SVM to detect sexual orientation. The reason why we want to study on this topic is that we hope our research can help people to reduce the probability of falling in love with men with different sexual orientation. VGGFace is a face recognition model. It is trained on VGGNet’s own dataset, which contain 2.6 million face images of 2,622 people that is used development face recognition technology, recognizing who is the person in a photo among this dataset. Most of the recent research use it to recognize whether two photos are the same person or their similarity. And SVM is a relatively simple Supervised Machine Learning Algorithm, used for classification and/or regression. It will finds a hyper-plane that creates a boundary between the types of data. Therefore, we decide to combine the distinguishing ability of VGGFace and the classification ability of SVM as our structure of model. ## Method ### data collection - Training / validation images We select photos among biologically Asian males in the age between 18 to 40 years old. Photos we collect mainly from public figures and dating apps, and some from our friends with their consent. How we label the images is checking if the person got married, if he have a boy/girlfriend, or the label he added in the dating app. Moreover, we labeled people who are bisexual as homosexual, too. Besides, in order to ensure impartiality, for each person who is in our training data, other photos of him will not be picked as validation data. We originally collect 390 training images in total, and 181 validation images in total. - Testing images Four pictures for men who volunteered to be our testing data. ### data preprocessing - Detecting Faces and Cropping and Images Since our input data are general images, which may contain not only male faces but also other unrelated objects, in order to focus on the data of our interest, we must first locate the faces and crop only those part of images. To this end, we use face detector of Dlib for face detecting. This face detector will based on the number of detected faces and each face's scale to determine the sizes to plot the images. Then according to the acquired image size to construct a blank image, which is an array, and then start to fill the array with the human face data. Since the cropped photos are in different sizes, we resized these photos to 224x224, which is the format VGGFace required. - Data Augmentation In order to increase the amount of training data and avoid the problem of over fitting, we augment the data before putting it into model. The methods we use are shown bellow: 1. Gamma: tf.image.adjust_gamma() Perform gamma correction on the input images to adjust the brightness; we set the parameter = 0.2. 3. Contrast: tf.image.adjust_contrast() Adjust contrast of the input images; we set the parameter = 8. 5. Horizontal Flip: tf.image.flip_left_right() Flip the images horizontally(left and right). 7. Saturation: tf.image.adjust_saturation() Adjust saturation of the input images; we set the parameter = 0 and 1.5, which thus produces 2 batches of data. 8. Hue: tf.image.adjust_hue() Adjust hue of the input images; we set the parameter = 0.05. Last, we will change the dataset from 390 images to 2730 images. gay:868 straight:1862 val gay:77 val straight:104 ### Model 1 VGGFace+SVM - VGG Face VGGFace is a face recognition model, which is pre-trained on VGGNet by their own dataset. We use VGGFace to extract the features of the human facial features from the images. We download the VGGFace package from [這篇文章的code]. The model will first, transform the training data into the readable format for VGGFace, and input the data into the model. Then, we will acquire the features, which can represent the important infomation of the faces. - SVM SVC, which is an application of SVM for classification. Since we need to classify people into two groups by their sexual orientation, we use sklearn.svm.SVC() to train the model. - ROC curve & best threshold ![](https://i.imgur.com/MYDGcYz.png) By plotting and analyzing the ROC curve, we found out the best threshold value for our model is 0.648. - Model Attributes We use VGGFace as our base model to extract facial features in the images, and train them with SVM in turn. Below are some attributes of our VGGFace model. * weights = vggface We set the weights as 'vggface', which is a set of pretrained weight by vggface. * include_top = True We set include_top to True to include the 3 fully-connected layers at the top of the network. * model = vgg16 There are three base model choices for VGGFace, which are vgg16, resnet50 and senet50. Eventually, we chose vgg16 for optimization. - Layers Structure ![](https://i.imgur.com/oXAXMpU.png) We extracted the facial features from layer 'fc7' in VGGFace model, and trained them with SVM to classify and generate the result. ### Model 2 VGGFace+NN - VGG Face We use the same VGGFace model as VGGFace+SVM one, and acquire the features from layer 'fc7', which represent the important information of the faces. - NN Since we need a model which can find the relationship between data automatically, we use NN to train the model. The reason why we didn't choose CNN is that the input data of our model are features, not pictures. - ROC curve & best threshold ![](https://i.imgur.com/PNh7DsJ.png) By plotting and analyzing the ROC curve, we found out the best threshold value for our model is 0.845. - Model Attributes We use VGGFace as our base model to extract facial features in the images, and train them with NN in turn. The attributes of our VGGFace model are same as the previous one. - Layers Structure Same as the previous model, we extracted the facial features from layer 'fc7' in VGGFace model, and trained them with NN to classify and generate the result. * optimizer = 'adam' We have chosen 'adam' as our optimizer in our VGGFace+NN model and set the learning rate to 0.001. * Loss function = Binary Cross Entropy Because our classification is bipartite, the binary cross entropy is more suitable to evaluate our model. * Activation = Relu * Drop out rate = 0.25 In order to prevent overfitting, we added a drop out layer after the first activation function. * Activation = Relu * Activation = Relu * Drop out rate = 0.5 In order to prevent overfitting, we added a drop out layer. * Activation = Relu * Activation = Sigmoid * Epoches = 50 ## Result Following are our prediction : - Original Label : ......貼圖片 Fig.?? * VGG+SVM Model Predict Result : ......貼圖片 Fig.?? We got one wrong prediction on heterosexual, and one wrong prediction on homosexual respectively. * VGG+NN Model Predict Result : ......貼圖片 Fig.?? We got one wrong prediction on heterosexual, and all correct prediction on homosexual respectively. The accuracy is roughly 75%. ![](https://i.imgur.com/T9RockH.png) Fig.?? ![](https://i.imgur.com/TGyuKRA.png) Fig.?? ## Discussion and Conclusion - Result Analysis 1. We have trained three models, including VGGFace+SVM, VGG+NN, pure CNN models. 2. We compare the performance of the VGG-Face+SVM model, VGG-Face+NN model and the CNN model from homework 4, and find that the models using VGG-Face perform much better than the CNN model. In addition, the performance of model using SVM is equal to the performance of model with NN. 3. In the confusion matrix of our VGGFace+SVM model, we observed that the percentage of gay misclassified as straight is a bit higher than the percentage of straight misclassified as gay. The main reason for this may be attributed to the little imbalance in our training data, since the numberof our straight images is slightly more than gay ones in training data. - Difficulty and Solution 1. data not enough Since we collect training data, validation data, and testing data all on our own instead of using readily available data, it is hard for us to collect enormous amount of input data. Furthermore, many people don’t easily express their sexual orientation to the others, not to mention to expose this private information clearly on the internet, which makes our data-collecting job even harder and hence, of course, the less amount of our input data. To this end, to solve this problem, we perform augmentation on our original images and increase the amount from 390 to 2730 in total consequently, since data augmentation can not only be the remedy of insufficient data but also a method which can regularize the learning process to prevent the overfit. 2. VGG model application adjustment During the training process, we observed very strange behavior of our loss function, and acquired a not very good accuracy of the data at the end. Digging into the problem, we surprisingly found that our model predicted all men as straight, which is obviously wrong result. We then went back to restudy VGG Face model once again, finding out that the output data of VGG Face model is actually based on how similar the input image is to the people from its original training dataset (i.e., VGG-Face Dataset, which contains 2622 different public figures’ face images) rather than our own input data set. To solve this problem, we modified our model: instead of running all layers of VGG Face model, we only extract human facial features generated from one of its layers, "fc7". Then, we input the extracted facial features into the newly added SVM, calculating the ROC curves to estimate the performance of the classification and improve our model with the best threshold. - Future Work To improve the accuracy and practicality of our model.We will collect more input data to generalize the model and do further study on adding bisexual tag, classify female edition, or even expand our the classifying range of our model to all kinds of races. ## Author Contribution Statements 109060013 Hsin-Yu Chang 章魚(16.6%) Data collection, Model designing, report writing 109060016 Ting-Ju Lin 林亭汝(16.6%) Data collection, Image preprocessing, report writing 109060024 Yu-Yan Huang 黃宇妍 (16.6%) Data collection, Model designing, presentation, report writing 109060029 Chia-Chen Chiang 江(16.6%) Data collection, Image preprocessing, Model designing, report writing 109060036 Yi-Hua Lin 林宜樺(16.6%) Data collection, Model designing, report writing 109060037 Man-Dy Yen 顏曼娣(16.6%) Data collection, Image preprocessing, report writing ## References https://www.cnblogs.com/adaminxie/p/8339863.html https://paperswithcode.com/dataset/vgg-face-1 https://github.com/rcmalli/keras-vggface https://www.cc.ntu.edu.tw/chinese/epaper/0043/20171220_4306.html https://www.theguardian.com/technology/2017/sep/07/new-artificial-intelligence-can-tell-whether-youre-gay-or-straight-from-a-photograph

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully