File size: 1,290 Bytes
4986f6d
b245237
 
 
4986f6d
 
 
dc66a7c
4986f6d
b245237
 
4986f6d
 
5dad19d
 
4986f6d
 
 
 
b245237
4986f6d
 
 
b245237
4986f6d
 
 
 
b245237
dc66a7c
 
 
 
 
4986f6d
dc66a7c
40a6098
b245237
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import json
import logging

from dotenv import load_dotenv
from mmdeploy_runtime import Detector
from supabase import create_client, Client
import firebase_admin
from firebase_admin import credentials, initialize_app
from firebase_admin import firestore
from neo4j import GraphDatabase


logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


load_dotenv()

# LOAD MODEL
model_path = "./model"
detector = Detector(model_path=model_path, device_name="cpu", device_id=0)

# LOAD SUPABASE
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key)

# LOAD FIREBASE ADMIN SDK
if not firebase_admin._apps:
    firebase_app = initialize_app(
        credential=credentials.Certificate(
            json.loads(os.environ.get("FIREBASE_CREDENTIALS"))
        )
    )
else:
    firebase_app = firebase_admin.get_app()
db = firestore.client()

# LOAD NEO4J DB
URI = os.environ.get("NEO4J_URI")
AUTH = (os.environ.get("NEO4J_USERNAME"), os.environ.get("NEO4J_PASSWORD"))
driver = GraphDatabase.driver(URI, auth=AUTH)
driver.verify_connectivity()
driver.execute_query(
    "CREATE CONSTRAINT uid IF NOT EXISTS FOR (p:Person) REQUIRE p.uid IS UNIQUE"
)