Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
Alright, so I am pretty new to Machine/Deep Learning world and getting my hands dirty on implementing algorithms but there are few gaps which I have and want to understand how the industry is doing this.
I am an experienced developer with an experience of five and a half years of application (Web and Mobile) development with complex use cases. I have detailed knowledge on how to take an application from development to production starting right from scratch.
While going through the tutorials and all of the documentation available online explaining how to develop the model locally which basically looks like a python script. This script takes some data in either the structured or unstructured way, preprocess the data and the train the model on the received data. All this is fine as there are a lot of documents, tutorials available online for this but no one explains how to take it to production and how to maintain it on the production.
I am yet to identify, how to push the model to production, also when the model is deployed on the production, from which data we should train the model on the server. Should it be the same data which we used locally on the machine or some other data? Also, when we make any changes to the model and redeploy it on the production, do we have to train the model again (as the model seems to be stateless and must storing all of the training results and finding on the memory). If it is true, then redeploying the model will bring downtime to the application during the time model is being trained on the server.
I bet industry must be handling all of this in some or the other way. I want to understand the whole process and if I can have references for the same it would be really great.
I am using Tensorlfow, Scikitlearn and other popular libraries for development.
this is just my take, and it may not be standard.
A model is just a model, you can save it to a file, it's just a file, you can make copies of it, there's nothing ezoteric about it.
One way of deploying is by exposing the .predict() method via some form of API. You can do this with your favorite web framework but since you're using tensorflow it's probably easier with flask/django.
Another thing is, in the event where you're not actually messing with the internals of layers is to just use keras, which is much more straightforward to use for the layman than tensorflow and it sits on top of tensorflow so you're using the same tech.
So how to handle retraining? Well ML is compute intensive only when training so you do that separately, take your trained model and plug it back into your API. Ideally this can be done without actually interrupting production, it's just a file that can be overwritten at the end of the day. There are subtleties of course but it should be pretty close to seamless.
As for continuing training after the fact, i would start with this answer.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I've been trying to look for models that I can use/train as a license plate detector and recognizer. Thing is every time I come across a GitHub repo, they offer off the shelf instructions on how to install dependencies, ready up the model, train and inference.
What confuses me though, is sometimes they link to their website in order to get some API key to go with the code in order to continue training the model and i'm not sure whether the billing aspect of their website often refers to something that hinders me using their GitHub code or refers to something completely irrelevant like billing people to use the GUI (i.e. their website) to train a model instead of flat out doing it yourself from a CLI using their code.
Can someone shed some light on how this generally works?
TLDR: I'm looking, on GitHub, to use/train a model for an ALPR task but most link to their website as part of the instructions on how to continue with their code. How do I know when their websites, that include billings, actually hinder me from using their code on GitHub? (i.e. I don't want to pay for anything. I'd rather train and inference it myself)
Example repo: https://github.com/NanoNets/nanonets-ocr-sample-python
Website they link: http://app.nanonets.com/#/keys
There are github repos of companies, they basically show a demo with their API's and there developers who upload it as a project or whatever. The Company you gave as an example shows a demo of their API's and asks you to buy a key and without that key you won't be able to access their API's I.e they are like a key to your house.
What you have to do is make an API and host it. Here you want to do a license plate detector and recognize the character right? So what suggestion I have for you is:
Make a haar-cascade classifier for detecting the number plate
Train a mnist model in scikit or whatever library you prefer.
Make a flask application of the same or any other web framework app
Host it Heroku
Heroku is a like a computer in cloud you can deploy several application and deploy it.
6.but everything is not free there for example if you want to name your website car-detector, you won't be able to do in free tier instead your url will look like car-detector.herokuapp.com and if you want a custom domain you have to pay for it and also, if you want to increase the performance of the app you have to pay for it
Here is an flask opencv python app for you to start with
https://github.com/dev-Roshan-lab/flask-opencv-app
Regards,
Roshan
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a project for University where we are developing a toy healthcare app and I am the backend developer. This app interacts with users, collecting their data. This data is used to make predictions for the user (data science) and can also be sent to doctors. Doctors can also update the data and send it back to the app.
What I do know:
The backend will be in Python, since that's the language of Data Science.
Probably will use Flask for ease of use
needs a database to store the data - probably start with SQLite also for quick ease of use
What I don't know:
since we are dealing with health data, I know that there are standards when it comes to transferring such data, such as using FHIR. But I have no idea where FHIR fits in in the app. I saw that Smart-on-FHIR has a fhirclient library with an example in Flask - is that the way to go?
I assume I need a FHIR server but how do I use one? I saw many available for testing, but how can I use those if the data needs to be private?
Basically, although I know which technologies to use, I don't know how to actually fit the pieces together. This question is asking for ideas on how to piece this project together. I need some clarity to get started and get things off the ground. I have a Flask server - how do I implement this FHIR in it so that I store the data properly, get the data for predictions and also send the data back and forth between the app and the doctor?
I appreciate any help!
FHIR is principally standard for sharing information between software systems - be that applications within a hospital, between EMRs and community pharmacies, clinical systems and research systems, etc. If your system isn't actually sharing data with other applications, there's no real need to use FHIR at all.
You could choose to use FHIR anyhow - you could download one of the FHIR open source servers and use that as your persistence layer. (You'd have your own instance running on your own hardware/cloud server, so your data would be your own.) The rationale for doing that is that it'll be good at storing healthcare data and will have most of the features you need (though it'll likely have a whole lot of features you don't). Also, if one of the objectives of your project is learning, then understanding how FHIR represents data will be useful as you move beyond a 'toy' application and start working with real systems that invariably need to share data.
SMART on FHIR is a mechanism to let you embed applications inside of electronic health record systems that have access to the EHR's data. It can also be used to create web applications that have access to EHR data. The key thing that SMART provides is an ability for a user to control what data the app has access to. (Just like you can control whether an app on your phone can access your address book or microphone, SMART lets you control whether a healthcare app can access your allergies or medications.) It's not obvious from your project description that there'd necessarily be a need for that functionality.
In short, you probably don't need FHIR, but you may find some of the open source tools developed by the FHIR community useful. Good luck with your project.
I apologize in advance if anything about the structure of my question or the way I’m asking it isn’t exactly correct; this is my first time asking a question on here.
The Problem
I’ve built a GUI application for my research position that interfaces with a radar sensor’s API in order to perform real-time imaging in a variety of formats (this uses C++/Qt). My next step will be architecting and implementing a CNN that will essentially take in image data retrieved by the sensor and perform binary classification on it. For the past week or so, I’ve had an absolutely horrible time attempting to include any kind of mainstream deep learning framework in my pre-existing app.
What I’ve Tried
TensorFlow
My first thought was to employ TensorFlow (due to its popularity) to construct my network in Python and then load the model into my C++ app. Unfortunately, I’ve been completely unable to include TensorFlow in my app properly due to a lack of any kind of clear documentation or instruction on how to do so.
PyTorch
After beating my head against a wall for a few days with TensorFlow, I figured I’d try a similar approach with PyTorch because I heard plenty of people commending it for being more user-friendly and intuitive. Once again, trying to include the PyTorch C++ API in my app has been a total nightmare. All I can find in the docs are a couple tutorials in which CMake is used to generate a new project, but for obvious reasons, this wouldn’t work for my use case.
I feel like I’m chasing my tail at this point; my next thought is to try again with another kind of deep learning framework, but I feel like I’ll fall right back into this same issue of being unable to include the library in my pre-existing app. Any recommendations/guidance would be greatly appreciated!
I have an interesting, non-novel but seemingly generally unsolved, at least in sources I could find online, problem. The issue is basically this:
I want to persist the states of my RNN in between calls/invokations to it via the TF Serving API.
I have found quite a few people online talking about this problem, such as in the following links:
https://github.com/tensorflow/serving/issues/724
https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/00tipdqxRZk
Tensorflow Serving - Stateful LSTM
Unfortunetly, there seems to be some discussion of the problem and discussion of a built in fix being added to TF but not being there yet, but no actual guides/examples for how to work around this problem.
The closest I have been able to find a guide for how to do this was the following in the groups.google link:
"As background for future readers, there are two broad cases to consider. The first is where you want to run an entire sequence computation, with multiple steps, each with state to preserve for the next step. This case is addressed with dynamic unrolling."
I am not really sure how to go about implementing this at all though. I dont really want to share my code here just because it is really quite long for a SO post and don't expect anyone to read through it all and tell me what to do.
Just any general tips would be awesome.
I have two files right now that I am using to deploy and use my RNN in the serving api. They are called rnn_save_model.py and rnn_client.py. rnn_save_model just creates the actual model in code and then uses SavedModelBuilder to save it to file. rnn_client then passes in some parameters to the model when I have it loaded via the following command:
tensorflow_model_server --port=9000 --model_name=rnn --model_base_path=/tmp/rnn_model/
I am just not even sure where to add code to get the model to load a state stored to file or something as the model itself is "created" once in rnn_save_model and I do not see how to clearly pass in states via the rnn_client file that are then added to the graph as the file in its current state is just using a model loaded in memory and interfacing with it VS actually editing the model like would be needed to load previous state from file or something.
I really appreciate any help!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have observed that staticians and machine learning scientist generally doesnt follow OOPS for ML/data science projects when using Python (or other languages).
Mostly it should be due to lack of understanding of best software engineering practises in oops while developing ML code for production. Because they mostly come from math & statistics education background than computer science.
Days when ML scientist develop ad hoc protype code and another software team make it production ready are over in the industry.
Questions
How do we structure code using OOP for ML project?
Should every major task (from picture above) like data cleaning, feature transformation, grid search, model validation etc. be a individual class? What are the recommended code design practises for ML?
Any good github links with well strcutured code for reference (may be a well written kaggle solution)
Should every class like data cleaning have fit(), transform(), fit_transform() function for every process like remove_missing(), outlier_removal()? When this is done why is scikit-learn BaseEstimator be usually inherited?
What should be the structure of typical config file for ML projects in production?
You are right about one thing being special about ML: data scientists are generally clever people, so they have no problem in presenting their ideas in code. The problem is that they tend to create fire&forget code, because they lack software development craftsmanship - but ideally this shouldn't be the case.
When writing code it shouldn't make any difference what the code is for1. ML is just another domain like anything else, and should follow clean code principles.
The most important aspect always should be SOLID. Many important aspects directly follow: maintainability, readability, flexibility, testability, reliability etc. What you can add to this mix of features is risk of change. It doesn't matter whether a piece of code is pure ML, or banking business logic, or audiological algorithm for a hearing instrument. All the same - the implementation will be read by other developers, will contain bugs to fix, will be tested (hopefully) and possibly refactored and extended.
Let me try to explain this in more detail while addressing some of your questions:
1,2) You shouldn't think that OOP is the goal in itself. If there is a concept that can be modeled as a class and this will make its usage easy for other developers, it will be readable, easy to extend, easy to test, easy to avoid bugs then of course - make it a class. But unless it's needed, you shouldn't follow the BDUF antipattern. Start with free functions and evolve into a better interface if needed.
4) Such complex inheritance hierarchies are typically created to allow implementation to be extensible (see "O" from SOLID). In this case, library users can inherit BaseEstimator and it's easy to see what methods can they override and how this will fit into scikit's existing structure.
5) Almost the same principles as for code, but with people who will create/edit these config files in mind. What will be the easiest format for them? How to choose parameter names so it will be obvious what do they mean, even for a beginner, who is just starting to use your product?
All these things should be combined with guessing how likely is it that this piece of code will be changed/extended in the future? If you are sure something should be written in stone, don't worry about all aspects too much (e.g. focus only on readability), and direct your efforts to more critical parts of the implementation.
To sum up: think about people who will interact with what you create in the future. In case of products/config files/user interfaces it should be always "user first". In case of code, try to put yourself in the shoes of a future developer who will want to fix/extend/understand your code.
1 There are of course some special cases, like code that needs to be formally proven correct or extensively documented because of formal regulations and this main goal imposes some particular constructs/practices.