akhaliq HF staff commited on
Commit
f982578
1 Parent(s): 9a30751

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -1
README.md CHANGED
@@ -7,4 +7,90 @@ 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
+ <h1 class="lg:col-span-2">This organization invites participants to showoff conference papers on Hugging Face as a Gradio Web Demo (Note: This is not a official NAACL sponsored event)</h1>
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/ECCV2022/share/kZuMIwRJKOTteDgoueNuPAMUGSnfDjWAGq" 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 NAACL 2022 event
14
+ </h4>
15
+ <p class="lg:col-span-2">
16
+ NAACL organization is accepting Gradio demo submissions for NAACL 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>July 31st, 2022 (AOE Time Zone)</b>. <b>For all participants, feel free to submit Gradio demos for any NAACL 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/course/chapter9/1?fw=pt" 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 NAACL 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">NAACL Leaderboard</a></p>
28
+ <h4 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">Hugging Face Spaces & Gradio for Showcasing your NAACL ‘22 Demo
29
+ </h4>
30
+ <p class="lg:col-span-2">
31
+ 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
32
+ </p>
33
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">🚀 Create a Gradio Demo from your Model
34
+ </h3>
35
+ <p class="lg:col-span-2">
36
+ 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>.
37
+ </p><br />
38
+
39
+ <h3 class="my-8 lg:col-span-2" style="font-size:20px; font-weight:bold">1. Install the gradio library
40
+ </h3>
41
+ <p class="lg:col-span-2">
42
+ All you need to do is to run this in the terminal: <code>pip install gradio</code>
43
+ </p>
44
+ <br />
45
+ <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
46
+ </h3>
47
+ <p class="lg:col-span-2">
48
+ 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):
49
+ <pre>
50
+ <code>
51
+ def predict(inp):
52
+ inp = Image.fromarray(inp.astype('uint8'), 'RGB')
53
+
54
+ inp = transforms.ToTensor()(inp).unsqueeze(0)
55
+
56
+ with torch.no_grad():
57
+
58
+ prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
59
+
60
+ return {labels[i]: float(prediction[i]) for i in range(1000)}
61
+ </code>
62
+ </pre>
63
+ </p>
64
+
65
+ <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
66
+ </h3>
67
+ <p class="lg:col-span-2">
68
+ For the image classification model from Step 2, it would like like this:
69
+ </p>
70
+ <pre>
71
+ <code>
72
+ inputs = gr.inputs.Image()
73
+
74
+ outputs = gr.outputs.Label(num_top_classes=3)
75
+
76
+ io = gr.Interface(fn=predict, inputs=inputs, outputs=outputs)
77
+ </code>
78
+ </pre>
79
+ <p class="lg:col-span-2">
80
+ If you need help creating a Gradio Interface for your model, check out the Gradio Getting Started guide.
81
+ </p>
82
+
83
+ <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)
84
+ </h3>
85
+ <pre>
86
+ <code>
87
+ io.launch()
88
+ </code>
89
+ </pre>
90
+ <p class="lg:col-span-2">
91
+ You should see a web interface like the following where you can drag and drop your data points and see the predictions:
92
+ </p>
93
+ <img class="lg:col-span-2" src="https://i.imgur.com/1hsIgJJ.png" alt="Gradio Interface" style="margin:10px">
94
+ </div>
95
+
96
+