mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-25 12:10:31 +08:00
update demos and readme
This commit is contained in:
parent
2a7d9972c9
commit
5533ecac15
14
README.md
14
README.md
@ -36,7 +36,7 @@ def greet(name):
|
||||
|
||||
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||
|
||||
3. The interface below will appear automatically within the Python notebook, or pop in a browser on [http://localhost:7860](http://localhost:7860/) if running from a script.
|
||||

|
||||
@ -68,7 +68,7 @@ iface = gr.Interface(
|
||||
inputs=gr.inputs.Textbox(lines=2, placeholder="Name Here..."),
|
||||
outputs="text")
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
### Multiple Inputs and Outputs
|
||||
@ -90,7 +90,7 @@ iface = gr.Interface(
|
||||
inputs=["text", "checkbox", gr.inputs.Slider(0, 100)],
|
||||
outputs=["text", "number"])
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
We simply wrap the components in a list. Furthermore, if we wanted to compare multiple functions that have the same input and return types, we can even pass a list of functions for quick comparison.
|
||||
@ -113,7 +113,7 @@ def sepia(img):
|
||||
|
||||
iface = gr.Interface(sepia, gr.inputs.Image(shape=(200, 200)), "image")
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
Additionally, our `Image` input interface comes with an 'edit' button which opens tools for cropping, flipping, rotating, drawing over, and applying filters to images. We've found that manipulating images in this way will often reveal hidden flaws in a model.
|
||||
@ -145,7 +145,7 @@ iface = gr.Interface(calculator,
|
||||
]
|
||||
)
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
### Flagging
|
||||
@ -174,7 +174,7 @@ iface = gr.Interface(
|
||||
outputs="label", interpretation="default")
|
||||
iface.launch()
|
||||
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
Notice the `interpretation` keyword argument. We're going to use Gradio's default interpreter here. After you submit and click Interpret, you'll see the interface automatically highlights the parts of the text that contributed to the final output orange! The parts that conflict with the output are highlight blue.
|
||||
@ -212,7 +212,7 @@ iface = gr.Interface(
|
||||
fn=gender_of_sentence, inputs=gr.inputs.Textbox(default="She went to his house to get her keys."),
|
||||
outputs="label", interpretation=interpret_gender)
|
||||
iface.launch()
|
||||
```
|
||||
````
|
||||

|
||||
|
||||
## Contributing:
|
||||
|
@ -12,7 +12,7 @@ template_dict = {}
|
||||
for code_src in codes:
|
||||
with open(os.path.join("demo", code_src + ".py")) as code_file:
|
||||
python_code = code_file.read().replace('if __name__ == "__main__":\n iface.launch()', "iface.launch()")
|
||||
template_dict["code_" + code_src] = "````python\n" + python_code + "\n```"
|
||||
template_dict["code_" + code_src] = "````python\n" + python_code + "\n````"
|
||||
|
||||
for demo_src in demos:
|
||||
template_dict["demo_" + demo_src] = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user