Metadata-Version: 2.1
Name: wikifaces
Version: 1.0.8
Summary: A downloader for named images containing faces from Wiki servers.
Author-email: "Trenton W. Ford" <twford@wm.edu>, Ruiting Shao <shao72@purdue.edu>
License: MIT License
        
        Copyright (c) 2023 Trenton W. Ford
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/tford9/Wiki-Faces-Downloader
Project-URL: Issues, https://github.com/tford9/Wiki-Faces-Downloader/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: facenet-pytorch
Requires-Dist: pymediawiki
Requires-Dist: tqdm
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: opencv-python
Provides-Extra: dev
Requires-Dist: pylint~=2.14.0; extra == "dev"
Requires-Dist: toml~=0.10.2; extra == "dev"
Requires-Dist: yapf~=0.32.0; extra == "dev"

# Wiki Faces:

[![License: MIT License](https://img.shields.io/badge/License%3A-MIT%20License-red)](https://mit-license.org/)
<figure>
  <img src="https://github.com/tford9/Wiki-Faces-Downloader/blob/main/Joko_Widodo_Wiki.png" style="width:100%">
  <figcaption>Figure 1: Joko Widodo's Wikipedia page, which includes am image of his face. The cropped image on the right is download into a directory named "Joko_Widodo."</figcaption>
</figure>

## TLDR

This project downloads images from a Wiki that include human faces. Specifically, images that are associated with
certain wikipedia categories.

## Installation

<img src="https://img.shields.io/badge/python%20-%2314354C.svg?&style=for-the-badge&logo=python&logoColor=white"/> <img src="https://img.shields.io/badge/PyTorch%20-%23EE4C2C.svg?&style=for-the-badge&logo=PyTorch&logoColor=white" />

Pip Installation Procedure:

#### From PIP:

```commandline
pip install wikifaces 
```

#### From Repo:

```commandline
git clone git@github.com:tford9/Wiki-Faces-Downloader.git
cd Wiki-Faces-Downloader
python setup.py
pip install wikifaces
```

## Usage

#### Command-Line Example

```commandline
python downloader -i "indonesian engineers" -o ../data/ -d
```

#### Package Example

```python
from wikifaces.downloader import WikiFace

wikiface_obj = WikiFace()
wikiface_obj.download(categories=['facebook'], depth=2, output_location='../data/')
```

The following structure is output:

- `facebook`
    - `cached_1_people_pages_d2.pkl`
    - `cached_pages_d2.pkl`
    - `alan_rushbridger`
        - `Alan_Rusbridger_01.jpg-p0.jpg`
    - `...`
    - `mark_zuckerberg`
        - `MarkZuckerbergcrop.jpg-p1.jpg`
    - `...`

The process is carried out as follows:

1. Given a category from a Wiki, collect *n* pages that contain the same category as well as at least one category
   containing "people" in the title.
2. With those pages, crawl across their included categories and collect *y* pages that contain those categories as well
   as at least one "people" category.
3. Given the collected Wiki pages, download the primary image from the page and determine if it is a human face using
   light facial detection.
4. We capture all images from the wiki that contain the name of the page (if it's a person then the filename contains
   their name),
5. Using the captured name and images, we create a dataset for that face.

TODOs:

1. Currently, a part of this process uses a recursive call structure to get all related pages; there may be a way to
   linearize, or parallelize this.
2. Currently, we are only pulling images contain the person's name in the title and only have one visible face in the
   image. All other images are not considered. A voting system should be added to get the most represented faces across
   multiple images.
