| title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned | license |
|---|---|---|---|---|---|---|---|---|
Img Classfication |
👀 |
blue |
purple |
gradio |
4.16.0 |
app.py |
false |
mit |
The live demo is here
In this tutorial, we will explore how to create a simple and interactive Object Recognition application using the Gradio library, we will use the Microsoft BEIT model from Hugging Face. Gradio is a Python library that allows you to rapidly create UIs for machine learning models, making it easy to demonstrate and interact with your models.
Before we begin, make sure you have the following installed and set up:
- Hugging Face Account:
- Ensure you have a Hugging Face account. If not, you can create one here.
- Gradio and Transformers:
-
Install the necessary libraries by running the following commands in your terminal:
pip install gradio transformers
-
Start by importing the required libraries in your Python script.
import gradio as gr
from transformers import pipelineLoad the Microsoft BEIT model using the Hugging Face Transformers library.
# Load the BEIT model for image classification
pipe = pipeline(task="image-classification",
model="microsoft/beit-base-patch16-384")Use Gradio to create a simple UI for object recognition.
# Create Gradio interface from the pipeline
gr.Interface.from_pipeline(pipe,
title="Image Classification",
description="Object Recognition using Microsoft BEIT",
examples=['egyptian_cat.jpg', 'German_shepherd.jpg']
).launch()You can customize the interface by adding more features or modifying the appearance. For example, you can include an article section with the author's information.
# Add article information to the interface
gr.Interface.from_pipeline(pipe,
title="Image Classification",
description="Object Recognition using Microsoft BEIT",
examples=['egyptian_cat.jpg', 'German_shepherd.jpg'],
).launch()Finally, launch the Gradio application and interact with it.
# Run the script in your terminal
python app.py
Visit the provided URL in your browser to use the interactive Object Recognition application.