removed unused packages
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import Datastore
|
||||
from shared.docstore import connect_mongodb
|
||||
from shared.docstore.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# ensure env vars set
|
||||
check_env(NECESSARY_ENV_VAR_LIST)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
# generate random predictions
|
||||
for vis_com in vis_com_list:
|
||||
vis_com.generate_random_prediction()
|
||||
for vis_com in vis_com_list:
|
||||
print(vis_com)
|
||||
@@ -1,31 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import Datastore
|
||||
from shared.docstore import connect_mongodb, get_visual_communication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# ensure env vars set
|
||||
check_env(NECESSARY_ENV_VAR_LIST)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to 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=datastore._client)
|
||||
image.show()
|
||||
@@ -1,48 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pymongo.errors import DuplicateKeyError
|
||||
|
||||
from shared.datastore import Datastore
|
||||
from shared.docstore import connect_mongodb
|
||||
from shared.docstore.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# ensure env vars set
|
||||
check_env(NECESSARY_ENV_VAR_LIST)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
for vis_com in vis_com_list:
|
||||
print(repr(vis_com))
|
||||
# upload images
|
||||
for vis_com in vis_com_list:
|
||||
try:
|
||||
result = collection.insert_one(vis_com.model_dump())
|
||||
except DuplicateKeyError as exc:
|
||||
print('ignoring:\n', exc)
|
||||
else:
|
||||
print(f"inserted document: {result}")
|
||||
@@ -1,53 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pymongo.errors import DuplicateKeyError
|
||||
|
||||
from shared.datastore import Datastore
|
||||
from shared.docstore import connect_mongodb
|
||||
from shared.docstore.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# ensure env vars set
|
||||
check_env(NECESSARY_ENV_VAR_LIST)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
ext_img_dir = Path('/Volumes/BW-PSSD/Mixed Methods/')
|
||||
assert ext_img_dir.exists()
|
||||
img_path_list = [
|
||||
path
|
||||
for path in ext_img_dir.glob(
|
||||
'*.jpg',
|
||||
)
|
||||
if path.is_file()
|
||||
]
|
||||
print(f"found {len(img_path_list)} images")
|
||||
# create visual communication objects
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path, minio_client=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
print(f"created {len(vis_com_list)} visual communication objects")
|
||||
# upload images
|
||||
for vis_com in vis_com_list:
|
||||
try:
|
||||
result = collection.insert_one(vis_com.model_dump())
|
||||
except DuplicateKeyError as exc:
|
||||
print('ignoring:\n', exc)
|
||||
else:
|
||||
print(f"inserted document: {result}")
|
||||
@@ -1,34 +0,0 @@
|
||||
"""Test that a model can be saved and loaded again."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import torch
|
||||
from dotenv import load_dotenv
|
||||
from torchinfo import summary
|
||||
|
||||
from model.src.models import VisualCommunicationModel
|
||||
from shared.datastore import Datastore
|
||||
from shared.utils import setup_logging
|
||||
|
||||
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minio
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
# instantiate model
|
||||
model = VisualCommunicationModel().to(DEVICE)
|
||||
# show model weights
|
||||
summary(model)
|
||||
# put buffer in minio bucket
|
||||
hash_str = datastore.put_model(
|
||||
model=model,
|
||||
)
|
||||
print(f"hash string: {hash_str}")
|
||||
print('saved to Minio')
|
||||
@@ -1,32 +0,0 @@
|
||||
"""Definition of function to generate a new randomly initialized model and save
|
||||
it in Minio datastore."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from torchinfo import summary
|
||||
|
||||
from model.src.models import VisualCommunicationModel
|
||||
from shared.datastore import Datastore
|
||||
from shared.utils import setup_logging
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to 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 = datastore.put_model(
|
||||
model=model,
|
||||
)
|
||||
print(f"hash string: {hash_str}")
|
||||
print('saved to Minio')
|
||||
@@ -1,48 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from shared.datastore import Datastore
|
||||
from shared.docstore import connect_mongodb, upsert_prediction
|
||||
from shared.docstore.src.classes import VisualCommunication
|
||||
from shared.utils import check_env, setup_logging
|
||||
from web_ui.src.main import NECESSARY_ENV_VAR_LIST
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load in env file
|
||||
env_path = Path(__file__).parent.parent / 'server.env'
|
||||
assert env_path.exists()
|
||||
load_dotenv(env_path)
|
||||
# ensure env vars set
|
||||
check_env(NECESSARY_ENV_VAR_LIST)
|
||||
# setup logging
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
datastore = Datastore()
|
||||
datastore.connect()
|
||||
assert datastore._client is not None
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongodb()
|
||||
# get list of image paths
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
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=datastore._client)
|
||||
for path in img_path_list
|
||||
]
|
||||
# generate random predictions
|
||||
for vis_com in vis_com_list:
|
||||
vis_com.generate_random_prediction()
|
||||
# upload visual communication
|
||||
for vis_com in vis_com_list:
|
||||
if vis_com.prediction is None:
|
||||
continue
|
||||
upsert_prediction(
|
||||
collection=collection,
|
||||
vis_com_name=vis_com.name,
|
||||
predictions=vis_com.prediction,
|
||||
)
|
||||
Reference in New Issue
Block a user