Skip to content
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
305 commits
Select commit Hold shift + click to select a range
408f743
fixed external tests
abidlabs Mar 18, 2022
6bcbde4
fixing test_inputs.py
abidlabs Mar 19, 2022
77eae45
fixing test inputs
abidlabs Mar 19, 2022
e95a4b3
deleted components
abidlabs Mar 19, 2022
12e7333
only Number and Label outputs are interpretable
abidlabs Mar 19, 2022
db6f845
fixed test data
abidlabs Mar 19, 2022
219adfa
used numbers.Numbers
abidlabs Mar 19, 2022
f2a5ecd
fixed test inputs.py
abidlabs Mar 19, 2022
d25419b
fixed interpretation
abidlabs Mar 19, 2022
e80d203
Merge pull request #765 from gradio-app/Blocks-Components
omerXfaruq Mar 21, 2022
0d2c4b1
Blocks-Components-v2
omerXfaruq Mar 21, 2022
b778aa5
Blocks-Components-v2
omerXfaruq Mar 21, 2022
8c21e12
Blocks-Backend-Events
omerXfaruq Mar 21, 2022
f2f4d0d
cleaned up imports
abidlabs Mar 21, 2022
e9386f5
updated imports to components.py
abidlabs Mar 21, 2022
566c954
stop interface from erroring out
Mar 21, 2022
01cc894
updated to use merged components
abidlabs Mar 21, 2022
63ccf88
added super basic static textbox demo
abidlabs Mar 21, 2022
ef533b2
kinematics block
abidlabs Mar 21, 2022
15c9175
Blocks-Backend-Events
omerXfaruq Mar 22, 2022
860ea5c
Blocks-Backend-Events
omerXfaruq Mar 22, 2022
21b6dcc
Blocks Backend Components
omerXfaruq Mar 22, 2022
d9cd56e
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
24011e4
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
b2a9816
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
5d0d875
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
ba6ec35
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
51c9aa6
revert demos
abidlabs Mar 22, 2022
c462858
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
72244c3
Blocks-Backend-Components-v2
omerXfaruq Mar 22, 2022
e8e8439
Merge pull request #843 from gradio-app/Blocks-Components-v2
abidlabs Mar 22, 2022
95aaf2d
Merge branch 'Blocks-Dev' into Blocks-Backend-Events
abidlabs Mar 22, 2022
1ff6270
Merge pull request #844 from gradio-app/Blocks-Backend-Events
abidlabs Mar 22, 2022
c5fce03
moved commits over
abidlabs Mar 22, 2022
4796e55
Interfaces from Blocks (#849)
aliabid94 Mar 22, 2022
330ba63
Merge branch 'Blocks-Dev' into update-demos
abidlabs Mar 22, 2022
3a5b8a7
readd imports in init
abidlabs Mar 22, 2022
35f661b
live calculator
abidlabs Mar 22, 2022
a8ab1c8
Blocks dev (#853)
aliabid94 Mar 22, 2022
35c26c0
made the non-keyword parameter choices instead of default values for …
abidlabs Mar 22, 2022
52b2901
Merge branch 'Blocks-dev' into update-demos
abidlabs Mar 22, 2022
6003122
Merge branch 'update-demos' of github.com:gradio-app/gradio into upda…
abidlabs Mar 22, 2022
763585c
formatting
abidlabs Mar 22, 2022
503eb7b
revert calculator_live changes
abidlabs Mar 22, 2022
5d6a9d4
calculator live correction
abidlabs Mar 22, 2022
7f2f62c
revert diff text changes
abidlabs Mar 22, 2022
40efaac
fixed kinematics demo; readded button click trigger
abidlabs Mar 22, 2022
398f556
Merge pull request #848 from gradio-app/update-demos
abidlabs Mar 23, 2022
26d2c19
add test infra + add browser tests to CI (#852)
pngwn Mar 23, 2022
bc8d974
rebuilt frontend
abidlabs Mar 23, 2022
60f6f86
context tests pass
abidlabs Mar 23, 2022
5b3bb9e
removed test demos, test encryptor passes
abidlabs Mar 23, 2022
0edf628
test_external passing
abidlabs Mar 23, 2022
8d94713
add test infra
pngwn Mar 22, 2022
b7d2125
improve test setup and utils
pngwn Mar 22, 2022
4f772dc
ensure textbox updates the value
pngwn Mar 23, 2022
8ed9f3b
add tests for textbox
pngwn Mar 23, 2022
2c7e33c
update deps
pngwn Mar 23, 2022
569491f
Merge pull request #859 from gradio-app/854-textbox
abidlabs Mar 23, 2022
bc6f6f8
merged
abidlabs Mar 23, 2022
96259bc
Merge branch 'blocks-dev' into more-demos
abidlabs Mar 23, 2022
88662ce
build frontend
abidlabs Mar 23, 2022
6c01bad
commented out flagging tests as we don't support that yet
abidlabs Mar 23, 2022
6a82b72
test_inputs pass'
abidlabs Mar 23, 2022
41197a6
removed examples test
abidlabs Mar 23, 2022
6b259bd
removed outdated outputs tests
abidlabs Mar 23, 2022
95e861e
test_routes passing
abidlabs Mar 23, 2022
fea2c32
process examples
abidlabs Mar 23, 2022
fa27aa5
fixed outputs tests
abidlabs Mar 23, 2022
63d18ac
formatting
abidlabs Mar 23, 2022
0ef247a
changes
Mar 23, 2022
3eb520b
Merge branch 'blocks-dev' into interface_to_blocks_features
aliabid94 Mar 23, 2022
2df7c60
add test for output to input
pngwn Mar 24, 2022
ceb96ec
remove unused import
pngwn Mar 24, 2022
85dbeff
initialise chatbot with empty array of messages
pngwn Mar 24, 2022
017e62c
remove log
pngwn Mar 24, 2022
3b452ff
set default values as the value for components
pngwn Mar 24, 2022
2f4f16a
backend_default_value_refactoring
omerXfaruq Mar 24, 2022
1d316d3
commented external, removed context
abidlabs Mar 24, 2022
721e2db
removed external tests
abidlabs Mar 24, 2022
81e4a08
removed process examples
abidlabs Mar 24, 2022
946dffc
fixed static checks
abidlabs Mar 24, 2022
f92685b
Merge pull request #861 from gradio-app/more-demos
abidlabs Mar 24, 2022
4e0e789
more changes
Mar 25, 2022
9ca5cf0
Merge branch 'interface_to_blocks_features' of https://github.com/gra…
Mar 25, 2022
49bd10b
changes
Mar 25, 2022
508c28b
Merge branch 'blocks-dev' into 862-chatbot
abidlabs Mar 25, 2022
07c97c1
Merge branch 'blocks-dev' into interface_to_blocks_features
aliabid94 Mar 25, 2022
2260c3f
Merge pull request #867 from gradio-app/862-chatbot
abidlabs Mar 25, 2022
50fd650
Merge branch 'blocks-dev' into 790-in-out
abidlabs Mar 25, 2022
da5463b
changed test coverage threshold temporarily
abidlabs Mar 25, 2022
bb0b965
Merge pull request #866 from gradio-app/790-in-out
abidlabs Mar 25, 2022
840dd78
merged
abidlabs Mar 25, 2022
603d0ab
fixed base64 encoding
abidlabs Mar 25, 2022
1b567e7
changes
Mar 25, 2022
946d473
Merge branch 'interface_to_blocks_features' of https://github.com/gra…
Mar 25, 2022
48c42da
test fix
Mar 25, 2022
d4759cf
fix format
Mar 25, 2022
0f54bac
import sort
Mar 25, 2022
a5e5a13
changes
Mar 25, 2022
7cd76a5
adding docstrings
abidlabs Mar 25, 2022
6a01773
formatting
abidlabs Mar 25, 2022
6eeaccc
flagging tests pass
abidlabs Mar 25, 2022
22f332b
examples tests pass
abidlabs Mar 25, 2022
fd70292
formatting
abidlabs Mar 25, 2022
12db19e
brought back interface examplest test
abidlabs Mar 25, 2022
809755b
fixed process example tests
abidlabs Mar 25, 2022
4bde73e
Merge pull request #864 from gradio-app/interface_to_blocks_features
abidlabs Mar 25, 2022
713cb97
fixed spaces path
abidlabs Mar 25, 2022
ca2d0b7
brought back external and mix tests
abidlabs Mar 25, 2022
a34dd93
Merge pull request #879 from gradio-app/blocks-dev-external
abidlabs Mar 25, 2022
52d4b10
Merge branch 'blocks-dev' into backend_default_values_refactoring
aliabid94 Mar 25, 2022
8bc644e
rename default to default_value
Mar 25, 2022
444e91c
fixed empty default value bug
abidlabs Mar 25, 2022
6ff3ad2
output tests passing
abidlabs Mar 25, 2022
04b6b80
inputs
abidlabs Mar 25, 2022
c7299ed
formatting
abidlabs Mar 25, 2022
55bf180
Merge pull request #871 from gradio-app/backend_default_values_refact…
abidlabs Mar 25, 2022
e6eb78c
Merge branch 'blocks-dev' into default-values
abidlabs Mar 25, 2022
be423b7
Merge pull request #869 from gradio-app/default-values
abidlabs Mar 26, 2022
4a78773
fix buttons (#883)
aliabid94 Mar 26, 2022
d4f310a
built frontend
abidlabs Mar 26, 2022
0b2f0e2
fix markdown default_value
Mar 26, 2022
152ad48
built frontend
abidlabs Mar 26, 2022
1a500bf
pushed beta version to pypi
abidlabs Mar 28, 2022
d074d23
checked 7 more demos
abidlabs Mar 28, 2022
75d9318
added multistep demo
abidlabs Mar 28, 2022
f817f33
4 more demos
abidlabs Mar 28, 2022
3010d55
updated demos
abidlabs Mar 28, 2022
5fa6978
fixed more demos
abidlabs Mar 28, 2022
76d5a52
more demos
abidlabs Mar 28, 2022
3404141
updated demos
abidlabs Mar 28, 2022
745826d
fixed remaining demos
abidlabs Mar 28, 2022
aeec89c
guard render to check for children
pngwn Mar 29, 2022
95deeb8
cleanup default_value
pngwn Mar 29, 2022
a839379
add docstring for test_launch
abidlabs Mar 29, 2022
776249a
fixed demos
abidlabs Mar 29, 2022
94eef9c
fixed demos
abidlabs Mar 29, 2022
f07a458
formatting
abidlabs Mar 29, 2022
d4c91aa
Merge pull request #892 from gradio-app/remaining-demos
abidlabs Mar 29, 2022
dcc9ba8
blocks-tests
omerXfaruq Mar 29, 2022
acda997
blocks-tests
omerXfaruq Mar 29, 2022
c0c46c2
blocks-tests
omerXfaruq Mar 29, 2022
aa01ab8
Merge branch 'blocks-dev' into blocks-tests
abidlabs Mar 29, 2022
2d30bfd
blocks-tests
omerXfaruq Mar 29, 2022
839dcd6
Merge branch 'blocks-tests' of https://github.com/gradio-app/gradio i…
omerXfaruq Mar 29, 2022
2825ee6
resolving relative imports
abidlabs Mar 29, 2022
ac4568d
Merge branch 'blocks-tests' of github.com:gradio-app/gradio into bloc…
abidlabs Mar 29, 2022
2ec8482
fixed config
abidlabs Mar 29, 2022
9d7de51
fixed config
abidlabs Mar 29, 2022
117776e
added init
abidlabs Mar 29, 2022
16ca460
blocks-tests
omerXfaruq Mar 29, 2022
88c79ef
Merge branch 'blocks-tests' of https://github.com/gradio-app/gradio i…
omerXfaruq Mar 29, 2022
e09df09
fixed formatting
abidlabs Mar 29, 2022
b851831
hacky way to get imports to work
abidlabs Mar 29, 2022
8daada1
slightly better
abidlabs Mar 29, 2022
6ace296
Merge pull request #902 from gradio-app/blocks-tests
abidlabs Mar 29, 2022
c1a6974
Merge pull request #901 from gradio-app/interface-fix
abidlabs Mar 29, 2022
4c594e5
blocks-components-tests
omerXfaruq Mar 29, 2022
c343a62
blocks-components-tests
omerXfaruq Mar 29, 2022
28d5f93
blocks-components-tests
omerXfaruq Mar 29, 2022
32f0554
blocks-components-tests
omerXfaruq Mar 29, 2022
d7ca65c
blocks-components-tests
omerXfaruq Mar 30, 2022
f623438
blocks-components-tests
omerXfaruq Mar 30, 2022
070b8a9
blocks-components-tests
omerXfaruq Mar 30, 2022
71e3997
blocks-components-tests
omerXfaruq Mar 30, 2022
cf6f490
blocks-components-tests
omerXfaruq Mar 30, 2022
d39eb47
fix duplicate tabs issue
dawoodkhan82 Mar 30, 2022
d4ccde2
Merge branch 'blocks-dev' into dawood/blocks-fixes
dawoodkhan82 Mar 30, 2022
2c27f7f
fixed test
abidlabs Mar 30, 2022
e95b88a
fixed formatting
abidlabs Mar 30, 2022
3d880c8
Merge pull request #907 from gradio-app/dawood/blocks-fixes
dawoodkhan82 Mar 30, 2022
b912317
fix endpoint url in prod (#911)
pngwn Mar 31, 2022
da4a594
blocks-with-fix
omerXfaruq Apr 1, 2022
e5ea806
Merge pull request #917 from gradio-app/blocks-with-fix
omerXfaruq Apr 1, 2022
3e72cfd
fixed idempotency issue
abidlabs Apr 1, 2022
983535c
removing indented blocks from markdown
abidlabs Apr 2, 2022
04e9ea8
added some typing
abidlabs Apr 4, 2022
d1c2461
formatting
abidlabs Apr 4, 2022
6a376ed
fixed test
abidlabs Apr 4, 2022
f33ece2
reverted some changes temporarily
abidlabs Apr 4, 2022
24e343f
fixed so that multiple interfaces can run in one session
abidlabs Apr 4, 2022
e44edb7
getting blocks inside blocks
abidlabs Apr 4, 2022
5c44ae3
Restore Interpretation, Live, Auth, Queueing (#915)
aliabid94 Apr 4, 2022
b725836
blocks inside blocks!
abidlabs Apr 4, 2022
faa37f3
tabbedinterface
abidlabs Apr 5, 2022
541041e
merged blocks-dev
abidlabs Apr 5, 2022
8d19a96
formatting
abidlabs Apr 5, 2022
9f7a486
blocks-components-test
omerXfaruq Apr 5, 2022
ceee0fc
blocks-components-test
omerXfaruq Apr 5, 2022
9061768
blocks-components-test
omerXfaruq Apr 5, 2022
fee261d
removed TabbedInterface
abidlabs Apr 5, 2022
651205a
Merge pull request #919 from gradio-app/blocks-as-block
abidlabs Apr 5, 2022
f2d71ab
Redesign 1 (#918)
pngwn Apr 5, 2022
2fdf26d
merged blocks-dev
abidlabs Apr 5, 2022
67ced04
fixed error in merge
abidlabs Apr 5, 2022
19cf1e7
fixing tests related to new way of doing interpretation
abidlabs Apr 5, 2022
2958548
fixed interpretation test
abidlabs Apr 5, 2022
826fcee
fixed carousel test
abidlabs Apr 5, 2022
22c4003
blocks-components-test
omerXfaruq Apr 5, 2022
dac4caa
blocks-components-test
omerXfaruq Apr 5, 2022
bca035b
Merge pull request #904 from gradio-app/blocks-components-tests
omerXfaruq Apr 5, 2022
5313a4e
fix unit + browser tests (#926)
pngwn Apr 6, 2022
6274b90
blocks-move-test-data (#927)
omerXfaruq Apr 6, 2022
6e4e877
remove debounce from form inputs (#932)
pngwn Apr 6, 2022
af5b555
reimplement webcam video (#928)
pngwn Apr 6, 2022
d8dd552
blocks-move-test-data
omerXfaruq Apr 6, 2022
5ca96c4
added timeseries output test
abidlabs Apr 7, 2022
e3aeeb5
formatting
abidlabs Apr 7, 2022
4a685a0
Merge pull request #941 from gradio-app/blocks-dev-components-tests
abidlabs Apr 7, 2022
d722de0
replaced ASR model with one that works
abidlabs Apr 7, 2022
0383857
allow audio components to take a string value (#930)
pngwn Apr 7, 2022
61c2e0e
static mode for textbox (#929)
pngwn Apr 7, 2022
48fc3f9
fix file upload text (#931)
pngwn Apr 7, 2022
0237061
add fake_gan demos with smaller pictures
omerXfaruq Apr 8, 2022
3c876c4
add fake_gan demos with smaller pictures
omerXfaruq Apr 8, 2022
dc6175a
tabbed-interface-rewritten (#958)
omerXfaruq Apr 8, 2022
c19042e
replaced local files with urls to images (#965)
abidlabs Apr 8, 2022
ea3a929
Blocks analytics (#947)
abidlabs Apr 8, 2022
8eae59f
Blocks page load (#963)
omerXfaruq Apr 8, 2022
4b10085
add frontend for page load events (#967)
pngwn Apr 8, 2022
f57fa0e
fix i18n and some tweaks (#966)
pngwn Apr 8, 2022
7576f06
Cleaning up `Launchable()` (#968)
abidlabs Apr 11, 2022
a150985
Merge in Examples and cache_examples fixes
omerXfaruq Apr 11, 2022
65f5733
New Blocks Demo: neural instrument cloning (#975)
abidlabs Apr 12, 2022
ceea8ce
tweaked demo
abidlabs Apr 12, 2022
1d3cb51
State and variables (#977)
aliabid94 Apr 13, 2022
6e1ccec
update-components (#986)
omerXfaruq Apr 13, 2022
9cb40dc
ensure dataframe updates as expected (#981)
pngwn Apr 13, 2022
86ebd8a
test-guideline (#990)
omerXfaruq Apr 13, 2022
eebe7b5
Issue #785: add footer (#972)
dawoodkhan82 Apr 13, 2022
5af5b25
indentation fix (#993)
abidlabs Apr 13, 2022
e0a64e5
added interactive parameter to components (#992)
abidlabs Apr 14, 2022
ad75b06
custom-components (#985)
omerXfaruq Apr 14, 2022
8464aa7
Refactor component shortcuts (#995)
omerXfaruq Apr 14, 2022
0e1dce6
- typo
omerXfaruq Apr 14, 2022
f511174
import hotfix (#1008)
omerXfaruq Apr 15, 2022
1c2f430
Progress indicator bar (#997)
aliabid94 Apr 15, 2022
2f771e2
update codecov version
abidlabs Apr 18, 2022
499f106
Model3D + Plot Components (#1010)
dawoodkhan82 Apr 18, 2022
4f1947d
merge in master
Apr 19, 2022
c15885f
merge master
Apr 19, 2022
0312c40
format
Apr 19, 2022
7bf3283
fix css
Apr 19, 2022
3ce6e63
fix css
Apr 19, 2022
1089bc6
test fixes
Apr 19, 2022
3a0d78f
format
Apr 19, 2022
ba9eebf
changes
Apr 19, 2022
7a1618a
fixes
Apr 19, 2022
3dfc726
fixes
Apr 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 11 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
codecov: codecov/codecov@3.1.1
codecov: codecov/codecov@3.2.2
node: circleci/node@4.7.0
jobs:
build:
Expand All @@ -11,6 +11,11 @@ jobs:
- run: mkdir test-reports
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "gradio.egg-info/requires.txt" }}
- run:
name: Install ffmpeg
command: |
sudo apt update
sudo apt install ffmpeg -y
- run:
name: Install Python deps in a venv
command: |
Expand Down Expand Up @@ -38,11 +43,6 @@ jobs:
- run:
command: |
mkdir screenshots
- run:
command: |
. venv/bin/activate
coverage run -m pytest
coverage xml
- run:
command: |
. venv/bin/activate
Expand All @@ -55,6 +55,11 @@ jobs:
command: |
. venv/bin/activate
python -m flake8 --ignore=E731,E501,E722,W503,E126,F401,E203 gradio test
- run:
command: |
. venv/bin/activate
coverage run -m pytest
coverage xml
- codecov/upload:
file: 'coverage.xml'
- store_artifacts:
Expand Down
55 changes: 45 additions & 10 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: gradio-ui

on:
push:
branches:
- "master"
branches:
- "main"
paths:
- "ui/**"
pull_request:
Expand All @@ -12,23 +12,31 @@ on:

defaults:
run:
working-directory: ./ui
working-directory: ui

env:
CI: true
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
NODE_OPTIONS: "--max-old-space-size=4096"

concurrency:
group: deploy-${{ github.ref }}-${{ github.event_name == 'push' || github.event.inputs.fire != null }}
cancel-in-progress: true

jobs:
check:
quick-checks:
name: static checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm i -g pnpm@6
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.1
with:
version: 6
- uses: actions/setup-node@v3
with:
node-version: 16

cache: pnpm
cache-dependency-path: ui/pnpm-lock.yaml
- name: install dependencies
run: pnpm i --frozen-lockfile
- name: formatting check
Expand All @@ -38,5 +46,32 @@ jobs:
continue-on-error: true
- name: unit tests
run: pnpm test:run
- name: build
run: pnpm build
functional-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.1
with:
version: 6
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
cache-dependency-path: ui/pnpm-lock.yaml
- name: Cache browsers
id: browser_cache
uses: actions/cache@main
with:
path: "~/.cache/ms-playwright"
key: chromium-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile
- run: pnpx playwright install chromium
- run: pnpm build
- run: pnpm test:browser
- name: Upload failed tests screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
retention-days: 3
name: test-failure-${{ github.run_id }}
path: ui/packages/app/test-results
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ coverage:
source:
paths:
- "gradio/"
target: 80%
target: 70%
threshold: 0.1
patch: off

Expand Down
91 changes: 91 additions & 0 deletions demo/blocks_flashcards/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import random

import gradio as gr

demo = gr.Blocks()

with demo:
gr.Markdown(
"Load the flashcards in the table below, then use the Practice tab to practice."
)

with gr.Tabs():
with gr.TabItem("Word Bank"):
flashcards_table = gr.Dataframe(headers=["front", "back"], type="array")
with gr.TabItem("Practice"):
with gr.Row():
front = gr.Textbox()
answer_row = gr.Row(visible=False)
with answer_row:
back = gr.Textbox()
with gr.Row():
new_btn = gr.Button("New Card")
flip_btn = gr.Button("Flip Card")
selected_card = gr.Variable()
feedback_row = gr.Row(visible=False)
with feedback_row:
correct_btn = gr.Button(
"Correct",
css={"background-color": "lightgreen", "color": "green"},
)
incorrect_btn = gr.Button(
"Incorrect", css={"background-color": "pink", "color": "red"}
)
with gr.TabItem("Results"):
results = gr.Variable(default_value={})
correct_field = gr.Markdown("# Correct: 0")
incorrect_field = gr.Markdown("# Incorrect: 0")
gr.Markdown("Card Statistics: ")
results_table = gr.Dataframe(headers=["Card", "Correct", "Incorrect"])

def load_new_card(flashcards):
card = random.choice(flashcards)
return card, card[0], False, False

new_btn.click(
load_new_card,
[flashcards_table],
[selected_card, front, answer_row, feedback_row],
)

def flip_card(card):
return card[1], True, True

flip_btn.click(flip_card, [selected_card], [back, answer_row, feedback_row])

def mark_correct(card, results):
if card[0] not in results:
results[card[0]] = [0, 0]
results[card[0]][0] += 1
correct_count = sum(result[0] for result in results.values())
return (
results,
f"# Correct: {correct_count}",
[[front, scores[0], scores[1]] for front, scores in results.items()],
)

def mark_incorrect(card, results):
if card[0] not in results:
results[card[0]] = [0, 0]
results[card[0]][1] += 1
incorrect_count = sum(result[1] for result in results.values())
return (
results,
f"# Inorrect: {incorrect_count}",
[[front, scores[0], scores[1]] for front, scores in results.items()],
)

correct_btn.click(
mark_correct,
[selected_card, results],
[results, correct_field, results_table],
)

incorrect_btn.click(
mark_incorrect,
[selected_card, results],
[results, incorrect_field, results_table],
)

if __name__ == "__main__":
demo.launch()
19 changes: 19 additions & 0 deletions demo/blocks_inputs/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import gradio as gr

str = """Hello friends
hello friends

Hello friends

"""


with gr.Blocks() as demo:
txt = gr.Textbox(label="Input", lines=5)
txt_2 = gr.Textbox(label="Output")
txt_3 = gr.Textbox(str, label="Output")
btn = gr.Button("Submit")
btn.click(lambda a: a, inputs=[txt], outputs=[txt_2])

if __name__ == "__main__":
demo.launch()
38 changes: 38 additions & 0 deletions demo/blocks_kinematics/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import matplotlib.pyplot as plt
import numpy as np

import gradio as gr


def plot(v, a):
g = 9.81
theta = a / 180 * 3.14
tmax = ((2 * v) * np.sin(theta)) / g
timemat = tmax * np.linspace(0, 1, 40)[:, None]

x = (v * timemat) * np.cos(theta)
y = ((v * timemat) * np.sin(theta)) - ((0.5 * g) * (timemat**2))

fig = plt.figure()
plt.scatter(x=x, y=y, marker=".")
plt.xlim(0, 100)
plt.ylim(0, 60)
return fig


demo = gr.Blocks()

with demo:
gr.Markdown(
"Let's do some kinematics! Choose the speed and angle to see the trajectory."
)

with gr.Row():
speed = gr.Slider(25, min=1, max=30, label="Speed")
angle = gr.Slider(45, min=0, max=90, label="Angle")
output = gr.Image(type="plot")
btn = gr.Button("Run")
btn.click(plot, [speed, angle], output)

if __name__ == "__main__":
demo.launch()
Binary file not shown.
Binary file not shown.
Binary file added demo/blocks_neural_instrument_coding/new-sax.wav
Binary file not shown.
Loading