Spaces:
Running
Running
Updated Vision Key - Hugginsface token - handled s3 bucket issues
Browse files- app.py +3 -3
- audit-edge-cloud-products-6eb51d237f19.json +13 -0
- layoutlmv3FineTuning/Layoutlm_inference/ocr.py +1 -1
- multiple_request.py +5 -5
- requirements.txt +5 -0
- s3_setup.py +3 -3
app.py
CHANGED
@@ -8,9 +8,9 @@ import os
|
|
8 |
|
9 |
# Set Google Application Credentials
|
10 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = (
|
11 |
-
"
|
12 |
)
|
13 |
-
from s3_setup import
|
14 |
import requests
|
15 |
from fastapi import FastAPI, HTTPException, Request
|
16 |
from transformers import LayoutLMv3Processor, LayoutLMv3ForTokenClassification
|
@@ -183,7 +183,7 @@ def perform_inference(file_paths: Dict[str, str], upload_to_s3: bool):
|
|
183 |
|
184 |
# Upload file to S3 if required
|
185 |
if upload_to_s3:
|
186 |
-
client =
|
187 |
bucket_name = "edgekycdocs"
|
188 |
if doc_type == "cin_llpin":
|
189 |
folder_name = f"{doc_type.replace('_', '')}docs"
|
|
|
8 |
|
9 |
# Set Google Application Credentials
|
10 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = (
|
11 |
+
"audit-edge-cloud-products-6eb51d237f19.json"
|
12 |
)
|
13 |
+
from s3_setup import S3Client
|
14 |
import requests
|
15 |
from fastapi import FastAPI, HTTPException, Request
|
16 |
from transformers import LayoutLMv3Processor, LayoutLMv3ForTokenClassification
|
|
|
183 |
|
184 |
# Upload file to S3 if required
|
185 |
if upload_to_s3:
|
186 |
+
client = S3Client()
|
187 |
bucket_name = "edgekycdocs"
|
188 |
if doc_type == "cin_llpin":
|
189 |
folder_name = f"{doc_type.replace('_', '')}docs"
|
audit-edge-cloud-products-6eb51d237f19.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"type": "service_account",
|
3 |
+
"project_id": "audit-edge-cloud-products",
|
4 |
+
"private_key_id": "6eb51d237f190a8ebb472e8813e0e72c4669ec74",
|
5 |
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDTeM+ZXVi8eCYe\nBEtP0QlZfQgEvZhYWpOH9N3HX7tusRDTfAsnyMaDA/dVSVsfSc4OVDx3BZgIw55J\n0orMw9UFMSbYQAlu5QY2MDP0XnywbbxTCXEd8jJluQ/667qxB/hAXMLS8GRd+CMb\ncPf8TVZHFHXaxGGHOw7CoR4RyactQch/8xggDOgkFSCS5vJgOKYUcQM8UrZ+SEXB\nNeXP3daj6lIdCFN9clGYilTeotBh03qLr6U7LP5WoCX93DlCRrLtPmCckMLsMMWk\npCX8TwM024Xf+udSoM9gpBM8+eS7t2ZKOoBJvLAMxRj5ap7WnC4OMuknMpucUxLc\nFSn6OlQ1AgMBAAECggEAE9Eu9yrJvYOu4sI5QoYOz72JSlRwGduHFscKH3xnpqRe\nNMtbikNk4vM0st/Yc7KpZitbrTWvfSbDxxw9WJoDdOSZxMsfdy5sKhjTTZOrMKdf\n7hIk8Q74zRKOHlAH4z4hc/qdYUIYzbuKorAv9QtUSf3vW2xqzU7p/7A0jqssiO+F\nAvV7dr+9m1E13gKcbxElT69yQHIGW+YrQhRj1UEjvADP1WhFulp4uB6G7FY39r4j\n3IkIGGribcCO203emhWbIokieJXMbIR5rjtFgEUm89DP4I6+udVnNEGP0z/HuMkR\nP44wiifl2+KfAEGno9uZeKpsAO/o63k22nNUv9SQ0QKBgQD43uHNS6aPPcdlJUbU\naz2VVto53g6jIZ5j2wXj/Ek+GkuAkKLqjRDGkoIAZOgbRWFzTYLFTVN/l2ANMEpQ\n/ZgfFED4z5eirKMVYHwzKPxImNyGxW2zJg4Y4lGNDo/2TLrod9J6nbsurGO3UXXb\nCVYJYoavl74CqQ3BTbEU6O4oLQKBgQDZh6lg1Dl7GT+n/pTICiHAvGPqEtPvGbKb\nzDu5T9HUXlR7i8Q2tHkstegF/axFu+wy24O86r64Q8i132avb0DLZ+7A3pLAJ4GX\nj2BLjB8C2TKNFWYHvHBSgjVs8yKh+6gPVZZZe7fO4BmQuNTcP6+Bd9f2+gX0SLIe\nvKxFHz+ZKQKBgGLMEHXwf1nEG8EykDDJtfPwO8fXOJZYRUm87FS6ldT6mVibkqFs\niOlbxhIj/OS+oVYlwjFTZj9zt6Tks8v9MIO+BaEAwGDLCh71Y7jnn2euj3VNMSR6\nigQk7F0EF/CeO2EIGF2m+mUn+JoQ06m1xhsJqxBQPBVQSW6gyhjT85+tAoGBAJkT\n7a71ScoFt5UaA0tOTfha2pjzTO8aj2Ux8Ol0cT3Yb+1NKvQwRoGfNTtaC2w7VXlo\nnqlILJRxJwJNxu44BUnextY1CuJsKrckL2ian4wamodMArP4+LYnaT9VTg7dkKPR\n3+7ysCPF8le0qh6gNnqOgo0L3zrMGYSl0zkFR3UZAoGACbn/H+yk/lM82f7ifegj\nA27xMnHZ9PkbiZVyA33cihh2g5E4Vsms90UDGxIv6adVmVL/RNsOhZ9E2RqTxwT0\nfa0MMIE4goiSxvGRF9zlSQgYEfBuu2V0qsnVyRzSSedYQLfOzF1M1PNcciVpoPeP\nIuJocuvwxUvuvQEug0VoiEc=\n-----END PRIVATE KEY-----\n",
|
6 |
+
"client_email": "audit-edge-service-account@audit-edge-cloud-products.iam.gserviceaccount.com",
|
7 |
+
"client_id": "116362056709639897324",
|
8 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
9 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
10 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
11 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/audit-edge-service-account%40audit-edge-cloud-products.iam.gserviceaccount.com",
|
12 |
+
"universe_domain": "googleapis.com"
|
13 |
+
}
|
layoutlmv3FineTuning/Layoutlm_inference/ocr.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import pandas as pd
|
3 |
|
4 |
import os
|
5 |
-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./
|
6 |
|
7 |
|
8 |
|
|
|
2 |
import pandas as pd
|
3 |
|
4 |
import os
|
5 |
+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./audit-edge-cloud-products-6eb51d237f19.json"
|
6 |
|
7 |
|
8 |
|
multiple_request.py
CHANGED
@@ -12,8 +12,8 @@ print("dummy_key",dummy_key)
|
|
12 |
|
13 |
# Define the API endpoint
|
14 |
#http://43.204.234.114:8000/api/aadhar_ocr
|
15 |
-
|
16 |
-
API_URL = "https://auditedge-optimised-ocr.hf.space/api/aadhar_ocr"
|
17 |
|
18 |
auth_token = HUGGINGFACE_AUTH_TOKEN # Replace with your actual token
|
19 |
|
@@ -27,8 +27,8 @@ print("this is response\n\n",response.text)
|
|
27 |
|
28 |
# Define the file paths
|
29 |
FILE_PATHS = {
|
30 |
-
"aadhar_file": "uploads/aadhar/test_one.jpg",
|
31 |
-
|
32 |
# "cheque_file": "test_images_cheque/0f81678a.jpeg",
|
33 |
# "gst_file": "test_images_gst/0a52fbcb_page3_image_0.jpg",
|
34 |
}
|
@@ -73,7 +73,7 @@ def test_api_concurrency(num_requests):
|
|
73 |
print(f"\nTotal time taken: {end_time - start_time:.2f} seconds")
|
74 |
|
75 |
# Number of concurrent requests
|
76 |
-
NUM_REQUESTS =
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
test_api_concurrency(NUM_REQUESTS)
|
|
|
12 |
|
13 |
# Define the API endpoint
|
14 |
#http://43.204.234.114:8000/api/aadhar_ocr
|
15 |
+
API_URL = "http://127.0.0.1:7860/api/aadhar_ocr"
|
16 |
+
# API_URL = "https://auditedge-optimised-ocr.hf.space/api/aadhar_ocr"
|
17 |
|
18 |
auth_token = HUGGINGFACE_AUTH_TOKEN # Replace with your actual token
|
19 |
|
|
|
27 |
|
28 |
# Define the file paths
|
29 |
FILE_PATHS = {
|
30 |
+
# "aadhar_file": "uploads/aadhar/test_one.jpg",
|
31 |
+
"pan_file": "uploads/pan/6ea33087.jpeg",
|
32 |
# "cheque_file": "test_images_cheque/0f81678a.jpeg",
|
33 |
# "gst_file": "test_images_gst/0a52fbcb_page3_image_0.jpg",
|
34 |
}
|
|
|
73 |
print(f"\nTotal time taken: {end_time - start_time:.2f} seconds")
|
74 |
|
75 |
# Number of concurrent requests
|
76 |
+
NUM_REQUESTS = 1 # Adjust this number based on your testing needs
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
test_api_concurrency(NUM_REQUESTS)
|
requirements.txt
CHANGED
@@ -13,3 +13,8 @@ boto3
|
|
13 |
|
14 |
python-multipart
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
python-multipart
|
15 |
|
16 |
+
|
17 |
+
#Stage two installations
|
18 |
+
|
19 |
+
Django
|
20 |
+
pdf2image
|
s3_setup.py
CHANGED
@@ -7,7 +7,7 @@ import sys
|
|
7 |
from utils import doc_processing
|
8 |
import mimetypes
|
9 |
from pathlib import Path
|
10 |
-
from django.conf import settings
|
11 |
|
12 |
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
13 |
|
@@ -47,8 +47,8 @@ print("AWS_SECRET_ACCESS_KEY", AWS_SECRET_ACCESS_KEY)
|
|
47 |
|
48 |
class S3Client:
|
49 |
def __init__(self):
|
50 |
-
self.aws_access_key_id =
|
51 |
-
self.aws_secret_access_key =
|
52 |
self.s3_client = boto3.client(
|
53 |
"s3",
|
54 |
aws_access_key_id=self.aws_access_key_id,
|
|
|
7 |
from utils import doc_processing
|
8 |
import mimetypes
|
9 |
from pathlib import Path
|
10 |
+
# from django.conf import settings
|
11 |
|
12 |
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
13 |
|
|
|
47 |
|
48 |
class S3Client:
|
49 |
def __init__(self):
|
50 |
+
self.aws_access_key_id = AWS_ACCESS_KEY_ID
|
51 |
+
self.aws_secret_access_key = AWS_SECRET_ACCESS_KEY
|
52 |
self.s3_client = boto3.client(
|
53 |
"s3",
|
54 |
aws_access_key_id=self.aws_access_key_id,
|