DeepSafe - DeepFake Detection made easy
- WebApp
- DeepSafe API
- Chrome Extension
WebApp - Live here
This is a limited access app, for the full access contact me.
- Clone the repository:
git clone https://github.com/siddharthksah/DeepSafe
cd DeepSafe
- Creating conda environment
- Main supported version : 3.8
- Other supported versions : 3.7 & 3.9
conda create -n deepsafe python==3.8 -y
conda activate deepsafe
- Install dependencies:
pip install -r requirements.txt
- Download Model Weights
Service | Google Drive | Mega Drive |
---|---|---|
Link | Google Drive | Mega Drive |
Or you can use Gdown
pip install gdown
# to upgrade
pip install --upgrade gdown
import gdown
#this takes a while cause the folder is quite big about 3.4G
url = "https://drive.google.com/drive/folders/1Gan21zLaPD0wHbNF3P3a7BzgKE91BOpq?usp=sharing
gdown.download_folder(url, quiet=True, use_cookies=False)
- Start the application:
streamlit run main.py
#Base Image to use
FROM python:3.7.9-slim
#Expose port 8080
EXPOSE 8080
#Optional - install git to fetch packages directly from github
RUN apt-get update && apt-get install -y git
RUN apt-get install ffmpeg libsm6 libxext6 -y
#Copy Requirements.txt file into app directory
COPY requirements.txt app/requirements.txt
#install all requirements in requirements.txt
RUN pip install -r app/requirements.txt
#Copy all files in current directory into app directory
COPY . /app
#Change Working Directory to app directory
WORKDIR /app
#Run the application on port 8080
ENTRYPOINT ["streamlit", "run", "main.py", "--server.port=8080", "--server.address=0.0.0.0"]
Building the Docker Image
docker build -f Dockerfile -t app:latest .
Running the docker image and creating the container
docker run -p 8501:8501 app:latest
Getting the image to Docker Hub
After you made your own Docker image, you can sign up for an account on https://hub.docker.com/. After verifying your email you are ready to go and upload your first docker image.
- Log in on https://hub.docker.com/
- Click on Create Repository.
- Choose a name (e.g. verse_gapminder) and a description for your repository and click Create.
- Log into the Docker Hub from the command line
docker login --username=yourhubusername --email=youremail@company.com
just with your own user name and email that you used for the account. Enter your password when prompted. If everything worked you will get a message similar to
WARNING: login credentials saved in /home/username/.docker/config.json
Login Succeeded
Check the image ID using
docker images
and what you will see will be similar to
REPOSITORY TAG IMAGE ID CREATED SIZE
verse_gapminder_gsl latest 023ab91c6291 3 minutes ago 1.975 GB
verse_gapminder latest bb38976d03cf 13 minutes ago 1.955 GB
rocker/verse latest 0168d115f220 3 days ago 1.954 GB
and tag your image
docker tag bb38976d03cf yourhubusername/verse_gapminder:firsttry
The number must match the image ID and :firsttry is the tag. In general, a good choice for a tag is something that will help you understand what this container should be used in conjunction with, or what it represents. If this container contains the analysis for a paper, consider using that paper’s DOI or journal-issued serial number; if it’s meant for use with a particular version of a code or data version control repo, that’s a good choice too - whatever will help you understand what this particular image is intended for.
Push your image to the repository you created
docker push yourhubusername/verse_gapminder
Command to build the application. Please remeber to change the project name and application name
gcloud builds submit --tag gcr.io/<ProjectName>/<AppName> --project=<ProjectName>
Command to deploy the application
gcloud run deploy --image gcr.io/<ProjectName>/<AppName> --platform managed --project=<ProjectName> --allow-unauthenticated
To install the app on Google Cloud, need to have account and gcloud tool installed in the system. Initiate GCloud
gcloud init
Set Project,Billing, Service Account and Region and Zone exmaple to set Region as Mumbai India...
gcloud config set compute/region asia-south1
gcloud config set compute/zone asia-south1-b
Enable Container Registry and Cloud Run Api run the following command in glocud terminal
gcloud services enable run.googleapis.com containerregistry.googleapis.com
Push Local Image to GCP Cloud Container Registry Following command will allow local docker engine tobe used by gcloud tool
gcloud auth configure-docker
Following step will create a tag of the local image as per gcp requirment.
docker tag st_demo:v1.0 gcr.io/< GCP PROJECT ID > /st_demo:v1.0
Push Local Image to GCP Registry
docker push gcr.io/< GCP PROJECT ID > /st_demo:v1.0
Finally ! Deploy on Serverless Cloud Run Run the following Single Line command to deploy / host the app.
gcloud run deploy < service name > --image < gcp image name> --platform managed --allow-unauthenticated --region < your region > --memory 2Gi --timeout=3600
< service name > : Service Name User Supplied < gcp image name> : Image Pushed into GCP < your region > : Region was set at the Gcloud Init. < platform managed > : GCP Specific Parameter, consult GCP Manual for further details. < allow-unauthenticated > : GCP Specific Parameter, consult GCP Manual for further details. < memory > : Memory to be allocated for the container deployment. < timeout > : GCP Specific Parameter, consult GCP Manual for further details. For streamlit deployment, this value should be set to a high value to avoid a timeout / connection error.
Any kind of enhancement or contribution is welcomed.