My Brain Cells

Easiest (and best) learning materials for anyone with a curiosity for machine learning and artificial intelligence, Deep learning, Programming, and other fun life hacks.


First thing first, Activate your python environment 

Now, Install fastapi and uvicorn 
         >> pip install fastapi uvicorn 

You should have an ML model file (.pkl, .model, .hd5 etc)

Let us assume that we have a “classifier.pkl” file

Create a file

import uvicorn

from fastapi import FastAPI

from BankNotes import BankNote

import numpy as np

import pickle

import pandas as pd

app = FastAPI()

pickle_in = open(“classifier.pkl”,”rb”)



def index():

    return {‘message’: ‘Hello, World’}


def get_name(name: str):

    return {‘Welcome’: f'{name}’}‘/predict’)

def predict_banknote(data:BankNote):

    data = data.dict()





   # print(classifier.predict([[variance,skewness,curtosis,entropy]]))

    prediction = classifier.predict([[variance,skewness,curtosis,entropy]])


        prediction=”Fake note”


        prediction=”Its a Bank note”

    return {

        ‘prediction’: prediction


#    Will run on

if __name__ == ‘__main__’:, host=’′, port=8000)

Create a file:

from pydantic import BaseModel

# Class which describes Bank Notes measurements

class BankNote(BaseModel):

    variance: float 

    skewness: float 

    curtosis: float 

    entropy: float

Now, In the terminal run the application 

        >>uvicorn main:app –reload

#   This will run on


4 thoughts on “FastApi

  1. Hi There,

    I’m Richard. If you are a student then you must know that at college and university level we have to buy a lot of TextBooks according to the subject of the course which are very expensive. This makes it difficult for students who do not have much money to buy these books. There is also a huge gap between supply and demand of TextBooks. Publishers keep changing editions (without any real changes in the books themselves) and force professors to get the new editions. This results in an additional burden on students.

    So considering all these issues, We have launched our website – We contacted authors and professors directly and received approval and agreement to sell the books digital( ePub/PDF) version directly to university and college students at a very cheap price. You can buy a book from our website at a discount of up to 70% off the price of a book from amazon.

    Our motto is simple: Education should be accessible and affordable for EVERYONE!

    If you are not student please share this website with all the students around you so that they might be benefited.

    Thanks You
    Richard C. Willis
    Marketing Consultant

  2. Did you write the article yourself or you hired someone to do it?
    I was wondering because I am a site owner too and
    struggle with writing new content all the time.
    Someone told me to use AI to do create articles which I am kinda considering because the output
    is almost written by human. Here is the sample content they sent me

    Let me know if you think I should go ahead and use AI.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top