Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
33c99d6
applied changes
vahagpetrosyan Jan 31, 2024
2322b86
performed testing and bugfixing
vahagpetrosyan Feb 28, 2024
a2666f7
handled aws key hiding
vahagpetrosyan Feb 28, 2024
7796c10
added performance testing and some refinements
vahagpetrosyan Mar 5, 2024
fdf7a12
added CLI and config documentation
vahagpetrosyan Mar 13, 2024
e7a22c5
added benchmarking files
vahagpetrosyan Mar 13, 2024
5992c94
Fixed load balancing, updated documentation
vahagpetrosyan Mar 18, 2024
221d7f0
added licence comments
vahagpetrosyan Mar 19, 2024
7769ebc
added memory clearing
vahagpetrosyan Apr 1, 2024
cdc8def
changed conda environment name to ethosight
hmlatapie Apr 14, 2024
1e95dcd
Update README.md
hmlatapie Apr 14, 2024
1b38e54
Update README.md
hmlatapie Apr 14, 2024
0f5cee9
fixed add_labels bug when new_labels contains no new labels
Apr 24, 2024
b5f0467
some minor updates
Apr 25, 2024
d3f7111
added utilities for working with ucf dataset
Apr 25, 2024
5877175
updated readme with links
Apr 25, 2024
fb2ee84
added initial ansible support
hmlatapie Apr 27, 2024
1c604d3
minor ansible reorg
hmlatapie Apr 27, 2024
ee2f6a6
it woiks now
hmlatapie Apr 27, 2024
34d91de
ansible install and running of dynamic nginx works
hmlatapie Apr 27, 2024
da09519
working on consul template
hmlatapie Apr 28, 2024
00009ac
still working on the consul template
hmlatapie Apr 28, 2024
7507b9e
consul template works
hmlatapie Apr 28, 2024
0d22fe5
ansible consul install and service creation and execution work now
hmlatapie Apr 28, 2024
49df922
gpu service is operational
hmlatapie Apr 29, 2024
5bded77
ansible nginx works
hmlatapie Apr 29, 2024
b765b40
improved nginx service I think
hmlatapie Apr 30, 2024
c933901
fixed server bug by using /tmp for working disk space
hmlatapie Apr 30, 2024
cc56e6e
added support for django
hmlatapie May 1, 2024
9f83af6
fixed a django bug
hmlatapie May 1, 2024
d5685c3
enabling and starting django
hmlatapie May 1, 2024
310ad9a
system survives reboots now
hmlatapie May 1, 2024
3f421c2
added install readme
hmlatapie May 2, 2024
872d3b9
removed email host passwords
vahagpetrosyan Jun 12, 2024
d28b6c5
updated docs
vahagpetrosyan Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Ethosight/Ethosight.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Ethosight/ReasonerInterface.py
Ethosight/__init__.py
Ethosight/langchain_reasoner.py
Ethosight/llama_index_reasoner.py
Ethosight/shared_models.py
Ethosight/utils.py
Ethosight.egg-info/PKG-INFO
Ethosight.egg-info/SOURCES.txt
Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/ChatGPTReasoner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
import openai
import requests
Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/Ethosight.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

# Ethosight environment variables
# EthosightBackend: "core" or "client"
# EthosightBackendURL: URL for EthosightRESTClient backend e.g. http://localhost:8000
Expand Down
28 changes: 25 additions & 3 deletions Ethosight/Ethosight/EthosightApp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from .EthosightMediaAnalyzer import EthosightMediaAnalyzer, EthosightOutput
from .LabelSpaceOptimization import SemanticRelationsOptimization, SemanticSimilarityOptimization
from ruamel.yaml import YAML
Expand Down Expand Up @@ -33,7 +50,7 @@ def __init__(self, app_name, base_dir="ENV"):
if not base_dir:
raise EthosightAppException("ETHOSIGHT_APP_BASEDIR environment variable is not defined.")
if not os.path.isdir(base_dir):
raise EthosightAppException(f"Base directory {base_dir} is not a valid directory.")
raise EthosightAppException(f"Base directory {base_dir} is not a valid directory. Please define a valid directory using ETHOSIGHT_APP_BASEDIR environment variable")

# Ensure the app_dir is an absolute path
self.app_dir = os.path.join(base_dir, app_name)
Expand All @@ -50,8 +67,9 @@ def __init__(self, app_name, base_dir="ENV"):
self.embeddings_path = self.config.get('embeddings_path')
self.labels_path = self.config.get('labels_path')
self.setActiveEmbeddingsFromFile(self.embeddings_path, self.labels_path)
self.groundTruthEmbeddings(makeActive=False)
self.reasoner = ChatGPTReasoner()
if self.config['benchmark']['enabled']:
self.groundTruthEmbeddings(makeActive=False)
self.reasoner = self.config['reasoner_type']

def load_config(self, config_file):
# Assuming the load_config function reads the YAML config file
Expand Down Expand Up @@ -1439,6 +1457,10 @@ def add_labels(self, new_labels):
for label in current_labels:
file.write(f"{label}\n")

if not added_labels:
print("No new labels added.")
return

# compute the new embeddings
new_embeddings = self.ethosight.compute_label_embeddings(added_labels)

Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/EthosightAppCLI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

#!/usr/bin/env python3
import click
from .EthosightApp import EthosightApp
Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/EthosightCLI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

#!/usr/bin/env python3
import click
import os
Expand Down
24 changes: 23 additions & 1 deletion Ethosight/Ethosight/EthosightCore.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
import torch
from models import imagebind_model
Expand All @@ -14,7 +31,7 @@
import torch.nn.functional as F

class EthosightCore:
def __init__(self, model=None, reasoner=None, gpu=0):
def __init__(self, model=None, reasoner='', gpu=0):
#gpu=none means use cpu
self.ethosight_dir = get_install_path('Ethosight')
if model is None:
Expand Down Expand Up @@ -258,6 +275,11 @@ def compute_affinity_scores(self, label_to_embeddings, image_path, normalize_fn=
top_labels = sorted_labels[:100]
top_scores = sorted_scores[:100]

# Clear memory
del vision_embeddings, raw_scores, unique_label_embeddings, inputs
if torch.cuda.is_available():
torch.cuda.empty_cache() # Clear unused memory

# Return the labels and scores as a dictionary
return {'labels': top_labels, 'scores': top_scores}

Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/EthosightDatasetCLI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

#!/usr/bin/env python3
import os
import csv
Expand Down
20 changes: 20 additions & 0 deletions Ethosight/Ethosight/EthosightMediaAnalyzer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
import copy
import yaml
Expand Down Expand Up @@ -65,6 +82,7 @@ class EthosightMediaAnalyzer:
'chatgpt': ChatGPTReasoner,
'langchain': LangchainReasoner,
'llamaindex': LlamaIndexReasoner,
'': ''
# 'narsgpt': NARSGPTReasoner,
# 'nars': NARSReasoner,
}
Expand Down Expand Up @@ -116,6 +134,8 @@ def load_reasoner(self, config):
ReasonerClass = self.REASONER_CLASSES.get(reasoner_type)
if ReasonerClass is None:
raise ValueError(f"Invalid reasoner type: {reasoner_type}")
if ReasonerClass == '':
return ''
return ReasonerClass() # assuming reasoner classes have no-arg constructor


Expand Down
17 changes: 17 additions & 0 deletions Ethosight/Ethosight/EthosightMediaAnalyzerCLI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

#!/usr/bin/env python3
import click
import yaml
Expand Down
Loading