#include "chrome/renderer/companion/visual_query/visual_query_classification_and_eligibility.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/tflite/src/tensorflow/lite/kernels/builtin_op_kernels.h"
#include "third_party/tflite/src/tensorflow/lite/op_resolver.h"
#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/task_api_factory.h"
#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/vision/image_classifier.h"
namespace companion::visual_query {
namespace {
ImageClassifier;
constexpr char kPosition[] = …;
constexpr char kStatic[] = …;
constexpr char kZIndex[] = …;
constexpr int kImageSize = …;
constexpr char kNegativeShoppingLabel[] = …;
constexpr char kNegativeSensitivityLabel[] = …;
bool OrOfThresholdingRuleLooksGood(const OrOfThresholdingRules& rules) { … }
ClassificationMetrics CalculateClassificatonMetrics(
EligibilityModule& eligibility_module,
const std::vector<ImageId>& first_pass_images,
const std::vector<ImageId>& second_pass_images) { … }
bool EligibilitySpecLooksGood(const EligibilitySpec& eligibility_spec) { … }
std::unique_ptr<tflite::MutableOpResolver> CreateOpResolver() { … }
std::unique_ptr<ImageClassifier> CreateClassifier(std::string model_data) { … }
std::string GetModelInput(const SkBitmap& bitmap, int width, int height) { … }
double GetScoreOfFirstClassThatDoesNotHaveName(
const std::string& avoid_name,
const tflite::task::vision::Classifications& classification) { … }
}
SingleImageGeometryFeatures
VisualClassificationAndEligibility::ExtractFeaturesForEligibility(
const ImageId& image_identifier,
blink::WebElement& element) { … }
std::unique_ptr<VisualClassificationAndEligibility>
VisualClassificationAndEligibility::Create(
const std::string& model_bytes,
const EligibilitySpec& eligibility_spec) { … }
std::vector<ImageId>
VisualClassificationAndEligibility::RunClassificationAndEligibility(
base::flat_map<ImageId, SingleImageFeaturesAndBytes>& images,
const gfx::SizeF& viewport_size) { … }
VisualClassificationAndEligibility::~VisualClassificationAndEligibility() =
default;
std::pair<double, double> VisualClassificationAndEligibility::ClassifyImage(
const SkBitmap& bitmap) { … }
VisualClassificationAndEligibility::VisualClassificationAndEligibility() =
default;
}