AI-PredictionClient

 view release on metacpan or  search on metacpan

bin/Inception.pl  view on Meta::CPAN

use AI::PredictionClient::InceptionClient;
# PODNAME: Inception.pl
# ABSTRACT: Runnable example command line Inception client

use Moo;
use MooX::Options;
use 5.010;
use Data::Dumper qw(Dumper);
use Perl6::Form;

my $default_host            = '127.0.0.1';
my $default_port            = '9000';
my $default_model           = 'inception';
my $default_model_signature = 'predict_images';

option image_file => (
  is       => 'ro',
  required => 1,
  format   => 's',
  doc      => '* Required: Path to image to be processed'
);
option host => (
  is       => 'ro',
  required => 0,
  format   => 's',
  default  => $default_host,
  doc      => "IP address of the server [Default: $default_host]"
);
option port => (
  is       => 'ro',
  required => 0,
  format   => 's',
  default  => $default_port,
  doc      => "Port number of the server [Default: $default_port]"
);
option model_name => (
  is       => 'ro',
  required => 0,
  format   => 's',
  default  => $default_model,
  doc      => "Model to process image [Default: $default_model]"
);
option model_signature => (
  is       => 'ro',
  required => 0,
  format   => 's',
  default  => $default_model_signature,
  doc      => "API signature for model [Default: $default_model_signature]"
);
option debug_verbose => (is => 'ro', doc => 'Verbose output');
option debug_loopback_interface => (
  is       => 'ro',
  required => 0,
  doc      => "Test loopback through dummy server"
);
option debug_camel => (
  is       => 'ro',
  required => 0,

lib/AI/PredictionClient/Classes/SimpleTensor.pm  view on Meta::CPAN


  if (@_ == 1) {
    return $class->$orig(tensor_ds => $_[0]);
  } else {
    return $class->$orig(@_);
  }
};

has tensor_ds => (
  is      => 'ro',
  default => sub {
    {
      dtype       => "DT_STRING",
      tensorShape => { dim => [ { size => 1 } ] },
      stringVal   => [""] };
  },
);

sub shape {
  my ($self, $shape_aref) = @_;

lib/AI/PredictionClient/Classes/SimpleTensor.pm  view on Meta::CPAN

sub dtype {
  my ($self, $dtype) = @_;
  my $tensor_dtype_ref = \$self->tensor_ds->{"dtype"};
  $$tensor_dtype_ref = $dtype if $dtype;

  return $$tensor_dtype_ref;
}

has use_base64_strings => (
  is      => 'rw',
  default => 0,
);

has dtype_values => (
  is      => 'ro',
  default => sub {
    {
      DT_HALF       => 'halfVal',
      DT_FLOAT      => 'floatVal',
      DT_DOUBLE     => 'doubleVal',
      DT_INT16      => 'intVal',
      DT_INT8       => 'intVal',
      DT_UINT8      => 'intVal',
      DT_STRING     => 'stringVal',
      DT_COMPLEX64  => 'scomplexVal',
      DT_INT64      => 'int64Val',

lib/AI/PredictionClient/Roles/PredictionRole.pm  view on Meta::CPAN

use Data::Dumper;
use MIME::Base64 qw( encode_base64 decode_base64 );
use Moo::Role;

has host => (is => 'ro');

has port => (is => 'ro',);

has loopback => (
  is      => 'rw',
  default => 0,
);

has debug_verbose => (
  is      => 'rw',
  default => 0,
);

has perception_client_object => (
  is      => 'lazy',
  builder => 1,
);

sub _build_perception_client_object {
  my $self = $_[0];

  my $server_port = $self->host . ':' . $self->port;
  return $self->loopback
    ? AI::PredictionClient::Testing::PredictionLoopback->new($server_port)
    : AI::PredictionClient::CPP::PredictionGrpcCpp::PredictionClient->new(
    $server_port);
}

has request_ds => (
  is      => 'ro',
  default => sub { { modelSpec => { name => "", signatureName => "" } } },
);

has reply_ds => (
  is      => 'rwp',
  default => sub { {} },
);

sub model_name {
  my ($self, $model_name) = @_;
  $self->request_ds->{"modelSpec"}->{"name"} = $model_name;
  return;
}

sub model_signature {
  my ($self, $model_signature) = @_;

lib/AI/PredictionClient/Testing/Camel.pm  view on Meta::CPAN

  builder => 1,
);

sub _build_camel_png_ref {
  my $self = $_[0];
  return \decode_base64(${ $self->camel_png_b64_ref });
}

has camel_jpeg_b64_ref => (
  is      => 'ro',
  default => sub { \$camel_jpeg_b64 },
);

has camel_png_b64_ref => (
  is      => 'ro',
  default => sub { \$camel_png_b64 },
);

$camel_jpeg_b64
  = '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkS
Ew8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJ
CQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy
MjIyMjIyMjIyMjIyMjL/wAARCABAAEADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEA
AAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIh
MUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6
Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZ



( run in 0.583 second using v1.01-cache-2.11-cpan-0a6323c29d9 )