✦ New Age Learning 🔍
Home › Library › AI for New Learner- Senior 2 › Chapter 8: Deploy Your AI — Get a Public URL

📖 Chapter 8 of 13 · AI for New Learner- Senior 2 · Class 10

Chapter 8: Deploy Your AI — Get a Public URL

In this chapter

  • Avani from Bengaluru ships her first AI to 1,000 users.
  • Streamlit — turn any Python ML script into a web app.
  • Hugging Face Spaces — free hosting your friends can visit.
  • Save and load models with pickle and joblib.
  • Get your own yourname.streamlit.app or HF Spaces URL.
  • Put your live URL on your CV. Today.

The Big Idea

Until now, your AI lived only on your laptop. That ends today. By the end of this chapter, you will have a deployed AI web app at a public URL — yourname.streamlit.app — that anyone with internet can use. Put it on your CV, your school portfolio, your Instagram bio. THAT is what real engineers do. THAT is what colleges and companies notice. Welcome to the world.

Did you know?

Hugging Face is the GitHub of AI. Over 30 lakh models are hosted there, including all major Indian LLMs (Sarvam, Krutrim, Indic models from IIT-M). Deploying your model on HF Spaces takes 5 minutes — and is free forever for small projects.

Builder Profile: Avani

Bengaluru, KA · age 15

Avani deploys her LPG-price predictor to a public Streamlit URL and reaches 1,000 users in a week.

Avani lives in Koramangala, Bengaluru. Her father is an auto driver. Her mother runs a tiffin service from home. The cooking gas cylinder cost — a fight every month — gave her an idea.

She built an AI that predicts LPG cylinder price changes in different states. She trained it on 3 years of public data. She deployed it on Streamlit Cloud with two commands. The URL: avani-lpg-predictor.streamlit.app — free forever.

Her aunt shared it on a WhatsApp group. By the end of week 1, 1,000 people had used it. An auto-rickshaw union in Mysuru reached out. A Hindi news channel did a story. A Bengaluru AI startup invited her for a summer internship — paid Rs 25,000/month. She is 15. She shipped. That is the entire difference.

Streamlit — Python to web app

Streamlit is a free Python library that turns ML scripts into interactive web apps. You write Python; Streamlit handles the buttons, sliders, charts and file uploads. The same code works on your laptop and on a public URL. It’s used by Google, Meta, ISRO, and every Indian AI student today — no HTML, no JavaScript, just Python.

Four steps take your model from laptop to the world: save it, wrap it in a Streamlit app, push to GitHub, and deploy.

💻 CODE LAB app.py — A Working ML Web App

import streamlit as st
import pandas as pd
import joblib

# Load your trained model (saved earlier with joblib.dump)
model = joblib.load('lpg_price_model.pkl')

st.title('LPG Price Predictor - India')
st.markdown('Predict next-month cylinder price for your state')

state = st.selectbox('Your state',
    ['Delhi', 'Maharashtra', 'Karnataka', 'Bihar', 'Tamil Nadu'])
current_price = st.slider('Current price (Rs)', 800, 1500)

if st.button('Predict'):
    pred = model.predict([[current_price, hash(state) % 100]])[0]
    st.success('Next month: Rs ' + str(round(pred)))
    st.balloons()

🚀 DEPLOY BOX Streamlit Cloud Deployment — 6 commands

# 1. Install Streamlit on your laptop
pip install streamlit pandas scikit-learn joblib

# 2. Save your trained model
python train.py        # creates lpg_price_model.pkl

# 3. Test app.py locally
streamlit run app.py   # opens at localhost:8501

# 4. Push to GitHub (create a repo first)
git init && git add . && git commit -m 'first AI app'
git push origin main

# 5. Go to streamlit.io/cloud, sign in with GitHub
# 6. Click 'New App', pick your repo, click 'Deploy'

# Done. Your URL: yourname-lpg-predictor.streamlit.app
# Free forever. Auto-redeploys on every git push.

⚙ TRY IT TODAY

Deploy ANY model from this book. Get your live URL. Add it to your bio. Show your parents. This is the single most important thing you will do in this entire series.

Hugging Face Spaces — the pro path

Streamlit Cloud is easiest for small ML apps — its free tier supports 1 GB RAM, fine for sklearn models. Hugging Face Spaces is more powerful, supports GPU (free up to 16 GB RAM), and is better for deep learning, neural networks and transformers. Every serious Indian AI shipped publicly today is on HF Spaces. Either works for your first app — start with Streamlit, and upgrade to HF when you build a neural net.

