• bitcoinBitcoin(BTC)$78,174.00-2.25%
  • ethereumEthereum(ETH)$2,241.95-3.20%
  • tetherTether(USDT)$1.00-0.06%
  • binancecoinBNB(BNB)$715.95-4.78%
  • rippleXRP(XRP)$1.25-3.28%
  • usd-coinUSDC(USDC)$1.00-0.03%
  • solanaSolana(SOL)$97.07-2.88%
  • tronTRON(TRX)$0.3462524.69%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.030.00%
  • HyperliquidHyperliquid(HYPE)$92.0516.74%
  • zcashZcash(ZEC)$1,282.033.07%
  • dogecoinDogecoin(DOGE)$0.076154-2.45%
  • moneroMonero(XMR)$604.782.95%
  • USDSUSDS(USDS)$1.00-0.28%
  • whitebitWhiteBIT Coin(WBT)$74.82-2.49%
  • leo-tokenLEO Token(LEO)$9.43-0.30%
  • chainlinkChainlink(LINK)$11.00-3.82%
  • cardanoCardano(ADA)$0.192482-3.07%
  • stellarStellar(XLM)$0.165233-1.86%
  • bitcoin-cashBitcoin Cash(BCH)$284.281.83%
  • nearNEAR Protocol(NEAR)$4.18-5.70%
  • RainRain(RAIN)$0.006602-1.13%
  • daiDai(DAI)$1.000.03%
  • Ethena USDeEthena USDe(USDE)$1.00-0.20%
  • litecoinLitecoin(LTC)$56.16-1.98%
  • uniswapUniswap(UNI)$6.79-3.22%
  • USD1USD1(USD1)$1.00-0.11%
  • CantonCanton(CC)$0.095168-1.25%
  • avalanche-2Avalanche(AVAX)$8.50-1.61%
  • suiSui(SUI)$0.89-2.33%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.18-3.19%
  • tether-goldTether Gold(XAUT)$3,987.03-1.11%
  • hedera-hashgraphHedera(HBAR)$0.070492-4.04%
  • Global DollarGlobal Dollar(USDG)$1.000.03%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.22%
  • BittensorBittensor(TAO)$237.44-4.48%
  • shiba-inuShiba Inu(SHIB)$0.000005-3.82%
  • quant-networkQuant(QNT)$185.81-3.44%
  • Ripple USDRipple USD(RLUSD)$1.00-0.08%
  • crypto-com-chainCronos(CRO)$0.051113-3.39%
  • EthenaEthena(ENA)$0.186671-5.39%
  • okbOKB(OKB)$113.312.63%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.15-0.01%
  • Circle USYCCircle USYC(USYC)$1.140.01%
  • MemeCoreMemeCore(M)$1.02-3.19%
  • BitwayBitway(BTW)$1.50-15.18%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • pepePepe(PEPE)$0.000005-1.37%
  • aaveAave(AAVE)$124.50-4.21%
  • OndoOndo(ONDO)$0.390475-4.23%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

A Coding Guide to Build a Multimodal Image Captioning App Using Salesforce BLIP Model, Streamlit, Ngrok, and Hugging Face

March 14, 2025
in AI & Technology
Reading Time: 4 mins read
A A
A Coding Guide to Build a Multimodal Image Captioning App Using Salesforce BLIP Model, Streamlit, Ngrok, and Hugging Face
ShareShareShareShareShare

In this tutorial, we’ll learn how to build an interactive multimodal image-captioning application using Google’s Colab platform, Salesforce’s powerful BLIP model, and Streamlit for an intuitive web interface. Multimodal models, which combine image and text processing capabilities, have become increasingly important in AI applications, enabling tasks like image captioning, visual question answering, and more. This step-by-step guide ensures a smooth setup, clearly addresses common pitfalls, and demonstrates how to integrate and deploy advanced AI solutions, even without extensive experience.

!pip install transformers torch torchvision streamlit Pillow pyngrok

First we install transformers, torch, torchvision, streamlit, Pillow, pyngrok, all necessary dependencies for building a multimodal image captioning app. It includes Transformers (for BLIP model), Torch & Torchvision (for deep learning and image processing), Streamlit (for creating the UI), Pillow (for handling image files), and pyngrok (for exposing the app online via Ngrok).

YOU MAY ALSO LIKE

Microsoft Offers Buyouts to 60,000 Employees

Meta Looks to Raise $95 Billion From Stock Sale to Fund AI Investments

