- Clone the repository
First, clone the repository containing the scripts to your local machine. You can do this by using the following command in your terminal:
git clone https://github.com/actuallyrizzn/matrixsearchReplace <repository URL> with the URL of your Git repository.
- Set up a virtual environment (optional, but recommended)
To prevent your project's dependencies from interfering with your other Python projects, it's best to create a virtual environment. Here's how to do it:
python3 -m venv myenvAnd then activate it with:
source myenv/bin/activate # On Windows, use `myenv\Scripts\activate`- Install necessary Python packages
The scripts require several Python packages. Install them with:
pip install google-cloud-vision python-dotenv requests tqdm opencv-python Pillow beautifulsoup4- Set up Google Cloud Vision API
You need to set up a Google Cloud Project, enable the Cloud Vision API, and create an API key file (.json file):
- Follow the Google Cloud Vision API Python Client documentation to set up a Google Cloud Project and enable the Cloud Vision API.
- Go to the API & Services → Credentials page on the Google Cloud Console, and create a new API key. This will download a
.jsonfile.
- Configure the API key file
- Rename the downloaded file to
.google_creds.jsonand move it into the main project folder. - This file should have the following structure:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "your-private-key-id",
"private_key": "your-private-key",
"client_email": "your-client-email",
"client_id": "your-client-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "your-client-cert-url",
"universe_domain": "googleapis.com",
"api_key":"your-api-key",
"cse_id":"your-cse-id"
}Replace all "your-xxx" parts with your actual credentials.
- Configure input JSON files
- The script
image_scraper.pyrequires a JSON file formatted in the following way:
{
"name1": ["category1", "category2", ...],
"name2": ["category1", "category2", ...],
...
}- Save this file in the main project folder. The name of the person will be searched on Google Images along with each category.
- Run the scripts
- Now you can run
image_scraper.pyto download images for each person, andcrop_faces.pyto crop faces from the downloaded images.