🚀 DEPLOY BOX HF Spaces Deployment

# 1. Make an account at huggingface.co
# 2. Click 'New Space', pick a name + Streamlit SDK

# 3. Clone the space to your laptop
git clone https://huggingface.co/spaces/USERNAME/SPACE
cd SPACE

# 4. Copy your app.py and model.pkl into this folder
cp ~/Desktop/app.py .
cp ~/Desktop/lpg_price_model.pkl .

# 5. Add a requirements.txt
# (list: streamlit, scikit-learn, joblib, pandas)

# 6. Push
git add . && git commit -m 'deploy' && git push

# Your URL: huggingface.co/spaces/USERNAME/SPACE

Solved illustrations

1. Why ship to a public URL?

Show answer

Answer: Because (a) it forces you to handle real-world inputs, (b) you get feedback from users, (c) colleges and companies can SEE your work, not just hear about it.

2. Streamlit or HF Spaces — which?

Show answer

Answer: Streamlit: sklearn-style ML, simple UI, easier to start. HF Spaces: deep learning, neural networks, transformers, GPU support. Pick Streamlit for your first app.

3. What is joblib for?

Show answer

Answer: Saves a trained sklearn model to disk so you can load it later — without retraining. Two lines: joblib.dump(model, 'file.pkl') and joblib.load('file.pkl').

4. Will my deployed app cost money?

Show answer

Answer: Both Streamlit Cloud (community tier) and HF Spaces (basic tier) are FREE for small ML apps. Tens of thousands of Indian students use them daily.

5. What is a requirements.txt and why does HF Spaces need it?

Show answer

Answer: It lists the Python libraries your app needs (streamlit, scikit-learn, joblib, pandas). The hosting server reads it and installs those libraries before running your app, so it works the same online as on your laptop.

Questions — Chapter 8

  1. List the 6 Streamlit deployment commands in order.
  2. What is in a requirements.txt and why does HF Spaces need it?
  3. What is the difference between localhost:8501 and your public URL?
  4. Sketch the screen of an AI app you would build.
  5. Why does shipping to a URL make you an engineer, not just a student?

The Final Ship-It Challenge

Ship one AI app to Streamlit or HF Spaces by next week. Email the URL to schools@newagelearning.in.

Check your understanding — Chapter 8

Tap an answer to check it instantly. These are for practice — nothing is saved or sent.

Q1. Why ship your AI to a public URL?

  1. To hide it
  2. It forces you to handle real inputs, you get user feedback, and colleges/companies can SEE your work
  3. URLs cost nothing so why not
Show answer

B. It forces you to handle real inputs, you get user feedback, and colleges/companies can SEE your work

Q2. What is Streamlit?

  1. A video game
  2. A free Python library that turns ML scripts into interactive web apps — no HTML or JavaScript needed
  3. A type of database
Show answer

B. A free Python library that turns ML scripts into interactive web apps — no HTML or JavaScript needed

Q3. What is joblib used for?

  1. Finding a job
  2. Saving a trained sklearn model to disk (joblib.dump) so you can load it later (joblib.load) without retraining
  3. Editing images
Show answer

B. Saving a trained sklearn model to disk (joblib.dump) so you can load it later (joblib.load) without retraining

Q4. Streamlit Cloud or Hugging Face Spaces — which for your first app?

  1. Neither is free
  2. Start with Streamlit (easiest for sklearn apps); move to HF Spaces when you build neural nets needing GPU
  3. Only HF works in India
Show answer

B. Start with Streamlit (easiest for sklearn apps); move to HF Spaces when you build neural nets needing GPU

All chapters in AI for New Learner- Senior 2

  1. Chapter 1: Where You Are Now — The ML Lifecycle
  2. Chapter 2: From Idea to Dataset
  3. Chapter 3: Linear Models — The Workhorses
  4. Chapter 4: Decision Trees & Random Forests
  5. Chapter 5: Neural Networks Demystified
  6. Chapter 6: Evaluation — Does It Actually Work?
  7. Chapter 7: Indian Datasets & Real Problems
  8. Chapter 8: Deploy Your AI — Get a Public URL
  9. Capstone Build-It Projects
  10. Final Book Exam
  11. AI / ML / Python Glossary
  12. Career & College Pathways
  13. Series Completion Diploma

Practise for Class 10