Git Product home page Git Product logo

celebaspoofchallengesubmissionexample's Introduction

CelebA-Spoof Challenge Submission Example

This repo provides an example Docker image for submission of CelebA-Spoof Challenge 2020. The submission is in the form of online evaluation.

Note: We highly recommend the participants to test their Docker images before submission. Or your code may not be run properly on the online evaluation platform. Please refer to Test the Docker image locally for instructions.

Before you start: request resource provision

  1. Create an account on the challenge website (CodaLab), as well as an AWS account (in any region except Beijing and Ningxia).
  2. Register CelebA-Spoof Challenge 2020 using the created CodaLab account.
  3. Send yours following information to the orgnizers' email address: [email protected]. We will check and allocate evaluation resources for you. (Very Important!)
    • CodaLab user name (i.e. team name)
    • The number of team members
    • Affiliation
    • CodaLab email address
    • Emails of all team members
    • AWS account id (12 digits)

Install and configure AWS CLI

AWS CLI is required. (version 2 is recommended)

After installation, you should configure the settings that the AWS Command Line Interface (AWS CLI) uses to interact with AWS:

  1. Generate the AWS Access Key ID and AWS Secret Access Key in IAM: AWS Management Console -> Find Services -> Enter 'IAM' -> Choose IAM (Manage access to AWS resources) -> Delete your root access keys -> Manage security credentials -> Access keys (access key ID and secret access key) -> Create New Access Key.

  2. Run this command: aws configure

    Then it will require you to input AWS Access Key ID, AWS Secret Access Key, Default region name (please input us-west-2) and Default output format (left it empty). If you still have questions, please refer to here.

Install Docker Engine

In order to build your Docker image, you should install Docker Engine first. Please refer to Install Docker Engine.

Install nvidia-docker

Because GPU is necessary for both the local test and online evaluation, we also need to install nvidia-docker. Please refer to nvidia-docker.

Obtain this example

Run the following command to clone this submission example repo:

git clone https://github.com/Davidzhangyuanhan/CelebASpoofChallengeSubmissionExample.git

Include your own algorithm & Build Docker image

  • Your algorithm codes should be put in model.
  • Your detector should inherit CelebASpoofDetector class in eval_kit/detector.py. For example:
sys.path.append('..')
from eval_kit.detector import CelebASpoofDetector

class AENetPredictor(CelebASpoofDetector): # You can give your detector any name.
    ...

You need to implement the abstract function predict(self, image) in your detector class:

    @abstractmethod
    def predict(self, image):
        """
        Process a list of image, the evaluation toolkit will measure the runtime of every call to this method.
        The time cost will include any thing that's between the image input to the final prediction score.
        The image will be given as a numpy array in the shape of (H, W, C) with dtype np.uint8.
        The color mode of the image will be **RGB**.
        
        params:
            - image (np.array): numpy array of required image
        return:
            - probablity
        """
        pass
  • Modify Line 29 in run_evalution.py to import your own detector for evaluation.
########################################################################################################
# please change this line to include your own detector extending the eval_kit.detector.CelebASpoofDetector base class.
from predictor import AENetPredictor as CelebASpoofDetector
########################################################################################################

Test the Docker image locally

The online evaluation for submissions may take several hours. It is slow to debug on the cloud. Here we provide some tools for the participants to locally test the correctness of the submission.

Before running, modify Line 32 in local_test.py.

To verify your algorithm can be run properly, run the following command:

docker run -it celeba-spoof-challenge-<your_aws_id> python3 local_test.py

Please refer to step 2 and 3 in Submit the Docker image to learn how to tag your Docker image.

It will run the algorithms in the evaluation workflow on some sample images and print out the results.

The output will look like:

    ================================================================================
    All images finished, showing verification info below:
    ================================================================================

INFO:root:Image ID: 494405.png
INFO:root:      gt: 1
INFO:root:      output probability: 0.9999998807907104
INFO:root:
INFO:root:Image ID: 494406.png
INFO:root:      gt: 1
INFO:root:      output probability: 0.999998927116394
INFO:root:
INFO:root:Image ID: 494410.png
INFO:root:      gt: 0
INFO:root:      output probability: 6.803428732382599e-06
INFO:root:
INFO:root:Image ID: 494415.png
INFO:root:      gt: 0
INFO:root:      output probability: 3.3887470181070967e-06
INFO:root:
INFO:root:Done

Submit the Docker image

You can push your Docker image to the allocated ECR repo as following steps:

(692230297653 is organizers' AWS account, please don't change)

  • Step 1. Retrieve the login command to use to authenticate your Docker client to your registry. Use the AWS CLI:
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 692230297653.dkr.ecr.us-west-2.amazonaws.com
  • Step 2. Build your Docker image using the following command. For information on building a Docker file from scratch see the instructions here. You can skip this step if your image has already been built:
cd ../CelebASpoofChallengeSubmissionExample
docker build -t celeba-spoof-challenge-<your_aws_id> .  # . means the current path. Please don't lose it.
# Example
# docker build -t celeba-spoof-challenge-123412341234 . 
  • Step 3. After the build is completed, tag your image so you can push the image to the repository:
docker tag celeba-spoof-challenge-<your_aws_id>:latest 692230297653.dkr.ecr.us-west-2.amazonaws.com/celeba-spoof-challenge-<your_aws_id>:latest
  • Step 4. Run the following command to push this image to your AWS ECR repository:
docker push 692230297653.dkr.ecr.us-west-2.amazonaws.com/celeba-spoof-challenge-<your_aws_id>:latest

After you push to the repo, the evaluation will automatically start. In 45 minutes you should receive a email with the evaluation result if the evaluation is successful. Finally, you can submit the evaluation result to the challenge website.

Acknowledgments

We sincerely thank the codebase from DeeperForensics Challenge, especially for the instruction from Zhengkui Guo and Liming Jiang.

celebaspoofchallengesubmissionexample's People

Contributors

zhangyuanhan-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

celebaspoofchallengesubmissionexample's Issues

Anyone with a successful submission?

Use exactly the given codes (AENet) in this example project to build docker images and run successfully in local environment, but no result was given.
Seems that there are errors when submitting, but no bug infos are given.
Could anyone give an example?

What is type of image in test set?

Hi @davidzhangyuanhan ,
I see all images on your example (['494405.png' '494406.png' '494410.png' '494415.png']) are cropped faces.
I'd like to know images on the test set whether is raw images as public data or processed images (cropped faces)?
It will affect my evaluation pipeline.

Thank you!

[Error at last step "pushing docker image on aws"]

After running docker push 692230297653.dkr.ecr.us-west-2.amazonaws.com/celeba-spoof-challenge-<your_aws_id>:latest got the error

denied: User: arn:aws:iam::871259748386:root is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:us-west-2:692230297653:repository/celeba-spoof-challenge-871259748386

Have anyone got this error?? Please help me.

Error at step 2: Build docker image

When i running docker build -t celeba-spoof-challenge-<my aws id> . I got this error.

`Sending build context to Docker daemon 176.5MB
Step 1/6 : FROM pytorch/pytorch:1.5-cuda10.1-cudnn7-runtime
---> a10c611c2731
Step 2/6 : RUN apt update && apt install -y -q libfontconfig1 libxrender1 libglib2.0-0 libsm6 libxext6 ucspi-tcp
---> Using cache
---> 28544dcff6e1
Step 3/6 : RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple install boto3 opencv-python-headless pillow numpy scipy matplotlib ipython jupyter pandas sympy nose
---> Running in d9d0c12f8a82
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting install
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f0/a5/fd2eb807a9a593869ee8b7a6bcb4ad84a6eb31cef5c24d1bfbf7c938c13f/install-1.3.4-py3-none-any.whl (3.1 kB)
Collecting boto3
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4b/b9/88fbe33f4f4862b06eed9e1fb05abb8883b0bf2683a87f21c45d597adc5a/boto3-1.15.17-py2.py3-none-any.whl (129 kB)
Collecting opencv-python-headless
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/75/d8/72fc2b7dc38e36a1c66fa672d91c8158481c433f67ec45585465bc0aedcf/opencv_python_headless-4.4.0.44-cp37-cp37m-manylinux2014_x86_64.whl (36.7 MB)
ERROR: Exception:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 313, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1840, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/opt/conda/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1646, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 425, in _error_catcher
yield
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/opt/conda/lib/python3.7/http/client.py", line 457, in read
n = self.readinto(b)
File "/opt/conda/lib/python3.7/http/client.py", line 501, in readinto
n = self.fp.readinto(b)
File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 326, in recv_into
raise timeout("The read operation timed out")
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 331, in run
resolver.resolve(requirement_set)
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
hashes=hashes,
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 287, in unpack_url
hashes=hashes,
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 159, in unpack_http_url
link, downloader, temp_dir.path, hashes
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 303, in _download_http_url
for chunk in download.chunks:
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/utils/ui.py", line 160, in iter
for x in it:
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/network/utils.py", line 39, in response_chunks
decode_content=False,
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/opt/conda/lib/python3.7/contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 430, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out.
The command '/bin/sh -c pip install -i https://pypi.tuna.tsinghua.edu.cn/simple install boto3 opencv-python-headless pillow numpy scipy matplotlib ipython jupyter pandas sympy nose' returned a non-zero code: 2`
I am beginer with docker so please help me.

Can not build docker on CentOS system

the current file named Dockerfile could not run properly in CentOS system, due to its command is for ubuntu only.
Could you provide Dockerfile in CentOS version?

Error by test the Docker image locally

When I run docker run -it celeba-spoof-challenge-<my_aws_id> python3 local_test.py
It appear error due to not detect GPU.
Is the above command correct?
Or add option --gpus all : docker run -it --gpus all celeba-spoof-challenge-<my_aws_id> python3 local_test.py ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.