Hosting a AI model, how ?

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
Let's say I've created a machine learning model. I want users to make predictions online. I could use Wordpress to create a website for users to sign-in ? I don't know how put each individual pieces together for this. I'm thinking:

- I need a cloud website ? like GCP ? Azure ?
- I host the AI model on the cloud ?
- I create a website front-end for use ? I host it on wordpress or ?
- how to link the 2 together ? Using APIs ? How does Python Flask or Django come into the picture ?
- If I use Python Flask or Django or FastAPI, how does it fit in with Wordpress ? What roles do these play ?

* What other options do I have other than like Flask, Wordpress, GCP, etc ? How would you do it ?
* What if I open the AI model to a mobile app ? How would the above process look like ?

Thanks for any inputs to help me conceptualise this better. 🙏
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Let's say I've created a machine learning model. I want users to make predictions online. I could use Wordpress to create a website for users to sign-in ? I don't know how put each individual pieces together for this. I'm thinking:

- I need a cloud website ? like GCP ? Azure ?
- I host the AI model on the cloud ?
- I create a website front-end for use ? I host it on wordpress or ?
- how to link the 2 together ? Using APIs ? How does Python Flask or Django come into the picture ?
- If I use Python Flask or Django or FastAPI, how does it fit in with Wordpress ? What roles do these play ?

* What other options do I have other than like Flask, Wordpress, GCP, etc ? How would you do it ?
* What if I open the AI model to a mobile app ? How would the above process look like ?

Thanks for any inputs to help me conceptualise this better. 🙏
Not expert in this area, but maybe this can help you, since there isn't much response to what you posted so far.
https://towardsdatascience.com/10-w...ve-ai-models-to-make-predictions-336527ef00b2
In any case, if what you are providing is a web service for your audiences, you might want to deploy a SaaS/BaaS. Your prediction model doesn't need to be exposed at all. What you should be providing is a solution to the problem that is solved assisted by the AI model.

Using AWS Rekognition(https://aws.amazon.com/rekognition/) as an example. Surely the image recognition techniques involves complex ML, but AWS Rekognition doesn't require the clients to know ML. It is just a web service provided and can be easily used by anyone. In fact, it is so simple where training is already done and no training is required (not customisable). The more full fledge ML SaaS from AWS will be Sagemaker (https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html), but that is a totally different ballgame where the target is veteran ML end-users.

Where you are hosting it matters in how your end-users are going to access the service, the scale of the service, etc. From your end-user standpoint, they don't need to know how to it works, or if they are informed, it's merely informative or better understanding to use it properly. It's just a set of web services exposed to your end-users.

:)
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
Not expert in this area, but maybe this can help you, since there isn't much response to what you posted so far.
https://towardsdatascience.com/10-w...ve-ai-models-to-make-predictions-336527ef00b2
In any case, if what you are providing is a web service for your audiences, you might want to deploy a SaaS/BaaS. Your prediction model doesn't need to be exposed at all. What you should be providing is a solution to the problem that is solved assisted by the AI model.

Using AWS Rekognition(https://aws.amazon.com/rekognition/) as an example. Surely the image recognition techniques involves complex ML, but AWS Rekognition doesn't require the clients to know ML. It is just a web service provided and can be easily used by anyone. In fact, it is so simple where training is already done and no training is required (not customisable). The more full fledge ML SaaS from AWS will be Sagemaker (https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html), but that is a totally different ballgame where the target is veteran ML end-users.

Where you are hosting it matters in how your end-users are going to access the service, the scale of the service, etc. From your end-user standpoint, they don't need to know how to it works, or if they are informed, it's merely informative or better understanding to use it properly. It's just a set of web services exposed to your end-users.

:)
Thanks David for your reply. I'm not providing a service. I'm trying to put something together for learning purposes. I thought it would be better if I use a full fledge implementation as a target to my learning process. I think this is an architectural design and implementation issue. I think my idea in terms of very high level building blocks are there, just that what are the ways to implement it. My AI model does not predict well is fine.

