AI-PredictionClient
view release on metacpan or search on metacpan
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/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
( run in 2.161 seconds using v1.01-cache-2.11-cpan-f56aa216473 )