Skip to content

Commit 89aed6a

Browse files
committed
Fix build.
1 parent 302fc86 commit 89aed6a

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

SerialPrograms/Source/ML/DataLabeling/SegmentAnythingModel.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <iostream>
1010
#include <onnxruntime_cxx_api.h>
1111
#include <opencv2/imgcodecs.hpp>
12-
12+
#include "3rdParty/ONNX/OnnxToolsPA.h"
1313
#include "SegmentAnythingModel.h"
1414

1515
namespace PokemonAutomation{
@@ -52,14 +52,14 @@ template<typename T, class Buffer, class Shape> Ort::Value create_tensor(const O
5252

5353

5454
SAMEmbedderSession::SAMEmbedderSession(const std::string& model_path)
55-
: session_options(create_session_option())
56-
, session{env, model_path.c_str(), session_options}
57-
, memory_info{Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU)}
58-
, input_names{session.GetInputNames()}
59-
, output_names{session.GetOutputNames()}
60-
, input_shape{1, SAM_EMBEDDER_INPUT_IMAGE_HEIGHT, SAM_EMBEDDER_INPUT_IMAGE_WIDTH, 3}
61-
, output_shape{1, SAM_EMBEDDER_OUTPUT_N_CHANNELS, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE}
62-
, model_input(SAM_EMBEDDER_INPUT_SIZE)
55+
: session_options(create_session_option())
56+
, session{env, str_to_onnx_str(model_path).c_str(), session_options}
57+
, memory_info{Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU)}
58+
, input_names{session.GetInputNames()}
59+
, output_names{session.GetOutputNames()}
60+
, input_shape{1, SAM_EMBEDDER_INPUT_IMAGE_HEIGHT, SAM_EMBEDDER_INPUT_IMAGE_WIDTH, 3}
61+
, output_shape{1, SAM_EMBEDDER_OUTPUT_N_CHANNELS, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE}
62+
, model_input(SAM_EMBEDDER_INPUT_SIZE)
6363
{
6464
std::cout << "Built SAM embedder session" << std::endl;
6565
}
@@ -92,17 +92,17 @@ void SAMEmbedderSession::run(cv::Mat& input_image, std::vector<float>& model_out
9292

9393

9494
SAMSession::SAMSession(const std::string& model_path)
95-
: session_options(create_session_option())
96-
, session{env, model_path.c_str(), session_options}
97-
, memory_info{Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU)}
98-
, input_names{session.GetInputNames()}
99-
, output_names{session.GetOutputNames()}
100-
, input_image_embedding_shape{1, SAM_EMBEDDER_OUTPUT_N_CHANNELS,
101-
SAM_EMBEDDER_OUTPUT_IMAGE_SIZE, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE}
102-
, input_mask_shape{1, 1, SAM_LOW_RES_MASK_SIZE, SAM_LOW_RES_MASK_SIZE}
103-
, output_low_res_mask_shape{1, 1, SAM_LOW_RES_MASK_SIZE, SAM_LOW_RES_MASK_SIZE}
104-
, input_mask_buffer(SAM_LOW_RES_MASK_SIZE * SAM_LOW_RES_MASK_SIZE, 0.0)
105-
, output_low_res_mask_buffer(SAM_LOW_RES_MASK_SIZE * SAM_LOW_RES_MASK_SIZE, 0.0)
95+
: session_options(create_session_option())
96+
, session{env, str_to_onnx_str(model_path).c_str(), session_options}
97+
, memory_info{Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU)}
98+
, input_names{session.GetInputNames()}
99+
, output_names{session.GetOutputNames()}
100+
, input_image_embedding_shape{1, SAM_EMBEDDER_OUTPUT_N_CHANNELS,
101+
SAM_EMBEDDER_OUTPUT_IMAGE_SIZE, SAM_EMBEDDER_OUTPUT_IMAGE_SIZE}
102+
, input_mask_shape{1, 1, SAM_LOW_RES_MASK_SIZE, SAM_LOW_RES_MASK_SIZE}
103+
, output_low_res_mask_shape{1, 1, SAM_LOW_RES_MASK_SIZE, SAM_LOW_RES_MASK_SIZE}
104+
, input_mask_buffer(SAM_LOW_RES_MASK_SIZE * SAM_LOW_RES_MASK_SIZE, 0.0)
105+
, output_low_res_mask_buffer(SAM_LOW_RES_MASK_SIZE * SAM_LOW_RES_MASK_SIZE, 0.0)
106106
{
107107
std::cout << "Built SAM session" << std::endl;
108108
}
@@ -121,7 +121,7 @@ void SAMSession::run(
121121
assert(input_box.size() == 0 || input_box.size() == 4); // 4 is x_min, y_min, x_max, y_max
122122
assert(input_points.size() > 0 || input_box.size() > 0);
123123

124-
int num_points = input_points.size() / 2;
124+
size_t num_points = input_points.size() / 2;
125125
if(input_box.size() > 0){
126126
num_points += 2; // add the bounding box two corners
127127
}
@@ -247,4 +247,4 @@ bool load_image_embedding(const std::string& image_filepath, std::vector<float>&
247247

248248

249249
}
250-
}
250+
}

SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void DrawnBoundingBox::on_mouse_press(double x, double y){
6868
m_mouse_start->first = x;
6969
m_mouse_start->second = y;
7070
}
71-
void DrawnBoundingBox::on_mouse_release(double x, double y){
71+
void DrawnBoundingBox::on_mouse_release(double, double){
7272
m_mouse_start.reset();
7373

7474
const size_t source_width = m_program.source_image_width;
@@ -82,14 +82,15 @@ void DrawnBoundingBox::on_mouse_release(double x, double y){
8282
return;
8383
}
8484

85-
m_program.m_sam_session.run(m_program.m_image_embedding,
86-
source_height, source_width, {}, {},
85+
m_program.m_sam_session.run(
86+
m_program.m_image_embedding,
87+
(int)source_height, (int)source_width, {}, {},
8788
{box_x, box_y, box_x + box_width, box_y + box_height},
8889
m_program.m_output_boolean_mask
8990
);
9091

91-
for(size_t y = 0; y < source_height; y++){
92-
for(size_t x = 0; x < source_width; x++){
92+
for (size_t y = 0; y < source_height; y++){
93+
for (size_t x = 0; x < source_width; x++){
9394
uint32_t& pixel = m_program.m_mask_image.pixel(x, y);
9495
// if the pixel's mask value is true, set a semi-transparent 45-degree blue strip color
9596
// otherwise: fully transparent (alpha = 0)

0 commit comments

Comments
 (0)