jacob-stein commited on
Commit
d587396
·
1 Parent(s): a70329e

Update google cloud ocr

Browse files
modules/google_cloud_ocr/google_cloud_ocr.py CHANGED
@@ -5,12 +5,15 @@ from google.cloud import vision
5
 
6
  load_dotenv()
7
 
8
- google_creds = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
9
 
10
- if google_creds is None:
11
- raise EnvironmentError("GOOGLE_APPLICATION_CREDENTIALS not set in .env file")
12
 
13
- client = vision.ImageAnnotatorClient()
 
 
 
14
 
15
  def google_cloud_ocr(tiff_file):
16
  content = tiff_file.read()
 
5
 
6
  load_dotenv()
7
 
8
+ google_creds_json = os.getenv('GOOGLE_CLOUD_CREDENTIALS')
9
 
10
+ if google_creds_json is None:
11
+ raise EnvironmentError("GOOGLE_CLOUD_CREDENTIALS not set in Hugging Face Secrets")
12
 
13
+ credentials_dict = json.loads(google_creds_json)
14
+
15
+ credentials = service_account.Credentials.from_service_account_info(credentials_dict)
16
+ client = vision.ImageAnnotatorClient(credentials=credentials)
17
 
18
  def google_cloud_ocr(tiff_file):
19
  content = tiff_file.read()