Use Tensorflow trained models as a service - google-app-engine

I just started with tensorflow. I was able to successfully train it for a data set that I created. Now the question is that how will I be able to use this model to make predictions. I want to make it as a REST service, to which I will be able to pass some values and get the predictions as response. Any helpful links are also welcome. The model is currently on a VM.
Thanks :)

Have you seen Cloud ML on GCP? It might be exactly what you're looking for.
https://cloud.google.com/ml/
You might need to make a few tweaks to the architecture of your model - like variable batch sizes and adding inputs/outputs to collections - but they are well explained in the documentation.
If performance, scalability and a short downtime if you decide to update the model are not an issue, you could also consider just having a simple flask server with tensorflow installed on it.
If you don't want to use Cloud ML and need to serve a large amount of requests then look into the tensorflow serving.

First of all: try saving and loading your model: https://www.tensorflow.org/versions/r0.11/how_tos/variables/index.html
Then, after training, you can simply call:
rest_prediction = sess.run(prediction_tensor, feed_dict={x_tensor: user_input})
An important difference is that during training you have batch_size inputs, but when you have a REST server you have 1 input. The shape (https://www.tensorflow.org/versions/r0.11/resources/dims_types.html) of your tensors should be variable. How you can achieve this can be found here: https://www.tensorflow.org/versions/r0.11/resources/faq.html#tensor-shapes
If you post a short and simple code snippet we might be able to help you better.

Related

Sagemaker Inference Endpoint with fitted Encoder

So as I don't get any help by reading documentations and blogposts I ll ask over here:
I want to deploy a Sagemaker Endpoint with fitting a Sagemaker Pipeline. I want to have an endpoint which is backed by a PipelineModel. This PipelineModel should consist of two models: A fitted model which encodes my data and a model which predicts with an XGBoost estimator. I follow along this docu: enter link description here
But this example doesn't show how to integrate the fitted preprocessor model in a PipelineStep. What Step do I have to use? A TrainingStep? Thanks in advance. I am desperate
Check out this official example: Train register and deploy a pipeline model.
The two variations to keep in mind:
For models that need training (usually for those based on tensorflow/pytorch), a TrainingStep must be used so that the output (the model artifact) is correctly (and automatically) generated with the ability to use it later for inference.
For models generated by a simple fitting on the data (e.g., a scaler with sklearn), you can think about creating a TrainingStep in disguised (it is an extra component in pipeline, it is not very correct to do it but it is a working round) but the more correct method is to configure the preprocessing script so that it internally saves a model.tar.gz file with the necessary files (e.g., pickle or joblib objects) inside it can then be properly used in later steps as model_data. In fact, if you have a model.tar.gz, you can define a Model of various types (e.g., an SKLearnModel) that is already fitted.
At this point, you define your PipelineModel with the trained/fitted models and can either proceed to direct endpoint deployment or decide to go through the model registry and keep a more robust approach.

How to create and train own model with own dataset?

I want create and train own model. If not possible to create own, any way to train other models? (Yolo, MobileNet, Coco?)
There some requirements:
- I know only JS (tried Python, no, i don't continue, i can't, Python best language, but i can't, sorry)
- Performance, at least 24 FPS, like real-time detection
- Own dataset freedom (like file /dogs/pitbull/01.png)
I tried Python, but i don't/can't work in Python due of 10 years experience with JS doesn't lets me use Python
Thanks for everyone for help
This answer is written by an IBMer.
If you want to build a model like the one described (image classification/object detection) without having to deal with python - and you want to use it with javascript in a browser, you can try the tooling available at https://cloud.annotations.ai/. It works with a IBM Cloud account but you can stay go on with the free tier - so you just need to register, at least to do your first experiments.
You'll find here https://github.com/cloud-annotations code and boilerplate to use your model on different platform.
It is not an advanced tool but it enables you to put your hands on the topic.

How can I get data into a Sails.js app from a MongoDB?

I have a Sails.js app that needs to fetch from a Mongo database, then display that data in a graph. Alternately, it can take data from a JSON file located on the server.
I am struggling with that process immensely. What seems like it should be an easy task is anything but. I should mention that I am not terribly familiar with Sails.js, but this is what I was directed to use.
I am seeking either examples, documentation, advice, pointers, alternatives, basically anything that would point me in the right direction.
I realize that this is likely to generate a lot of opinion over the "best" and that's not what I am after. I am looking for direction towards resources or guidance on technique.
Thanks.
you can read this link to understand how integrate mongodb with sails.js
i will list logic steps to understand how you can get data
after install mongodb-sails driver in package.json to open
connection between sails and mongodb
you have to define model which map your mongodb documents to
Models
define model attributes
you can use waterline to get document , findbycolumnname and make
CRUD operations

Receive XML post to Salesforce Sites page

I'm currently looking at building a lightweight integration between PivotalTracker and Salesforce.com. Reviewing this bit of PT documentation, it looks like I can do an update of Salesforce data based on PT activity. Awesome! I can't figure out how to access the XML data that is being posted however.
I can't see anything in ApexPages.CurrentPage() that looks like it will let me get to the XML. Has anyone done anything like this, without the use of an intermediate server?
I think we chatted about this over Twitter last week.
AFAIK there is (somewhat annoyingly) no way to access raw (i.e. not form posted key/values) POST data via SFDC. The Apex REST service support would be the closest thing, but requires authentication and still may not do exactly what you want.
Fairly certain you'll need some sort of middle-man proxy that simply takes the XML data and posts it to VF as a form-encoded key/value pair. That is a fairly trivial thing to do, but it's an unnecessary additional moving part and will require some sort of server resource.
I would probably first investigate if PT supports any other ping mechanism, or a way to write a custom extension to convert the raw POST into a form POST.

Integrating CakePHP and Sage Pay (Protx)

I am needing to integrate Sage Pay on our website to accept online payments.
I have downloaded and tested the PHP kit provided by Sage and have run a few successful tests, however, I don't know where to start when it comes to integrating this with Cake PHP.
If anybody has some initial pointers or ideas, or even links (multiple, varied Google searches yielded nothing) that would be great ...
Many thanks,
Dave
Hi there,thanks for the reply, and apologies for the delayed replying myself. I have it all working now, except my final issue as that I need to parse the final response returned from SagePay. The demo has the following code in the final step that gets posted to my site (to an action), The code they have is as follows:
...
$strVPSSignature=$_REQUEST["VPSSignature"];
$strStatusDetail=$_REQUEST["StatusDetail"];
...
Obviously this won't work due to Cake's routing. How do you suggest I parse these value>
Thanks again.
Dave
Haven't used Sagepay but a few pointers anyway:
Third party PHP classes should be loaded as vendors, so that is what I would do with their PHP kit.
This guy thinks SagePay's kit is a mess so you might find using his classes is easier to grok.
Although some might say payments belong in the business layer (your model), you might find it easier to initially perform payments from the controller layer. As such, I would start by creating a simple component with the inputs and outputs you need (methods/parameters/return values) and use it as a wrapper for the SagePay vendor of your choice. This will help keep your controller actions skinny. You can refactor later to your taste once you get things working.

Resources