Skip to content

Commit

Permalink
adding Image APIs and deploying moving to prod fly account
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-dhanwant-yral committed Nov 7, 2024
1 parent c73450c commit 0146807
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ swap_size_mb = 32768
[[vm]]
memory = '8gb'
cpu_kind = 'performance'
cpus = 1
cpus = 4
4 changes: 2 additions & 2 deletions localping.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def run():
try:
print("Sending video ID request to server")
metadata = [('authorization', f'Bearer {_JWT_TOKEN}')]
# video_response = stub.DetectNSFWVideoId(nsfw_detector_pb2.NSFWDetectorRequestVideoId(video_id=video_id), metadata=metadata)
# print(video_response)
video_response = stub.DetectNSFWVideoId(nsfw_detector_pb2.NSFWDetectorRequestVideoId(video_id=video_id), metadata=metadata)
print(video_response)

print("Sending image URL request to server")
url_response = stub.DetectNSFWURL(nsfw_detector_pb2.NSFWDetectorRequestURL(url=image_url), metadata=metadata)
Expand Down
4 changes: 2 additions & 2 deletions nsfw_detect_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class NSFWDetect:
def __init__(self, pipe3c, pipe5c):
self.pipe3c = pipe3c
self.pipe5c = pipe5c
service_cred = os.environ.get("SERVICE_CRED")
service_acc_creds = json.loads(service_cred)
service_cred = os.environ.get("GOOGLE_CLOUD_EVENTS_BQ_SERVICE_ACCOUNT_KEY_JSON")
service_acc_creds = json.loads(service_cred, strict=False)
credentials = service_account.Credentials.from_service_account_info(service_acc_creds)
self.gclient = vision.ImageAnnotatorClient(credentials=credentials)

Expand Down
5 changes: 3 additions & 2 deletions ping_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
with open(token_fpath, 'r') as f:
_JWT_TOKEN = f.read()

server_url = 'prod-yral-nsfw-classification.fly.dev:443'
# server_url = 'prod-yral-nsfw-classification.fly.dev:443'
server_url = 'yral-nsfw-classification.fly.dev:443'
# Load the private key from a path specified in an environment variable

def run():
Expand All @@ -22,7 +23,7 @@ def run():
try:
print("Sending request to server")
metadata = [('authorization', f'Bearer {_JWT_TOKEN}')]
response = stub.DetectNSFW(nsfw_detector_pb2.NSFWDetectorRequest(video_id=video_id), metadata=metadata)
response = stub.DetectNSFWVideoId(nsfw_detector_pb2.NSFWDetectorRequestVideoId(video_id=video_id), metadata=metadata)
print(response)
except grpc.RpcError as e:
print(f"RPC failed: {e}")
Expand Down
2 changes: 1 addition & 1 deletion save_model_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def download_blob(bucket_name, source_blob_name, destination_file_name):
# The path to which the file should be downloaded
# destination_file_name = "local/path/to/file"

service_cred = os.environ.get("SERVICE_CRED")
service_cred = os.environ.get("FLY_IO_DEPLOY_TOKEN")
service_acc_creds = json.loads(service_cred)
credentials = service_account.Credentials.from_service_account_info(service_acc_creds)
storage_client = storage.Client(credentials=credentials, project="hot-or-not-feed-intelligence")
Expand Down
2 changes: 1 addition & 1 deletion utils/gcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_images_from_gcs(bucket_name='yral-video-frames', folder_name='', n_worke
"""Downloads all files from a GCS folder and returns a list of PIL images using multithreading."""


service_cred = os.environ.get("SERVICE_CRED")
service_cred = os.environ.get("FLY_IO_DEPLOY_TOKEN")
service_acc_creds = json.loads(service_cred)
credentials = service_account.Credentials.from_service_account_info(service_acc_creds)
storage_client = storage.Client(credentials=credentials, project="hot-or-not-feed-intelligence")
Expand Down

0 comments on commit 0146807

Please sign in to comment.