Spaces:
Sleeping
Sleeping
Google Cloud OCR Setup with Python
Step 1: Create a Google Cloud Project
- Go to the Google Cloud Console.
- Create a New Project:
- In the top-left corner, click the project dropdown menu and then "New Project."
- Enter a project name (e.g., "OCR Project") and click "Create."
Step 2: Enable the Cloud Vision API
- In the Google Cloud Console, go to the Navigation Menu (three horizontal lines at the top left).
- Click on APIs & Services > Library.
- In the search bar, type Vision API.
- Select Cloud Vision API and click Enable.
Step 3: Create Service Account Credentials
- Navigate to APIs & Services > Credentials.
- Click on Create Credentials > Service Account.
- Service Account Details:
- Give the service account a name (e.g., "vision-api-service-account").
- Click "Create and Continue."
- Grant Permissions:
- Choose Role: Select "Project" > "Editor" to give your service account sufficient permissions.
- Click "Continue."
- Create JSON Key:
- After creating the service account, click on the three dots next to the account.
- Select "Manage Keys" > "Add Key" > "Create New Key."
- Choose JSON format and download the JSON file. This file contains your credentials.
Step 4: Set Up the .env File
Create a new file named
.envin the root directory of your Python project.Add the following line to the
.envfile, replacing the path with the actual path to your downloaded JSON credentials file:GOOGLE_APPLICATION_CREDENTIALS=/path-to-your-credentials.json
Step 5: Running the script
- Ensure you have the needed package:
pip install google-cloud-vision python-dotenv
- Run the script and see the text files for outputs