Skip to content

Commit

Permalink
typo in label studio
Browse files Browse the repository at this point in the history
  • Loading branch information
bw4sz committed Nov 28, 2024
1 parent fe74d52 commit 1c6307d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/label_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def import_image_tasks(label_studio_project, image_names, local_image_dir, predi
for index, image_name in enumerate(image_names):
print(f"Importing {image_name} into Label Studio")
data_dict = {'image': os.path.join("/data/local-files/?d=input/", os.path.basename(image_name))}
if predictions:
if predictions is not None:
prediction = predictions[index]
# Skip predictions if there are none
if prediction.empty:
Expand Down
3 changes: 2 additions & 1 deletion src/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def run(self):
# Align the predictions with the cropped images
# Run the annotation pipeline
if len(image_paths) > 0:
label_studio.upload_to_label_studio(images=image_paths,
full_image_paths = [os.path.join(self.config.active_learning.image_dir, image) for image in image_paths]
label_studio.upload_to_label_studio(images=full_image_paths,
sftp_client=self.sftp_client,
label_studio_project=self.label_studio_project,
images_to_annotate_dir=self.config.active_learning.image_dir,
Expand Down
13 changes: 12 additions & 1 deletion src/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ def __init__(self, report_dir, image_dir, pipeline_monitor=None):
self.image_dir = image_dir
self.pipeline_monitor = pipeline_monitor

def concat_predictions(self):
"""Concatenate predictions
Args:
predictions: List of dataframes containing predictions
"""
self.all_predictions = pd.concat(self.pipeline_monitor.predictions, ignore_index=True)

def generate_report(self):
"""Generate a report"""
self.all_predictions = pd.concat(self.pipeline_monitor.predictions)

self.concat_predictions()
self.write_predictions()
self.write_metrics()
self.generate_video()

def write_predictions(self):
"""Write predictions to a csv file"""
self.concat_predictions()
self.all_predictions.to_csv(f"{self.report_dir}/predictions.csv", index=False)

return f"{self.report_dir}/predictions.csv"
Expand All @@ -37,6 +46,7 @@ def get_coco_datasets(self):

def generate_video(self):
"""Generate a video from the predictions"""
self.concat_predictions()
visualizer = PredictionVisualizer(self.all_predictions, self.report_dir)
output_path = f"{self.report_dir}/predictions.mp4"
images = self.all_predictions['image_path'].unique()
Expand All @@ -52,6 +62,7 @@ def write_metrics(self):
Args:
pipeline_monitor: PipelineEvaluation instance containing model performance metrics
"""
self.concat_predictions()
# Get current timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

Expand Down
4 changes: 2 additions & 2 deletions submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#SBATCH --output=/home/b.weinstein/logs/BOEM%j.out # Standard output and error log
#SBATCH --error=/home/b.weinstein/logs/BOEM%j.err
#SBATCH --partition=gpu
#SBATCH --gpus=3
#SBATCH --gpus=1

source activate BOEM

cd ~/BOEM/
python main.py active_learning.gpus = 3
python main.py active_learning.pool_limit=5000 active_learning.n_images=100
2 changes: 1 addition & 1 deletion tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def pipeline_monitor(config, random_model, random_crop_model):

@pytest.fixture
def reporter(config, pipeline_monitor, tmpdir_factory):
report_dir = tmpdir_factory.mktemp("report_dir").strpath
report_dir = tmpdir_factory.mktemp("report_dir").strpath
return reporting.Reporting(report_dir, config.reporting.image_dir, pipeline_monitor)

def test_generate_video(reporter):
Expand Down

0 comments on commit 1c6307d

Please sign in to comment.