AI-PredictionClient

 view release on metacpan or  search on metacpan

bin/Inception.pl  view on Meta::CPAN

  $client->debug_verbose($self->debug_verbose);
  $client->loopback($self->debug_loopback_interface);
  $client->camel($self->debug_camel);

  printf("Sending image %s to server at host:%s  port:%s\n",
    $self->image_file, $self->host, $self->port);

  if ($client->call_inception($image_ref)) {

    my $results_ref         = $client->inception_results;
    my $classifications_ref = $results_ref->{'classes'};
    my $scores_ref          = $results_ref->{'scores'};
    my $comments            = 'Clasification Results for ' . $self->image_file;

    my $results_text
      = form
      '.===========================================================================.',
      '| Class                                                     | Score         |',
      '|-----------------------------------------------------------+---------------|',
      '| {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[} |{]].[[[[[[[[}  |',
      $classifications_ref, $scores_ref,
      '|===========================================================================|',
      '| {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[}                   |',
      $comments,
      "'==========================================================================='";

    print $results_text;

  } else {
    printf("Failed. Status: %s, Status Code: %s, Status Message: %s \n",
      $client->status, $client->status_code, $client->status_message);
    return 1;
  }
  return 0;
}

sub read_image {
  my $self = shift;

  return \'' if $self->debug_camel;

  my $file_name     = shift;
  my $max_file_size = 16 * 1000 * 1000;  # A large but safe maximum

  open(my $fh, '<:raw', $file_name)
    or die "Could not open file: $file_name";

  read($fh, my $buffer, $max_file_size);

  close $fh;

  return \$buffer;
}

exit main->new_with_options->run;

__END__

=pod

=encoding UTF-8

=head1 NAME

Inception.pl - Runnable example command line Inception client

=head1 VERSION

version 0.05

=head1 PLEASE SEE FOR DOCUMENTATION

L<AI::PredictionClient>

=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
the same terms as the Perl 5 programming language system itself.

=cut

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.576 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )