Project import generated by Copybara.

GitOrigin-RevId: 6e5aa035cd1f6a9333962df5d3ab97a05bd5744e
This commit is contained in:
MediaPipe Team
2022-06-28 12:11:05 +00:00
committed by Sebastian Schmidt
parent 4a20e9909d
commit c688862570
144 changed files with 5772 additions and 2118 deletions
+2
View File
@@ -137,6 +137,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":label_map_cc_proto",
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:integral_types",
"//mediapipe/framework/port:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
-5
View File
@@ -33,8 +33,3 @@ message LabelMapItem {
// hierarchy.
repeated string child_name = 3;
}
// Mapping from index to a label map item.
message LabelMap {
map<int64, LabelMapItem> index_to_item = 1;
}
+3 -3
View File
@@ -25,7 +25,7 @@
namespace mediapipe {
absl::StatusOr<LabelMap> BuildLabelMapFromFiles(
absl::StatusOr<proto_ns::Map<int64, LabelMapItem>> BuildLabelMapFromFiles(
absl::string_view labels_file_contents,
absl::string_view display_names_file) {
if (labels_file_contents.empty()) {
@@ -68,9 +68,9 @@ absl::StatusOr<LabelMap> BuildLabelMapFromFiles(
label_map_items[i].set_display_name(display_names[i]);
}
}
LabelMap label_map;
proto_ns::Map<int64, LabelMapItem> label_map;
for (int i = 0; i < label_map_items.size(); ++i) {
(*label_map.mutable_index_to_item())[i] = label_map_items[i];
label_map[i] = label_map_items[i];
}
return label_map;
}
+5 -3
View File
@@ -16,6 +16,8 @@
#define MEDIAPIPE_UTIL_LABEL_MAP_UTIL_H_
#include "absl/strings/string_view.h"
#include "mediapipe/framework/port/integral_types.h"
#include "mediapipe/framework/port/proto_ns.h"
#include "mediapipe/framework/port/statusor.h"
#include "mediapipe/util/label_map.pb.h"
@@ -25,9 +27,9 @@ namespace mediapipe {
// both expected to contain one label per line.
// Returns an error e.g. if there's a mismatch between the number of labels and
// display names.
absl::StatusOr<mediapipe::LabelMap> BuildLabelMapFromFiles(
absl::string_view labels_file_contents,
absl::string_view display_names_file);
absl::StatusOr<proto_ns::Map<int64, ::mediapipe::LabelMapItem>>
BuildLabelMapFromFiles(absl::string_view labels_file_contents,
absl::string_view display_names_file);
} // namespace mediapipe
+2 -1
View File
@@ -422,7 +422,7 @@ tasks and tracking (or class) fields for tracking information.
|`region/point/x`|feature list float list|`add_bbox_point_x` / `AddBBoxPointX`|A list of normalized x values for points in a frame.|
|`region/point/y`|feature list float list|`add_bbox_point_y` / `AddBBoxPointY`|A list of normalized y values for points in a frame.|
|`region/point/\*`| *special* |`add_bbox_point` / `AddBBoxPoint`|Operates on point/x,point/y with a single call.|
|`region/point/radius`|feature list float list|`add_bbox_point_radius` / `AddBBoxPointRadius`|A list of radii for points in a frame.|
|`region/radius`|feature list float list|`add_bbox_point_radius` / `AddBBoxRadius`|A list of radii for points in a frame.|
|`region/3d_point/x`|feature list float list|`add_bbox_3d_point_x` / `AddBBox3dPointX`|A list of normalized x values for points in a frame.|
|`region/3d_point/y`|feature list float list|`add_bbox_3d_point_y` / `AddBBox3dPointY`|A list of normalized y values for points in a frame.|
|`region/3d_point/z`|feature list float list|`add_bbox_3d_point_z` / `AddBBox3dPointZ`|A list of normalized z values for points in a frame.|
@@ -460,6 +460,7 @@ tasks and tracking (or class) fields for tracking information.
|`image/label/confidence`|feature list float list|`add_image_label_confidence` / `AddImageLabelConfidence`|If an image at a specific timestamp should have a label, use this. If a range of time, prefer Segments instead.|
|`image/format`|context bytes|`set_image_format` / `SetImageFormat`|The encoding format of the images.|
|`image/channels`|context int|`set_image_channels` / `SetImageChannels`|The number of channels in the image.|
|`image/colorspace`|context bytes|`set_image_colorspace` / `SetColorspace`|The colorspace of the images.|
|`image/height`|context int|`set_image_height` / `SetImageHeight`|The height of the image in pixels.|
|`image/width`|context int|`set_image_width` / `SetImageWidth`|The width of the image in pixels.|
|`image/frame_rate`|context float|`set_image_frame_rate` / `SetImageFrameRate`|The rate of images in frames per second.|
+2 -1
View File
@@ -161,7 +161,8 @@ absl::Status ReconcileMetadataFeatureFloats(
if (absl::StrContains(key, kFeatureFloatsKey)) {
const auto prefix = key.substr(0, key.find(kFeatureFloatsKey) - 1);
int number_of_elements = GetFeatureFloatsAt(prefix, *sequence, 0).size();
if (HasFeatureDimensions(prefix, *sequence)) {
if (HasFeatureDimensions(prefix, *sequence) &&
!GetFeatureDimensions(prefix, *sequence).empty()) {
int64 product = 1;
for (int64 value : GetFeatureDimensions(prefix, *sequence)) {
product *= value;
+3
View File
@@ -501,6 +501,9 @@ void Clear3dPoint(const std::string& prefix,
FIXED_PREFIX_VECTOR_BYTES_FEATURE_LIST( \
CONCAT_STR2(identifier, EmbeddingEncoded), kRegionEmbeddingEncodedKey, \
prefix) \
FIXED_PREFIX_VECTOR_FLOAT_FEATURE_LIST( \
CONCAT_STR2(identifier, EmbeddingConfidence), \
kRegionEmbeddingConfidenceKey, prefix) \
FIXED_PREFIX_VECTOR_INT64_CONTEXT_FEATURE( \
CONCAT_STR2(identifier, EmbeddingDimensionsPerRegion), \
kRegionEmbeddingDimensionsPerRegionKey, prefix) \
@@ -400,12 +400,20 @@ TEST(MediaSequenceTest, RoundTripBBoxEmbedding) {
tensorflow::SequenceExample sequence;
std::vector<std::vector<std::string>> embeddings = {
{"embedding00", "embedding01"}, {"embedding10", "embedding11"}};
std::vector<std::vector<float>> confidences = {{0.7, 0.8}, {0.9, 0.95}};
for (int i = 0; i < embeddings.size(); ++i) {
AddBBoxEmbeddingEncoded("GT_KEY", embeddings[i], &sequence);
ASSERT_EQ(GetBBoxEmbeddingEncodedSize("GT_KEY", sequence), i + 1);
const auto& sequence_embeddings =
GetBBoxEmbeddingEncodedAt("GT_KEY", sequence, i);
EXPECT_THAT(sequence_embeddings, testing::ElementsAreArray(embeddings[i]));
AddBBoxEmbeddingConfidence("GT_KEY", confidences[i], &sequence);
ASSERT_EQ(GetBBoxEmbeddingConfidenceSize("GT_KEY", sequence), i + 1);
const auto& sequence_confidences =
GetBBoxEmbeddingConfidenceAt("GT_KEY", sequence, i);
EXPECT_THAT(sequence_confidences,
testing::ElementsAreArray(confidences[i]));
}
}
-1
View File
@@ -648,7 +648,6 @@ bool MotionBoxLines(const MotionBoxState& state, const Vector2_f& scaling,
std::array<Vector3_f, 4>* box_lines) {
CHECK(box_lines);
std::array<Vector2_f, 4> corners = MotionBoxCorners(state, scaling);
std::array<Vector3_f, 4> lines;
for (int k = 0; k < 4; ++k) {
const Vector2_f diff = corners[(k + 1) % 4] - corners[k];
const Vector2_f normal = diff.Ortho().Normalize();