forked from gradio-app/gradio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
82 changed files
with
12,627 additions
and
2,611 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import gradio as gr | ||
from difflib import Differ | ||
|
||
import gradio as gr | ||
|
||
|
||
def diff_texts(text1, text2): | ||
d = Differ() | ||
return [ | ||
(token[2:], token[0] if token[0] != " " else None) for token in d.compare(text1, text2) | ||
(token[2:], token[0] if token[0] != " " else None) | ||
for token in d.compare(text1, text2) | ||
] | ||
|
||
|
||
iface = gr.Interface( | ||
diff_texts, | ||
[ | ||
gr.inputs.Textbox( | ||
lines=3, default="The quick brown fox jumped over the lazy dogs."), | ||
gr.inputs.Textbox( | ||
lines=3, default="The fast brown fox jumps over lazy dogs."), | ||
lines=3, default="The quick brown fox jumped over the lazy dogs." | ||
), | ||
gr.inputs.Textbox(lines=3, default="The fast brown fox jumps over lazy dogs."), | ||
], | ||
gr.outputs.HighlightedText()) | ||
gr.outputs.HighlightedText(), | ||
) | ||
if __name__ == "__main__": | ||
iface.launch() | ||
iface.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import gradio as gr | ||
|
||
|
||
def filter_records(records, gender): | ||
return records[records['gender'] == gender] | ||
return records[records["gender"] == gender] | ||
|
||
|
||
iface = gr.Interface(filter_records, | ||
[ | ||
gr.inputs.Dataframe(headers=["name", "age", "gender"], datatype=["str", "number", "str"], row_count=5), | ||
gr.inputs.Dropdown(["M", "F", "O"]) | ||
], | ||
"dataframe", | ||
description="Enter gender as 'M', 'F', or 'O' for other." | ||
iface = gr.Interface( | ||
filter_records, | ||
[ | ||
gr.inputs.Dataframe( | ||
headers=["name", "age", "gender"], | ||
datatype=["str", "number", "str"], | ||
row_count=5, | ||
), | ||
gr.inputs.Dropdown(["M", "F", "O"]), | ||
], | ||
"dataframe", | ||
description="Enter gender as 'M', 'F', or 'O' for other.", | ||
) | ||
|
||
iface.test_launch() | ||
|
||
if __name__ == "__main__": | ||
iface.launch() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
import gradio as gr | ||
import pandas as pd | ||
import random | ||
|
||
import pandas as pd | ||
|
||
import gradio as gr | ||
|
||
|
||
def fraud_detector(card_activity, categories, sensitivity): | ||
activity_range = random.randint(0, 100) | ||
drop_columns = [column for column in ["retail", "food", "other"] if column not in categories] | ||
drop_columns = [ | ||
column for column in ["retail", "food", "other"] if column not in categories | ||
] | ||
if len(drop_columns): | ||
card_activity.drop(columns=drop_columns, inplace=True) | ||
return card_activity, card_activity, {"fraud": activity_range / 100., "not fraud": 1 - activity_range / 100.} | ||
return ( | ||
card_activity, | ||
card_activity, | ||
{"fraud": activity_range / 100.0, "not fraud": 1 - activity_range / 100.0}, | ||
) | ||
|
||
|
||
iface = gr.Interface(fraud_detector, | ||
[ | ||
gr.inputs.Timeseries( | ||
x="time", | ||
y=["retail", "food", "other"] | ||
), | ||
gr.inputs.CheckboxGroup(["retail", "food", "other"], default=[ | ||
"retail", "food", "other"]), | ||
gr.inputs.Slider(1, 3) | ||
], | ||
[ | ||
"dataframe", | ||
gr.outputs.Timeseries( | ||
x="time", | ||
y=["retail", "food", "other"] | ||
), | ||
gr.outputs.Label(label="Fraud Level"), | ||
] | ||
) | ||
iface = gr.Interface( | ||
fraud_detector, | ||
[ | ||
gr.inputs.Timeseries(x="time", y=["retail", "food", "other"]), | ||
gr.inputs.CheckboxGroup( | ||
["retail", "food", "other"], default=["retail", "food", "other"] | ||
), | ||
gr.inputs.Slider(1, 3), | ||
], | ||
[ | ||
"dataframe", | ||
gr.outputs.Timeseries(x="time", y=["retail", "food", "other"]), | ||
gr.outputs.Label(label="Fraud Level"), | ||
], | ||
) | ||
if __name__ == "__main__": | ||
iface.launch() |
Oops, something went wrong.