%%writefile app.py
import torch
from transformers import BlipProcessor, BlipForConditionalGeneration
import streamlit as st
from PIL import Image


device = "cuda" if torch.cuda.is_available() else "cpu"


@st.cache_resource
def load_model():
    processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
    model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to(device)
    return processor, model


processor, model = load_model()


st.title("🖼️ Image Captioning with BLIP")


uploaded_file = st.file_uploader("Upload your image:", type=["jpg", "jpeg", "png"])


if uploaded_file is not None:
    image = Image.open(uploaded_file).convert('RGB')
    st.image(image, caption="Uploaded Image", use_column_width=True)


    if st.button("Generate Caption"):
        inputs = processor(image, return_tensors="pt").to(device)
        outputs = model.generate(**inputs)
        caption = processor.decode(outputs[0], skip_special_tokens=True)
        st.markdown(f"### ✅ **Caption:** {caption}")

Then we create a Streamlit-based multimodal image captioning app using the BLIP model. It first loads the BLIPProcessor and BLIPForConditionalGeneration from Hugging Face, allowing the model to process images and generate captions. The Streamlit UI enables users to upload an image, displays it, and generates a caption upon clicking a button. The use of @st.cache_resource ensures efficient model loading, and CUDA support is utilized if available for faster processing.

from pyngrok import ngrok


NGROK_TOKEN = "use your own NGROK token here"
ngrok.set_auth_token(NGROK_TOKEN)


public_url = ngrok.connect(8501)
print("🌐 Your Streamlit app is available at:", public_url)


# run streamlit app
!streamlit run app.py &>/dev/null &

Finally, we set up a publicly accessible Streamlit app running in Google Colab using ngrok. It does the following:  

  1. Authenticates ngrok using your personal token (`NGROK_TOKEN`) to create a secure tunnel.
  2. Exposes the Streamlit app running on port `8501` to an external URL via `ngrok.connect(8501)`.
  3. Prints the public URL, which can be used to access the app in any browser.
  4. Launches the Streamlit app (`app.py`) in the background.

This method lets you interact remotely with your image captioning app, even though Google Colab does not provide direct web hosting.

In conclusion, we’ve successfully created and deployed a multimodal image captioning app powered by Salesforce’s BLIP and Streamlit, hosted securely via ngrok from a Google Colab environment. This hands-on exercise demonstrated how easily sophisticated machine learning models can be integrated into user-friendly interfaces and provided a foundation for further exploring and customizing multimodal applications.


Here is the Colab Notebook. Also, don’t forget to follow us on Twitter and join our Telegram Channel and LinkedIn Group. Don’t Forget to join our 80k+ ML SubReddit.


Asif Razzaq is the CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is committed to harnessing the potential of Artificial Intelligence for social good. His most recent endeavor is the launch of an Artificial Intelligence Media Platform, Marktechpost, which stands out for its in-depth coverage of machine learning and deep learning news that is both technically sound and easily understandable by a wide audience. The platform boasts of over 2 million monthly views, illustrating its popularity among audiences.

Parlant: Build Reliable AI Customer Facing Agents with LLMs 💬 ✅ (Promoted)

Credit: Source link

ShareTweetSendSharePin

Related Posts

Microsoft Offers Buyouts to 60,000 Employees
AI & Technology

Microsoft Offers Buyouts to 60,000 Employees

October 30, 2026
Meta Looks to Raise  Billion From Stock Sale to Fund AI Investments
AI & Technology

Meta Looks to Raise $95 Billion From Stock Sale to Fund AI Investments

October 30, 2026
Anthropic to Deliver Menlo’s Biggest-Ever Return
AI & Technology

Anthropic to Deliver Menlo’s Biggest-Ever Return

October 30, 2026
Anthropic’s S-1 Reveals Financial War Chest
AI & Technology

Anthropic’s S-1 Reveals Financial War Chest

October 29, 2026
Next Post
Trump Tries Out a Tesla With Elon Musk

Trump Tries Out a Tesla With Elon Musk

Leave a Reply Cancel reply

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

Search

No Result
View All Result
Selma Blair arrested for allegedly assaulting two flight attendants

Selma Blair arrested for allegedly assaulting two flight attendants

October 27, 2026
Paying 275% Interest On A Payday Loan (It’s Growing Every Day)

Paying 275% Interest On A Payday Loan (It’s Growing Every Day)

October 27, 2026
GreensKeeper Value Fund Q3 2026 Letter

GreensKeeper Value Fund Q3 2026 Letter

October 25, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!