I can think of this as a full-stack implementation rather than AI, the backend is just a API call to the AI model. But I'm not familiar with the tools to develop and hosting sites to use. I need to do a lot of research just to find out which to use, so I throw a question here to see if I can short cut the process. I'm going online to learn more about FS programming now. I'm giving myself sometimes to put up the whole implementation. It's a big hurdle for me, might be over-ambitious.

For a start, how does python with flask, django position itself with Wordpress... . I think the front-end is where I'm going to start. For this, can I just use WP or just Python/Flask or both ?

And thanks... :)

PS: Thanks for the article. I'll take a read later..
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Thanks David for your reply. I'm not providing a service. I'm trying to put something together for learning purposes. I thought it would be better if I use a full fledge implementation as a target to my learning process. I think this is an architectural design and implementation issue. I think my idea in terms of very high level building blocks are there, just that what are the ways to implement it. My AI model does not predict well is fine.

I can think of this as a full-stack implementation rather than AI, the backend is just a API call to the AI model. But I'm not familiar with the tools to develop and hosting sites to use. I need to do a lot of research just to find out which to use, so I throw a question here to see if I can short cut the process. I'm going online to learn more about FS programming now. I'm giving myself sometimes to put up the whole implementation. It's a big hurdle for me, might be over-ambitious.

For a start, how does python with flask, django position itself with Wordpress... . I think the front-end is where I'm going to start. For this, can I just use WP or just Python/Flask or both ?

And thanks... :)

PS: Thanks for the article. I'll take a read later..
If it's just for internal consumption, you don't even need to try too hard. You can easily host a python http server as such

https://www.codexpedia.com/python/python-web-server-for-get-and-post-requests/
Then you can implement the do_GET or do_POST methods to invoke your AI model which I assume you are coding it in Python. This is the simplest of a web service. Web service doesn't mean it must be exposed to the public. It's integration. Suppose you have your own system, you don't couple your Machine Learning logic deeply with the rest of the system. The ML component is best to be a standalone component that take in the necessary inputs to produce the necessary output. The integration can be a library or a web service or both.

You mentioned Flask, Django are web frameworks. It is trying to achieve web services using a framework approach.

Here is a simple http server downloaded from elsewhere
Python:
#!/usr/bin/env python2
"""
Very simple HTTP server in python.
Usage::
    ./dummy-web-server.py [<port>]
Send a GET request::
    curl http://localhost
Send a HEAD request::
    curl -I http://localhost
Send a POST request::
    curl -d "foo=bar&bin=baz" http://localhost
"""
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer

class S(BaseHTTPRequestHandler):
    def _set_headers(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_GET(self):
        self._set_headers()
        self.wfile.write("<html><body><h1>hi!</h1></body></html>")

    def do_HEAD(self):
        self._set_headers()

    def do_POST(self):
        # Doesn't do anything with posted data
        content_length = int(self.headers['Content-Length']) # <--- Gets the size of data
        post_data = self.rfile.read(content_length) # <--- Gets the data itself
        self._set_headers()
        #self.wfile.write("<html><body><h1>POST!</h1><p><</body></html>")
        self.wfile.write("<html><body><h1>POST!</h1><p><</body></html>")
        print post_data

def run(server_class=HTTPServer, handler_class=S, port=8000):
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    print 'Starting httpd...'
    httpd.serve_forever()

if __name__ == "__main__":
    from sys import argv

    if len(argv) == 2:
        run(port=int(argv[1]))
    else:
        run()

Bash:
$ ./httpserver.py
Starting httpd...
127.0.0.1 - - [14/Mar/2022 17:56:38] "GET / HTTP/1.1" 200 -

$ curl http://localhost:8000
<html><body><h1>hi!</h1></body></html>

If you want to follow ideas found in the article I shared earlier, feel free to do so too.
:)
 
Last edited:

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
David, do you have any suggestions for the tools for front-end, other than raw coding. Thanks !
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top