AI-PredictionClient

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.01 2017-07-12
  - Initial release to CPAN
0.02 2017-07-14
  - Fix dependencies found by CPAN testers. Documentation maintenance
0.03 2017-07-16
  - Bump up dependencies' version requirements
0.04 2017-07-21
  - Bump up dependencies. Documentation maintenance.
0.05 2017-07-23
  - Bump up dependencies.

LICENSE  view on Meta::CPAN

OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>

META.json  view on Meta::CPAN

            "MIME::Base64" : "0",
            "Moo" : "0",
            "Moo::Role" : "0",
            "MooX::Options" : "0",
            "Perl6::Form" : "0",
            "perl" : "5.01",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Test::More" : "0"
         }
      }
   },
   "provides" : {
      "AI::PredictionClient" : {
         "file" : "lib/AI/PredictionClient.pm",
         "version" : "0.05"
      },

Makefile.PL  view on Meta::CPAN

    "Moo::Role" => 0,
    "MooX::Options" => 0,
    "Perl6::Form" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Test::More" => 0
  },
  "VERSION" => "0.05",
  "test" => {
    "TESTS" => "t/*.t"
  }
);

my %FallbackPrereqs = (
  "AI::PredictionClient::Alien::TensorFlowServingProtos" => 0,
  "Alien::Google::GRPC" => 0,
  "Cwd" => 0,
  "Data::Dumper" => 0,
  "Inline" => 0,

cpanfile  view on Meta::CPAN

requires "JSON" => "0";
requires "MIME::Base64" => "0";
requires "Moo" => "0";
requires "Moo::Role" => "0";
requires "MooX::Options" => "0";
requires "Perl6::Form" => "0";
requires "perl" => "5.01";
requires "strict" => "0";
requires "warnings" => "0";

on 'test' => sub {
  requires "Test::More" => "0";
};

on 'configure' => sub {
  requires "AI::PredictionClient::Alien::TensorFlowServingProtos" => "0.05";
  requires "Alien::Google::GRPC" => "0.06";
  requires "ExtUtils::MakeMaker" => "0";
  requires "Inline" => "0";
  requires "Inline::CPP" => "0";
  requires "Inline::MakeMaker" => "0";

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

 Inception.pl --image_file=anything --debug_camel --host=xx7.x11.xx3.x14 --port=9000
 Inception.pl --image_file=grace_hopper.jpg --host=xx7.x11.xx3.x14 --port=9000
 Inception.pl --image_file=anything --debug_camel --debug_loopback --port 2004 --host technologic

=head3 In the examples above, the following points are demonstrated:

If you don't have an image handy --debug_camel will provide a sample image to send to the server. 
The image file argument still needs to be provided to make the command line parser happy.

If you don't have a server to talk to, but want to see if most everything else is working use 
the --debug_loopback_interface. This will provide a sample response you can test the client with. 
The module can use the same loopback interface for debugging your bespoke clients.

The --debug_verbose option will dump the data structures of the request and response to allow
you to see what is going on.

=head3 The response from a live server to the camel image looks like this:

 Inception.pl --image_file=zzzzz --debug_camel --host=107.170.xx.xxx --port=9000    
 Sending image zzzzz to server at host:107.170.xx.xxx  port:9000
 .===========================================================================.

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

otherwise it will build and install its own local copies.

 $ [sudo] apt-get install autoconf automake libtool

See the Alien::Google::GRPC for potential additional build dependencies.

At this time only Linux builds are supported.

=head2 CPAN Testers Note

This module may fail CPAN Testers' tests. 
The build support tools needed by this module and especially the 
Alien::Google::GRPC module are normally installed on the 
CPAN Testers' machines, but not always.

The system build tools dependencies have been reduced, so hopefully 
a large number of machines will build without manually installing 
system dependencies.

=head2 NOTE

This is a complex package with a lot of moving parts. Please pardon if this first release has some minor bug or missing dependency that went undiscovered in my testing.

=head1 AUTHOR

Tom Stall <stall@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Tom Stall.

This is free software; you can redistribute it and/or modify it under

lib/AI/PredictionClient/Docs/Overview.pod  view on Meta::CPAN

 Inception.pl --image_file=anything --debug_camel --host=xx7.x11.xx3.x14 --port=9000
 Inception.pl --image_file=grace_hopper.jpg --host=xx7.x11.xx3.x14 --port=9000
 Inception.pl --image_file=anything --debug_camel --debug_loopback --port 2004 --host technologic

=head3 In the examples above, the following points are demonstrated:

If you don't have an image handy --debug_camel will provide a sample image to send to the server. 
The image file argument still needs to be provided to make the command line parser happy.

If you don't have a server to talk to, but want to see if most everything else is working use 
the --debug_loopback_interface. This will provide a sample response you can test the client with. 
The module can use the same loopback interface for debugging your bespoke clients.

The --debug_verbose option will dump the data structures of the request and response to allow
you to see what is going on.

=head3 The response from a live server to the camel image looks like this:

 Inception.pl --image_file=zzzzz --debug_camel --host=107.170.xx.xxx --port=9000    
 Sending image zzzzz to server at host:107.170.xx.xxx  port:9000
 .===========================================================================.

lib/AI/PredictionClient/Docs/Overview.pod  view on Meta::CPAN

otherwise it will build and install its own local copies.

 $ [sudo] apt-get install autoconf automake libtool

See the Alien::Google::GRPC for potential additional build dependencies.

At this time only Linux builds are supported.

=head2 CPAN Testers Note

This module may fail CPAN Testers' tests. 
The build support tools needed by this module and especially the 
Alien::Google::GRPC module are normally installed on the 
CPAN Testers' machines, but not always.

The system build tools dependencies have been reduced, so hopefully 
a large number of machines will build without manually installing 
system dependencies.

=head2 NOTE

This is a complex package with a lot of moving parts. Please pardon if this first release has some minor bug or missing dependency that went undiscovered in my testing.

=head1 AUTHOR

Tom Stall <stall@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Tom Stall.

This is free software; you can redistribute it and/or modify it under

lib/AI/PredictionClient/InceptionClient.pm  view on Meta::CPAN


sub call_inception {
  my $self  = shift;
  my $image = shift;

  my $tensor = AI::PredictionClient::Classes::SimpleTensor->new();
  $tensor->shape([ { size => 1 } ]);
  $tensor->dtype("DT_STRING");

  if ($self->camel) {
    my $camel_test = AI::PredictionClient::Testing::Camel->new();
    $tensor->value([ $camel_test->camel_jpeg_ref ]);
  } else {
    $tensor->value([$image]);
  }

  $self->inputs({ images => $tensor });

  if ($self->callPredict()) {

    my $predict_output_map_href = $self->outputs;
    my $inception_results_href;

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

use strict;
use warnings;
package AI::PredictionClient::Testing::Camel;
$AI::PredictionClient::Testing::Camel::VERSION = '0.05';
# ABSTRACT: Provides a camel image for testing  in various formats 
use 5.010;
use MIME::Base64 qw( encode_base64 decode_base64 );
use Moo;

my $camel_jpeg_b64;
my $camel_png_b64;

has camel_jpeg_ref => (
  is      => 'lazy',
  builder => 1,

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

gC0AWwC2AGwBeH7G/wLjtM2l8m/OTQAAAABJRU5ErkJggg==';

__END__

=pod

=encoding UTF-8

=head1 NAME

AI::PredictionClient::Testing::Camel - Provides a camel image for testing  in various formats 

=head1 VERSION

version 0.05

=head1 AUTHOR

Tom Stall <stall@cpan.org>

=head1 COPYRIGHT AND LICENSE

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

use strict;
use warnings;
package AI::PredictionClient::Testing::PredictionLoopback;
$AI::PredictionClient::Testing::PredictionLoopback::VERSION = '0.05';

# ABSTRACT: A loopback interface for client testing and development

use 5.010;
use Data::Dumper;
use Moo;

around BUILDARGS => sub {
  my $orig  = shift;
  my $class = shift;

  if (@_ == 1 && !ref $_[0]) {

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

  } else {
    return $class->$orig(@_);
  }
};

has server_port => (is => 'rw',);

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

  my $test_return01
    = '{"outputs":{"classes":{"dtype":"DT_STRING","tensorShape":{"dim":[{"size":"1"},{"size":"6"}]},"stringVal":["bG9vcGJhY2sgdGVzdCBkYXRhCg==","bWlsaXRhcnkgdW5pZm9ybQ==","Ym93IHRpZSwgYm93LXRpZSwgYm93dGll","bW9ydGFyYm9hcmQ=","c3VpdCwgc3VpdCBvZiBjbG90...

  my $test_return02
    = '{"outputs":{"classes":{"dtype":"DT_STRING","tensorShape":{"dim":[{"size":"1"},{"size":"5"}]},"stringVal":["bG9hZCBpdAo=","Y2hlY2sgaXQK","cXVpY2sgLSByZXdyaXRlIGl0Cg==","dGVjaG5vbG9naWMK","dGVjaG5vbG9naWMK"]},"scores":{"dtype":"DT_FLOAT","tensor...

  my $return_ser = '{"Status": "OK", ';
  $return_ser .= '"StatusCode": "42", ';
  $return_ser .= '"StatusMessage": "", ';
  $return_ser .= '"DebugRequestLoopback": ' . $request_data . ', ';

  if ($self->server_port eq 'technologic:2004') {
    $return_ser .= '"Result": ' . $test_return02 . '}';
  } else {
    $return_ser .= '"Result": ' . $test_return01 . '}';
  }

  return $return_ser;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

AI::PredictionClient::Testing::PredictionLoopback - A loopback interface for client testing and development

=head1 VERSION

version 0.05

=head1 AUTHOR

Tom Stall <stall@cpan.org>

=head1 COPYRIGHT AND LICENSE

t/00load.t  view on Meta::CPAN

## no critic(RCS,VERSION,explicit,Module)
use strict;
use warnings;

use Test::More;

BEGIN {
    use_ok('AI::PredictionClient::CPP::PredictionGrpcCpp');
}
ok( 1, 'AI::PredictionClient::CPP::PredictionGrpcCpp loaded.' );
done_testing();

t/author-critic.t  view on Meta::CPAN

#!perl

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    print qq{1..0 # SKIP these tests are for testing by the author\n};
    exit
  }
}


use strict;
use warnings;

use Test::Perl::Critic (-profile => "perlcritic.rc") x!! -e "perlcritic.rc";
all_critic_ok();

t/author-pod-spell.t  view on Meta::CPAN


BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    print qq{1..0 # SKIP these tests are for testing by the author\n};
    exit
  }
}

use strict;
use warnings;
use Test::More;

# generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007004
use Test::Spelling 0.12;

t/author-pod-syntax.t  view on Meta::CPAN

#!perl

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    print qq{1..0 # SKIP these tests are for testing by the author\n};
    exit
  }
}

# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use strict; use warnings;
use Test::More;
use Test::Pod 1.41;

all_pod_files_ok();

t/release-minimum-version.t  view on Meta::CPAN

#!perl

BEGIN {
  unless ($ENV{RELEASE_TESTING}) {
    print qq{1..0 # SKIP these tests are for release candidate testing\n};
    exit
  }
}


use Test::More;

eval "use Test::MinimumVersion";
plan skip_all => "Test::MinimumVersion required for testing minimum versions"
  if $@;
all_minimum_version_ok( qq{5.10.1} );



( run in 0.469 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )