README / README.md
akhaliq's picture
akhaliq HF staff
make announcement
bd73e5e
metadata
title: README
emoji: 
colorFrom: pink
colorTo: green
sdk: static
pinned: false

Announcement: deadline to submit demos was extended to July 24th!

EuroPython 2022

EuroPython Dublin, You're invited!

Welcome to the 21st EuroPython. We're the oldest and longest running volunteer-led Python programming conference on the planet! Join us in July in the beautiful and vibrant city of Dublin. We'll be together, face to face and online, to celebrate our shared passion for Python and its community!

Hugging Face Gradio Hackathon 🤗

Come Join us from July 13th to 24th for a Hackathon in person and online using Gradio and Hugging Face to build and host Machine Learning demos. Find tutorial on getting started with Gradio on Hugging Face here and to get started with the new Gradio Blocks API here. Once the gradio demo is setup, see how to add it to Hugging Face Spaces here. Come see the talk on How to craft awesome Machine Learning demos with Python in Liffey Hall 2 on 13 July 2022 at 14:00 by Omar Sanseviero

Sprint July 16 and 17

  • Number of people: 3 maintainers + anyone willing to join
  • Build Machine Learning demos. You can also join if you don't know much about ML!
  • Liffey Hall 2
  • Python Level: any

Join organization by clicking here

Europython Banner

Potential ideas for creating spaces:

Hugging Face Prizes

LeaderBoard for Most Popular EuroPython Spaces

See the EuroPython Leaderboard

Hugging Face Spaces & Gradio for Showcasing your EuroPython ‘22 Demo

In this tutorial, we will demonstrate how to showcase your demo with an easy to use web interface using the Gradio Python library and host it on Hugging Face Spaces so that conference attendees can easily find and try out your demos. Also, see https://gradio.app/introduction_to_blocks/, for a more flexible way to build Gradio Demos

🚀 Create a Gradio Demo from your Model

The first step is to create a web demo from your model. As an example, we will be creating a demo from an image classification model (called model) which we will be uploading to Spaces. The full code for steps 1-4 can be found in this colab notebook.


1. Install the gradio library

All you need to do is to run this in the terminal: pip install gradio


2. Define a function in your Python code that performs inference with your model on a data point and returns the prediction

Here’s we define our image classification model prediction function in PyTorch (any framework, like TensorFlow, scikit-learn, JAX, or a plain Python will work as well):


def predict(inp):

    inp = Image.fromarray(inp.astype('uint8'), 'RGB')
  
    inp = transforms.ToTensor()(inp).unsqueeze(0)
  
    with torch.no_grad():

      prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)

    return {labels[i]: float(prediction[i]) for i in range(1000)}

3. Then create a Gradio Interface using the function and the appropriate input and output types

For the image classification model from Step 2, it would like like this:


inputs = gr.inputs.Image()

outputs = gr.outputs.Label(num_top_classes=3)

io = gr.Interface(fn=predict, inputs=inputs, outputs=outputs)

If you need help creating a Gradio Interface for your model, check out the Gradio Getting Started guide.

4. Then launch() you Interface to confirm that it runs correctly locally (or wherever you are running Python)


io.launch() 

You should see a web interface like the following where you can drag and drop your data points and see the predictions:

Gradio Interface