akhaliq HF staff commited on
Commit
a0276ae
1 Parent(s): 3d96c81

add event description, org card, and tutorial

Browse files
Files changed (1) hide show
  1. README.md +91 -1
README.md CHANGED
@@ -7,4 +7,94 @@ sdk: static
7
  pinned: false
8
  ---
9
 
10
- Edit this `README.md` markdown file to author your organization card 🔥
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+ <div class="grid lg:grid-cols-2 gap-x-4">
11
+ <h2 class="lg:col-span-2">This organization invites participants to showoff conference papers on huggingface as a Gradio Web Demo</h2>
12
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">Join organization by clicking <a href="https://huggingface.co/organizations/ICML2022/share/BpynfJtfsOTktlmXYoKNqqCnyufKLFXuay" style="text-decoration: underline" target="_blank">here</a></h3>
13
+ <h4 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">Hugging Face Gradio ICML 2022 event
14
+ </h4>
15
+ <p class="lg:col-span-2">
16
+ ICML organization is accepting Gradio demo submissions for ICML 2022 papers from anyone for a chance to win prizes from Hugging Face, see prizes section and the leaderboard below. The deadline to submit demos is <b>June 31th, 2022 (AOE Time Zone)</b>. <b>For all partipants, feel free to submit Gradio demos for any ICML paper for a chance to win prizes, you can submit demos for multiple papers</b>. Find tutorial on getting started with Gradio on Hugging Face <a href="https://huggingface.co/blog/gradio-spaces" style="text-decoration: underline" target="_blank">here</a> and to get started with the new Gradio Blocks API <a href="https://gradio.app/introduction_to_blocks/" style="text-decoration: underline" target="_blank">here</a></p>
17
+
18
+ <h4 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold" id="Prizes">Hugging Face Prizes</h4>
19
+ <ul class="lg:col-span-2" style="list-style: circle inside">
20
+ <li class="my-4">Top 5 spaces based on likes<ul class="lg:col-span-2" style="list-style: circle inside;padding-left: 40px;">
21
+ <li class="my-4">Swag from <a href="https://huggingface.myshopify.com/">Hugging Face merch shop</a>: t-shirt, hoodie, or mug of your choice</li>
22
+ </ul>
23
+ </li>
24
+ </ul>
25
+
26
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">LeaderBoard for Most Popular ICML Spaces</h3>
27
+ <p class="lg:col-span-2">See the <a href="https://huggingface.co/spaces/CVPR/Leaderboard" target="_blank" style="text-decoration:underline; font-weight:bold">ICML Leaderboard</a></p>
28
+ <img class="lg:col-span-2" src="https://i.imgur.com/1IiikXn.png" alt="Gradio Banner" style="margin:10px">
29
+ <h4 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">Hugging Face Spaces & Gradio for Showcasing your ICML ‘22 Demo
30
+ </h4>
31
+ <p class="lg:col-span-2">
32
+ 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 <a href="https://gradio.app/introduction_to_blocks/" style="text-decoration: underline" target="_blank">https://gradio.app/introduction_to_blocks/</a>, for a more flexible way to build Gradio Demos
33
+ </p>
34
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">🚀 Create a Gradio Demo from your Model
35
+ </h3>
36
+ <p class="lg:col-span-2">
37
+ 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 <a href="https://colab.research.google.com/drive/1S6seNoJuU7_-hBX5KbXQV4Fb_bbqdPBk?usp=sharing" style="text-decoration: underline" target="_blank">colab notebook</a>.
38
+ </p><br />
39
+
40
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">1. Install the gradio library
41
+ </h3>
42
+ <p class="lg:col-span-2">
43
+ All you need to do is to run this in the terminal: <code>pip install gradio</code>
44
+ </p>
45
+ <br />
46
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">2. Define a function in your Python code that performs inference with your model on a data point and returns the prediction
47
+ </h3>
48
+ <p class="lg:col-span-2">
49
+ 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):
50
+ <pre>
51
+ <code>def predict(inp):
52
+
53
+ inp = Image.fromarray(inp.astype('uint8'), 'RGB')
54
+
55
+ inp = transforms.ToTensor()(inp).unsqueeze(0)
56
+
57
+ with torch.no_grad():
58
+
59
+ prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
60
+
61
+ return {labels[i]: float(prediction[i]) for i in range(1000)}
62
+ </code>
63
+ </pre>
64
+ </p>
65
+
66
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">3. Then create a Gradio Interface using the function and the appropriate input and output types
67
+ </h3>
68
+ <p class="lg:col-span-2">
69
+ For the image classification model from Step 2, it would like like this:
70
+ </p>
71
+ <pre>
72
+ <code>
73
+ inputs = gr.inputs.Image()
74
+
75
+ outputs = gr.outputs.Label(num_top_classes=3)
76
+
77
+ io = gr.Interface(fn=predict, inputs=inputs, outputs=outputs)
78
+ </code>
79
+ </pre>
80
+ <p class="lg:col-span-2">
81
+ If you need help creating a Gradio Interface for your model, check out the Gradio Getting Started guide.
82
+ </p>
83
+
84
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">4. Then launch() you Interface to confirm that it runs correctly locally (or wherever you are running Python)
85
+ </h3>
86
+ <pre>
87
+ <code>
88
+ io.launch()
89
+ </code>
90
+ </pre>
91
+ <p class="lg:col-span-2">
92
+ You should see a web interface like the following where you can drag and drop your data points and see the predictions:
93
+ </p>
94
+ <img class="lg:col-span-2" src="https://i.imgur.com/1hsIgJJ.png" alt="Gradio Interface" style="margin:10px">
95
+ </div>
96
+
97
+
98
+
99
+
100
+