Skip to content

Privy filter is made to give the method for removing/accommodating for unethical bias in data.

License

Notifications You must be signed in to change notification settings

Deamoner/privyfilter

Repository files navigation

Photo Filter for racial/ethical bias

Filtering photos for bias(racial, gender) for machine learning.

Privy filter is your photo dataset augmentor and analyzer for unethical bias(Race, Gender, Age)

Filtering photos for bias(racial, gender) for machine learning.

Demo

Privy Filter: Info and Demo Site

Use Cases

  • Train Machine Learning Models minimizing unethical bias inherent in underlying photo dataset - IE Race, Gender, Age Discrimination
  • Data Augmentation of Photo datasets to balance unethical data bias
  • Create and Identify Unit Test Photos for datasets to ensure continual testing of bias in classification type problems
  • Ethical Machine Learning - Remove Identity/Generalize Identinity/Generalize Race/Gender/Skincolor/Generalize

Privy filter is your photo dataset augmentor and analyzer for unethical bias(Race, Gender, Age)

privyfilter detect and blurr faces privyfilter detect and blurr faces

Latest Release:

v0.2 - Sythetic Face Generation and Face Swapping

Roadmap

v0.1 - Basic Direct Identifier Scrubbing - Done

  • Face Detect - Needs improvement
  • Face Scrub

v0.1.6 - Basic Meta Data Scrubber - Done

  • RemoveMetaData(imgPath)

v0.2.0 - Identify face and replace - Done

  • getRandomFakeFace : get Random Synthetic Face - done - needs tmp folder setting
  • peopleObject - getFaceInfo - done - face model not loading on
  • peopleObject - swapFace(img1, img2)

v0.3.0 - ProcessAll and Use Case Direct Finishing

  • processOne() - review demographics of current photo - suggest additional photos
  • generatePhoto - from one photo and demographic info - generate those new photo demographic utilizing synthetic faces
  • processDir() - process all the photos in the directory - first calculate the statistics and distributions - and parameterize a directory to save all sythetic balanced photos.
  • Update DemoSite with Use Case direct notes and usability examples

v0.4.0 - Identify other identifiers and bias features

  • Detect skin - Dataset: http://cs-chan.com/downloads_skin_dataset.html
  • AdjustSkin - Can adjust skincolor to generate new dataset photo
  • Update processone stats and generatephoto to utilize skincolor data and manipulation
  • Update demosite with video
  • Demo of CelebA Dataset

v0.5 - Direct Aging and Gender

  • Test Face Aging Algo
  • Test Gender Changing Algo
  • Testing Race Direct Synthetic Style Transfer
  • Fixes for DetectSkin and AdjustSkin

v0.6 - Improve/Increase Original Photoset data quality retention through improve synthetic matching

  • Face pose matching for synthetic face replacement
  • Review accuracy of underlying demographic model
  • New CelebA Demo

v0.7 - Increase compatibility of pipeline for photosets

  • Support for multi face photo - Scoping - Document API updates
  • Support for people but no face in photos - recognize poses without faces

v0.8 - Reliability Fixes

  • Back to baseline of usecase documentation
  • Use Case Automated Testing

Methodology

Scrub all identifying and data possible for bias from the dataset keeping a featureset that still allows for useful machine learning.

  1. Identify Features - Faces, People
  2. Remove Unethical Bias Data - New Synthetic Faces, Adjust Skin, Gender and Age Transformation
  3. Create alternatives synthetic photos for balanced training

References Work

Process for Features

What needs to be done for roadmap Contribution:

  1. Scoping
  2. Test Implementation for AI Model pieces - Colab Notebook of Models with Validation Data
  3. Library wrapping and Implementation
  4. Library Publish

Tasks:

  • Face Detect - Colab Testing - Included in the Notebook folder in the repo.
  • Facescrub - Colab Testing - Simplest De-identification - Simple blur - Commonly available
  • Face Location Extraction
  • Basic Library Object Implementation
  • v0.1 Release for basic Direct Identifiers
  • Pose Extraction Notebook
  • Basic Skin Extraction
  • Synthetic Face Generation
  • Face Swap Testing
  • Face Swap Integration into main library
  • Fixes for model automated download
  • Clean up API for people and privyfilter library to match specs.
  • Replace Faces - Replace a face in a photo
  • Scope out API for calculation and methodology of race/gender face demographic balancing
  • Functions to process one photo for demographics and balanced demographics needed return
  • Function generateSytheticPhoto - create the photo required
  • Improved SkinExtraction Protocol
  • Skin Adjustment Methodology
  • Fixes for face detection to
  • v0.2 Release for George Floyd Implementation

Installation

Use the package manager pip to install Privy - Privacy Photo Filter library.

pip install privyfilter

Basic Usage

from privyfilter.privyfilter import Privyfilter as pf

faces2, img = pf.faceScrub("../TestPics/1Person-Close.jpg")

Scrub Meta Data

from privyfilter.privyfilter import Privyfilter as pf
img = pf.RemoveMetaData("../TestPics/1Person-Close.jpg")

Face Swap - Inputs imgPath

swapimg = pf.swapFaces("../TestPics/1Person-Close.jpg", "../TestPics/2Person-Close.jpg")
cv2_imshow(swapimg)

EndGoal API:

  • privyfilter.processDir(srcPath, dstPath) - analyze all photos for demographics in srcdirect, if dstdirect - generate the balanced dataset)
  • privyfilter.processOne(srcPath, dstPath) - analyze photo and suggest demographics of balanced photo dataset - if dstpath then generate
  • privyfilter.generatePhoto(srcPhoto, demographic, dstPath) - generate a photo from the original with the demographic params specified
  • privyfilter.findFaces(imgpath, demographics=false) or privyfilter.findFaces(cv2 object) - returns array of faces and can include demographics.
  • privyfilter.scrubFaces(imgPath) or privyfilter.scrubFaces(cv2 object) - returns faces, and scrubbed img
  • privyfilter.swapFaces(img1Path, img2Path) or privyfilter.swapFaces(img1 cv2 object, img2 cv2 Object) - replaces all faces in 2nd image with first. Returns new image as cv2 Object.
  • privyfilter.getFakeFace() - returns fakeface image object
  • privyfilter.replaceFaces(img1) - returns img of all faces randomly replaced with fake ones.

Deploying Module

python setup.py bdist_wheel --universal
twine upload dist/*

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

License

MIT

About

Privy filter is made to give the method for removing/accommodating for unethical bias in data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published