-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image editor #6169
Merged
Merged
Image editor #6169
Changes from all commits
Commits
Show all changes
222 commits
Select commit
Hold shift + click to select a range
85ba6de
squash commit
freddyaboulton d2314e5
BugFix: Make FileExplorer Component Templateable (#5933)
freddyaboulton a008420
Fix notebooks (#5935)
freddyaboulton 2986ea4
Merge branch 'main' into v4
freddyaboulton dcf13d7
V4: Update Component pyi file (#5937)
freddyaboulton 2dde40a
merge main
freddyaboulton 13ed8a4
V4: Use beta release versions for '@gradio' packages (#5938)
freddyaboulton d0cc6b1
maybe fix (#5946)
pngwn 9b330eb
Merge main again (#5948)
pngwn 1c390f1
Merge main again (#5949)
pngwn 5b6ef3f
Merge main again (#5950)
pngwn d558e8d
log
pngwn 7c5e131
log
pngwn 607dab8
fix changesets
pngwn 56b790c
Merge branch 'main' into v4
abidlabs 7f12a83
Merge branch 'main' into v4
abidlabs 319c30f
rererefactor frontend files (#5960)
pngwn d298e76
Strip vite import warning (#5962)
freddyaboulton 0b99f8e
chore: update versions (beta) (#5769)
pngwn 174b736
release wasm (#5963)
pngwn 5fbda0b
Wasm release (#5964)
pngwn f7475ee
chore: update versions (beta) (#5965)
pngwn fdc7c0a
Merge branch 'main' into v4
abidlabs 0c571c0
Add json schema unit tests (#5970)
freddyaboulton 85056de
V4: Simple textbox (#5990)
freddyaboulton be2ed5e
File upload optimization (#5961)
freddyaboulton 6b0bb5e
Removes deprecated arguments and parameters from v4 (#5968)
abidlabs 9cf40f7
V4: Simple dropdown (#5996)
freddyaboulton cad537a
pass props to example components and to example outputs (#6014)
pngwn 83e9476
Format js in v4 branch (#6016)
freddyaboulton de18102
V4: Fix component update bug (#6027)
freddyaboulton 0eb9687
Merge main
freddyaboulton 98ab4f1
Merge branch 'v4' of github.com:gradio-app/gradio into v4
freddyaboulton 8ce90b8
lockfile update
freddyaboulton d444b8d
Fixing test
freddyaboulton b98950f
fix test
freddyaboulton 184834d
Add a cli command to list available templates (#6018)
freddyaboulton b19516b
Merge branch 'main' into v4
abidlabs dbb7de5
fix tests (#6046)
pngwn 76d28d3
Merge branch 'main' into v4
pngwn 7d07001
fix storybook (#6065)
pngwn bf38e5f
remove dupe component (#6067)
pngwn 9053c95
Simplify File Component (#6044)
freddyaboulton 447dfe0
Clean up backend of `File` and `UploadButton` and change the return t…
abidlabs 6b82a97
Fix Dropdown Example component and example processing logic (#6075)
abidlabs 3b2d9ea
fix cc build (#6079)
pngwn f08da1a
Fixes markdown rendering in examples (#6071)
abidlabs 35a227f
Proposal: sample demo for custom components should be a `gr.Interface…
abidlabs 037e5af
WIP: Fix docs (#6082)
freddyaboulton ce036c5
Pending events behavior (#5826)
dawoodkhan82 66549d8
Fixes: slider bar are too thin on FireFox (#5984)
dawoodkhan82 abff6fb
Fix remaining xfail tests in backend (#6073)
freddyaboulton 825c9cd
Fix dev mode model3D (#5955)
freddyaboulton 338969a
V4: Single-file implementation of form components (#6026)
freddyaboulton cd8146b
Update logos for v4 (#6089)
abidlabs 11d67ae
Add a stand-alone install command and tidy-up the fallback template (…
freddyaboulton fadc057
V4: Fix constructor_args (#6093)
freddyaboulton 9a40de7
Fix: Move to cache in init postprocess + Fallback Fixes (#6107)
freddyaboulton e402bf0
fix build (#6112)
pngwn 20dbf90
Update cold-lemons-roll.md
freddyaboulton 06b1182
Revert "Update cold-lemons-roll.md" (#6113)
freddyaboulton 39227b6
Try to trigger a major beta release (#6114)
freddyaboulton 05e19a2
Delete bad changelog (#6115)
freddyaboulton 985f17a
merge
freddyaboulton 3e803a8
Merge branch 'v4' of github.com:gradio-app/gradio into v4
freddyaboulton 94f4385
formatting
hannahblair 205f613
Revert "formatting"
hannahblair 9cad212
Improve Audio Component (#5966)
hannahblair 9ed625f
Fix changesets 2 (#6116)
pngwn 0c8dac3
Fix changesets 2 (#6117)
pngwn 90116f2
chore: update versions (beta) (#5973)
pngwn 9969866
v4
abidlabs d5d29c9
Open source FRP server and allow `gradio` to connect to custom share …
abidlabs c3bc515
Gradio custom component publish (#6098)
freddyaboulton a7435ba
Fix static issues with Lite on v4 (#6124)
aliabd 865a22d
Refactor `Blocks.load()` so that it is in the same style as the other…
abidlabs d2dfc1b
Small change to make `api_open=False` by default (#6138)
abidlabs c476bd5
Image v4 (#6094)
pngwn 0d261c6
Fix fallback demo app template code (#6129)
freddyaboulton 5916b3d
fix video path
abidlabs c092936
Revert "fix video path"
abidlabs bce37ac
Fix selectable prop in the backend (#6135)
freddyaboulton 71bf270
Fix video (#6140)
abidlabs 274af0f
Merge branch 'main' into v4
abidlabs 53350c7
fix some tests on mac
abidlabs e4f7b4b
fix circular dependency with client + upload (#6143)
pngwn 40a171e
Fix image double change bug (#6146)
pngwn 0891615
make lite private (#6147)
pngwn 0000a19
fix dropdown arrow size (#6148)
pngwn 90318b1
swap `mode` on the frontned to `interactive` to match the backend (#6…
pngwn 0cc30dd
attempt to create python component
pngwn 103416d
JS READMEs and Storybook on Docs (#6142)
aliabd 9c3bf31
Don't serve files in working directory by default (#6128)
abidlabs e67e3f8
Fix issues with website deploy (#6151)
aliabd bf127e1
Swap websockets for SSE (#6069)
aliabid94 982bff2
Remove duplicate `elem_ids` from components (#6152)
hannahblair f71ea09
Moves `gradio_cached_folder` inside the gradio temp direcotry (#6155)
abidlabs 1162ed6
Remove `show_edit_button` param in Audio (#6153)
hannahblair a8ef6d5
Remove interpretation for good (#6154)
abidlabs db143bd
Make output components not editable if they are being updated (#6157)
dawoodkhan82 667802a
JS Component Documentation (#6136)
freddyaboulton 88bccfd
Improve Video Component (#6118)
hannahblair 0fe20f3
chore: update versions (beta) (#6122)
pngwn c829030
changes
pngwn 168cc64
V4 fixes (#6161)
aliabid94 b3d4de1
Pin 8.9 (#6162)
freddyaboulton 040ec31
Pending outputs fix (#6160)
dawoodkhan82 44ead3b
Clean root url (#6159)
abidlabs 570679f
V4 fixes (#6167)
aliabid94 1e2d0e1
Fixes remaining backend tests (#6165)
abidlabs 91a7881
make it work
pngwn 71dd639
testing something (#6173)
abidlabs 74b4ed3
add changeset
gradio-pr-bot 848a630
Merge branch 'v4' into image-editor
abidlabs 7eb93c9
Version 4 development branch (#5498)
pngwn 533fdf7
strip dangling svelte imports (#6171)
pngwn f3f1d74
leave pre-release mode (#6170)
pngwn bdf64f4
Final touches main (#6174)
freddyaboulton 1f97f83
Part I: Remove serializes (#6177)
abidlabs fee317f
Queue concurrency count (#6172)
aliabid94 58040cb
Allow data at queue join (#6182)
aliabid94 b0111a9
Remove gr.mix (#6184)
abidlabs edc1feb
Cleanup theme vars (#6183)
aliabid94 31817d0
fix (#6185)
pngwn 385b23c
chore: update versions (#6039)
pngwn 6c43228
modify preprocess to use pydantic models (#6181)
abidlabs dfc3168
JS Param (#6137)
dawoodkhan82 2ee19f2
Custom Component Guides (#6189)
freddyaboulton 84f468d
patch changesets (#6190)
abidlabs cc47eed
chore: update versions (#6188)
pngwn 88c4ac8
fix cdn build (#6191)
pngwn e1f88e9
chore: update versions (#6192)
pngwn 134840b
4.0 Website Changes (#6193)
aliabd 52e4d77
fix`FileExplorer` preprocess (#6211)
pngwn 2d9c73a
Ensure the statustracker for `gr.Image` displays in static mode (#6213)
pngwn beef9b3
Add that api routes are automatically named to CHANGELOG. (#6227)
freddyaboulton 69e7b70
fix ci (#6235)
pngwn 9182d90
Add likeable to config for Chatbot (#6231)
freddyaboulton ec15e2c
Model3D panning, improved UX (#6240)
dylanebert 5b09339
Fix stories (#6244)
abidlabs 3b878f4
Update README.md to correct example which throws error when using "sh…
RaghuSpaceRajan 15675eb
Fix file overflow and add keyboard navigation to `FileExplorer` (#5876)
hannahblair 66af378
Remove session if browser closed on mobile (#6241)
aliabid94 92b0504
fix: avoid unnecessary folders creation when flagging (#6245)
EgonFerri 9614d65
Some tweaks to the Custom Components Guide (#6243)
abidlabs d4686c4
Fixes: Initial message is overwrtitten in chat interface (#6229)
dawoodkhan82 5c8e714
ensure radios have different names (#6249)
pngwn e565daf
Ensure `gr.CheckboxGroup` updates as expected. (#6236)
pngwn 4800d91
Video/Audio fixes (#6234)
freddyaboulton 641766c
Fix bug where radio.select passes the previous value to the function …
freddyaboulton a34e85e
Improve Embed and CDN handling and fix a couple of related bugs (#6261)
pngwn 11b1814
Fix updating interactive prop (#6266)
abidlabs 7ed76f0
Fix various issues with demos on website (#6268)
aliabd 31393cb
Fixes input `Image` component with `streaming=True` (#6272)
abidlabs d2e0138
Update dependency msw to v2 (#6270)
renovate[bot] 9239a8f
Ensure Model 3D updates when attributes change (#6255)
hannahblair fc4588f
Merge branch 'main' into image-editor
pngwn cef82b8
fix
pngwn a1e400e
fix
pngwn fa2b5b9
fix types
pngwn 887cddf
Merge branch 'main' into image-editor
abidlabs 50806f2
fix vs main
pngwn 3fc739a
changes
pngwn cd8236e
changes
pngwn b18f696
fix
pngwn d58cc1d
Merge branch 'main' into image-editor
pngwn 62abb13
add changeset
gradio-pr-bot ef0229f
fix build
pngwn bf3b91b
asd
pngwn ae84cc4
fix crop squish + image allpha issue
pngwn 38a421a
fix webcam
pngwn 7b65f25
fix image editor as input
pngwn 7a38b54
enable undo + redo
pngwn 6b76462
little cleanup
pngwn d69078e
Merge branch 'main' into image-editor
abidlabs 862f8d9
fixes
pngwn ed080d1
allow user to draw with no bg
pngwn 1d5d24d
fix webcam
pngwn 5e78ce1
remove rotate
pngwn 4e6953a
Merge branch 'main' into image-editor
pngwn bbf0680
Merge branch 'main' into image-editor
abidlabs aa7a415
tweaks
pngwn 320910f
push fix
abidlabs e9243be
Merge branch 'main' into image-editor
abidlabs 3b2080e
image editor tests and accessibility improvements (#6468)
hannahblair bef6e9f
add draggable crop
pngwn 94e9c3f
brush swatches
pngwn a1032b2
fix colopicker interactivity
pngwn 4791b17
fix clear + layer creation
pngwn 9245da1
fix submit + webcam
pngwn 7777d59
fix events again
pngwn 51088b9
fix non interactive mode
pngwn 53a387e
Merge branch 'main' into image-editor
abidlabs f8cfbfa
python 3.8
abidlabs c0f28f4
Merge branch 'image-editor' of github.com:gradio-app/gradio into imag…
abidlabs d3aa142
lint so that we can run static checks
abidlabs eb5ec31
misc fixes
pngwn 94c32c6
fixes
pngwn bd5f950
fix things
pngwn 4becb43
fix dark mode
pngwn f8b6f4b
add crop constraints
pngwn 7db1de6
changers
pngwn 5f6be60
misc fixes
pngwn 3ee47c8
fix statustracker
pngwn ec69d7e
fix ci
pngwn ceb00d8
add changeset
gradio-pr-bot c6319be
crop resize on backend too
pngwn b47cc8c
fix thing
pngwn 7c6f8cb
format (#6478)
abidlabs 2366525
python tweaks
pngwn e3fdbe5
tweak ux
pngwn d86c747
fix ts
pngwn 83c72b5
update vitest
pngwn 9c81092
update vitest
pngwn fdadd95
update lockfile
pngwn 03500f7
expand changeset
pngwn 06d315a
expand changeset
pngwn ed625c5
expand changeset
pngwn 6c46f1a
expand changeset
pngwn d31cd06
fix notebooks
pngwn 8a94dcc
a more betterer changeset
pngwn e97796c
final tweaks
pngwn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
"@gradio/app": minor | ||
"@gradio/atoms": minor | ||
"@gradio/icons": minor | ||
"@gradio/image": minor | ||
"@gradio/imageeditor": minor | ||
"@gradio/preview": minor | ||
"@gradio/statustracker": minor | ||
"@gradio/upload": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat: | ||
|
||
#### New `ImageEditor` component | ||
|
||
A brand new component, completely separate from `Image` that provides simple editing capabilities. | ||
|
||
- Set background images from file uploads, webcam, or just paste! | ||
- Crop images with an improved cropping UI. App authors can event set specific crop size, or crop ratios (`1:1`, etc) | ||
- Paint on top of any image (or no image) and erase any mistakes! | ||
- The ImageEditor supports layers, confining draw and erase actions to that layer. | ||
- More flexible access to data. The image component returns a composite image representing the final state of the canvas as well as providing the background and all layers as individual images. | ||
- Fully customisable. All features can be enabled and disabled. Even the brush color swatches can be customised. | ||
|
||
<video src="https://user-images.githubusercontent.com/12937446/284027169-31188926-fd16-4a1c-8718-998e7aae4695.mp4" autoplay muted></video> | ||
|
||
```py | ||
|
||
def fn(im): | ||
im["composite"] # the full canvas | ||
im["background"] # the background image | ||
im["layers"] # a list of individual layers | ||
|
||
|
||
im = gr.ImageEditor( | ||
# decide which sources you'd like to accept | ||
sources=["upload", "webcam", "clipboard"], | ||
# set a cropsize constraint, can either be a ratio or a concrete [width, height] | ||
crop_size="1:1", | ||
# enable crop (or disable it) | ||
transforms=["crop"], | ||
# customise the brush | ||
brush=Brush( | ||
default_size="25", # or leave it as 'auto' | ||
color_mode="fixed", # 'fixed' hides the user swatches and colorpicker, 'defaults' shows it | ||
default_color="hotpink", # html names are supported | ||
colors=[ | ||
"rgba(0, 150, 150, 1)", # rgb(a) | ||
"#fff", # hex rgb | ||
"hsl(360, 120, 120)" # in fact any valid colorstring | ||
] | ||
), | ||
brush=Eraser(default_size="25") | ||
) | ||
|
||
``` |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: image_editor"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/image_editor/cheetah.jpg"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import time\n", "\n", "\n", "def sleep(im):\n", " time.sleep(5)\n", " return [im[\"background\"], im[\"layers\"][0], im[\"layers\"][1], im[\"composite\"]]\n", "\n", "\n", "with gr.Blocks() as demo:\n", " im = gr.ImageEditor(\n", " type=\"pil\",\n", " crop_size=\"1:1\",\n", " )\n", "\n", " with gr.Group():\n", " with gr.Row():\n", " im_out_1 = gr.Image(type=\"pil\")\n", " im_out_2 = gr.Image(type=\"pil\")\n", " im_out_3 = gr.Image(type=\"pil\")\n", " im_out_4 = gr.Image(type=\"pil\")\n", "\n", " btn = gr.Button()\n", " im.change(sleep, outputs=[im_out_1, im_out_2, im_out_3, im_out_4], inputs=im)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import gradio as gr | ||
import time | ||
|
||
|
||
def sleep(im): | ||
time.sleep(5) | ||
return [im["background"], im["layers"][0], im["layers"][1], im["composite"]] | ||
|
||
|
||
with gr.Blocks() as demo: | ||
im = gr.ImageEditor( | ||
type="pil", | ||
crop_size="1:1", | ||
) | ||
|
||
with gr.Group(): | ||
with gr.Row(): | ||
im_out_1 = gr.Image(type="pil") | ||
im_out_2 = gr.Image(type="pil") | ||
im_out_3 = gr.Image(type="pil") | ||
im_out_4 = gr.Image(type="pil") | ||
|
||
btn = gr.Button() | ||
im.change(sleep, outputs=[im_out_1, im_out_2, im_out_3, im_out_4], inputs=im) | ||
|
||
if __name__ == "__main__": | ||
demo.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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand demo. Uodate image mask demo. Add to deploy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to have a more complex demo as well, that shows e.g. a custom
Brush
,crop_size
, etc.