This commit is contained in:
@@ -4,9 +4,9 @@ from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import connect_minio
|
||||
from shared.datastore import Datastore
|
||||
from shared.mongodb import connect_mongodb
|
||||
from shared.mongodb.classes import VisualCommunication
|
||||
from shared.mongodb.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
@@ -20,7 +20,9 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
@@ -30,7 +32,7 @@ if __name__ == '__main__':
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
# generate random predictions
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import connect_minio
|
||||
from shared.datastore import Datastore
|
||||
from shared.mongodb import connect_mongodb, get_visual_communication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
@@ -19,11 +19,13 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get visual communication
|
||||
vis_com = get_visual_communication(collection)
|
||||
print(repr(vis_com))
|
||||
image = vis_com.get_image(minio_client=minio_client)
|
||||
image = vis_com.get_image(minio_client=datastore._client)
|
||||
image.show()
|
||||
|
||||
@@ -5,9 +5,9 @@ from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from pymongo.errors import DuplicateKeyError
|
||||
|
||||
from shared.datastore import connect_minio
|
||||
from shared.datastore import Datastore
|
||||
from shared.mongodb import connect_mongodb
|
||||
from shared.mongodb.classes import VisualCommunication
|
||||
from shared.mongodb.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
@@ -21,7 +21,9 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
@@ -31,7 +33,7 @@ if __name__ == '__main__':
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
for vis_com in vis_com_list:
|
||||
|
||||
@@ -5,9 +5,9 @@ from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from pymongo.errors import DuplicateKeyError
|
||||
|
||||
from shared.datastore import connect_minio
|
||||
from shared.datastore import Datastore
|
||||
from shared.mongodb import connect_mongodb
|
||||
from shared.mongodb.classes import VisualCommunication
|
||||
from shared.mongodb.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
@@ -21,7 +21,9 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
@@ -37,7 +39,7 @@ if __name__ == '__main__':
|
||||
print(f"found {len(img_path_list)} images")
|
||||
# create visual communication objects
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
print(f"created {len(vis_com_list)} visual communication objects")
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ from dotenv import load_dotenv
|
||||
from torchinfo import summary
|
||||
|
||||
from model.src.models import VisualCommunicationModel
|
||||
from shared.datastore import connect_minio, put_model
|
||||
from shared.datastore import Datastore
|
||||
from shared.utils import setup_logging
|
||||
|
||||
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
@@ -20,14 +20,14 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minio
|
||||
client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
# instantiate model
|
||||
model = VisualCommunicationModel().to(DEVICE)
|
||||
# show model weights
|
||||
summary(model)
|
||||
# put buffer in minio bucket
|
||||
hash_str = put_model(
|
||||
client=client,
|
||||
hash_str = datastore.put_model(
|
||||
model=model,
|
||||
)
|
||||
print(f"hash string: {hash_str}")
|
||||
|
||||
@@ -7,7 +7,7 @@ from dotenv import load_dotenv
|
||||
from torchinfo import summary
|
||||
|
||||
from model.src.models import VisualCommunicationModel
|
||||
from shared.datastore import connect_minio, put_model
|
||||
from shared.datastore import Datastore
|
||||
from shared.utils import setup_logging
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -18,14 +18,14 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minio
|
||||
client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
# instantiate model
|
||||
model = VisualCommunicationModel(download_resnet_weights=True)
|
||||
# show model weights
|
||||
summary(model)
|
||||
# put buffer in minio bucket
|
||||
hash_str = put_model(
|
||||
client=client,
|
||||
hash_str = datastore.put_model(
|
||||
model=model,
|
||||
)
|
||||
print(f"hash string: {hash_str}")
|
||||
|
||||
@@ -4,9 +4,9 @@ from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import connect_minio
|
||||
from shared.datastore import Datastore
|
||||
from shared.mongodb import connect_mongodb, upsert_prediction
|
||||
from shared.mongodb.classes import VisualCommunication
|
||||
from shared.mongodb.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
@@ -20,7 +20,9 @@ if __name__ == '__main__':
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
@@ -29,7 +31,7 @@ if __name__ == '__main__':
|
||||
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
# generate random predictions
|
||||
|
||||
Reference in New Issue
Block a user