Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontends/tensorflow/docs/supported_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV
| RFFT | YES | |
| RFFT2D | YES | |
| RFFT3D | YES | |
| RGBToHSV | NO | |
| RGBToHSV | YES | |
| RaggedBincount | NO | |
| RaggedCountSparseOutput | NO | |
| RaggedCross | NO | |
Expand Down
1 change: 1 addition & 0 deletions src/frontends/tensorflow/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops() {
{"RFFT", CreatorFunction(translate_rfft_op)},
{"RFFT2D", CreatorFunction(translate_rfft_op)},
{"RFFT3D", CreatorFunction(translate_rfft_op)},
{"RGBToHSV", CreatorFunction(translate_rgb_to_hsv_op)},
{"Rint", CreatorFunction(translate_rint_op)},
{"Roll", CreatorFunction(translate_roll_op)},
{"Round", CreatorFunction(translate_round_op)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ OP_CONVERTER(translate_reverse_op);
OP_CONVERTER(translate_reverse_v2_op);
OP_CONVERTER(translate_reverse_sequence_op);
OP_CONVERTER(translate_rfft_op);
OP_CONVERTER(translate_rgb_to_hsv_op);
OP_CONVERTER(translate_rint_op);
OP_CONVERTER(translate_roll_op);
OP_CONVERTER(translate_round_op);
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/tensorflow_common/include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ ov::Output<ov::Node> get_data_slice(const ov::Output<ov::Node>& data,
ov::Output<ov::Node> compute_broadcast_args(const ov::Output<ov::Node>& shape1, const ov::Output<ov::Node>& shape2);

std::shared_ptr<std::tuple<std::shared_ptr<ov::Node>, std::shared_ptr<ov::Node>, std::shared_ptr<ov::Node>>> rgb_to_hsv(
const std::shared_ptr<ov::Node>& images);
const ov::Output<ov::Node>& images);

std::shared_ptr<ov::Node> hsv_to_rgb(const ov::Output<ov::Node>& h,
const ov::Output<ov::Node>& s,
Expand Down
38 changes: 38 additions & 0 deletions src/frontends/tensorflow_common/src/op/rgb_to_hsv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "common_op_table.hpp"
#include "openvino/op/concat.hpp"
#include "utils.hpp"

using namespace std;
using namespace ov;
using namespace ov::op;

namespace ov {
namespace frontend {
namespace tensorflow {
namespace op {

OutputVector translate_rgb_to_hsv_op(const NodeContext& node) {
default_op_checks(node, 1, {"RGBToHSV"});
auto images = node.get_input(0);
auto node_name = node.get_name();

auto hsv_components = rgb_to_hsv(images);

auto hh = get<0>(*hsv_components);
auto ss = get<1>(*hsv_components);
auto vv = get<2>(*hsv_components);

auto rgb = make_shared<v0::Concat>(NodeVector{hh, ss, vv}, -1);

set_node_name(node_name, rgb);
return {rgb};
}

} // namespace op
} // namespace tensorflow
} // namespace frontend
} // namespace ov
2 changes: 1 addition & 1 deletion src/frontends/tensorflow_common/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Output<Node> compute_broadcast_args(const Output<Node>& shape1, const Output<Nod
return broadcasted_shape->output(0);
}

shared_ptr<tuple<shared_ptr<Node>, shared_ptr<Node>, shared_ptr<Node>>> rgb_to_hsv(const shared_ptr<Node>& images) {
shared_ptr<tuple<shared_ptr<Node>, shared_ptr<Node>, shared_ptr<Node>>> rgb_to_hsv(const ov::Output<ov::Node>& images) {
// image format conversion based on
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/image/adjust_saturation_op.cc
auto const_zero_f_ = create_same_type_const_scalar<float>(images, 0.0f);
Expand Down
54 changes: 54 additions & 0 deletions tests/layer_tests/tensorflow_tests/test_tf_RGBToHSV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest

rng = np.random.default_rng(3476123)


class TestRGBToHSV(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'images:0' in inputs_info
if self.special_case == 'Black Image':
images_shape = inputs_info['images:0']
inputs_data = {}
inputs_data['images:0'] = np.zeros(images_shape).astype(self.input_type)
elif self.special_case == 'Grayscale Image':
images_shape = inputs_info['images:0']
inputs_data = {}
inputs_data['images:0'] = np.ones(images_shape).astype(self.input_type) * rng.random()
else:
images_shape = inputs_info['images:0']
inputs_data = {}
inputs_data['images:0'] = rng.random(images_shape).astype(self.input_type)

return inputs_data

def create_rgb_to_hsv_net(self, input_shape, input_type, special_case):
self.special_case = special_case
self.input_type = input_type
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
images = tf.compat.v1.placeholder(input_type, input_shape, 'images')
tf.raw_ops.RGBToHSV(images=images)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def

return tf_net, None

@pytest.mark.parametrize('input_shape', [[2, 3], [5, 6, 3], [2, 5, 10, 3]])
@pytest.mark.parametrize('input_type', [np.float32, np.float64])
@pytest.mark.parametrize('special_case', [None, 'Black Image', 'Grayscale Image'])
@pytest.mark.precommit
@pytest.mark.nightly
def test_adjust_hue_basic(self, input_shape, input_type, special_case,
ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
self._test(*self.create_rgb_to_hsv_net(input_shape, input_type, special_case),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)