hd0013 commited on
Commit
8fdc036
1 Parent(s): 3b96025

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +2 -0
  2. .gitattributes +2 -0
  3. CHANGELOG.md +0 -0
  4. README.md +3 -9
  5. __init__.py +107 -0
  6. __pycache__/__init__.cpython-310.pyc +0 -0
  7. __pycache__/analytics.cpython-310.pyc +0 -0
  8. __pycache__/blocks.cpython-310.pyc +0 -0
  9. __pycache__/blocks_events.cpython-310.pyc +0 -0
  10. __pycache__/chat_interface.cpython-310.pyc +0 -0
  11. __pycache__/component_meta.cpython-310.pyc +0 -0
  12. __pycache__/context.cpython-310.pyc +0 -0
  13. __pycache__/data_classes.cpython-310.pyc +0 -0
  14. __pycache__/events.cpython-310.pyc +0 -0
  15. __pycache__/exceptions.cpython-310.pyc +0 -0
  16. __pycache__/external.cpython-310.pyc +0 -0
  17. __pycache__/external_utils.cpython-310.pyc +0 -0
  18. __pycache__/flagging.cpython-310.pyc +0 -0
  19. __pycache__/helpers.cpython-310.pyc +0 -0
  20. __pycache__/http_server.cpython-310.pyc +0 -0
  21. __pycache__/image_utils.cpython-310.pyc +0 -0
  22. __pycache__/interface.cpython-310.pyc +0 -0
  23. __pycache__/ipython_ext.cpython-310.pyc +0 -0
  24. __pycache__/networking.cpython-310.pyc +0 -0
  25. __pycache__/oauth.cpython-310.pyc +0 -0
  26. __pycache__/pipelines.cpython-310.pyc +0 -0
  27. __pycache__/pipelines_utils.cpython-310.pyc +0 -0
  28. __pycache__/processing_utils.cpython-310.pyc +0 -0
  29. __pycache__/queueing.cpython-310.pyc +0 -0
  30. __pycache__/ranged_response.cpython-310.pyc +0 -0
  31. __pycache__/renderable.cpython-310.pyc +0 -0
  32. __pycache__/route_utils.cpython-310.pyc +0 -0
  33. __pycache__/routes.cpython-310.pyc +0 -0
  34. __pycache__/server_messages.cpython-310.pyc +0 -0
  35. __pycache__/state_holder.cpython-310.pyc +0 -0
  36. __pycache__/strings.cpython-310.pyc +0 -0
  37. __pycache__/templates.cpython-310.pyc +0 -0
  38. __pycache__/tunneling.cpython-310.pyc +0 -0
  39. __pycache__/utils.cpython-310.pyc +0 -0
  40. __pycache__/wasm_utils.cpython-310.pyc +0 -0
  41. _frontend_code/accordion/Index.svelte +31 -0
  42. _frontend_code/accordion/package.json +23 -0
  43. _frontend_code/accordion/shared/Accordion.svelte +34 -0
  44. _frontend_code/annotatedimage/Index.svelte +251 -0
  45. _frontend_code/annotatedimage/package.json +26 -0
  46. _frontend_code/atoms/package.json +14 -0
  47. _frontend_code/atoms/src/Block.svelte +93 -0
  48. _frontend_code/atoms/src/BlockLabel.svelte +72 -0
  49. _frontend_code/atoms/src/BlockTitle.svelte +45 -0
  50. _frontend_code/atoms/src/Empty.svelte +63 -0
.dockerignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ templates/frontend
2
+ templates/frontend/**/*
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ frpc_linux_amd64_v0.2 filter=lfs diff=lfs merge=lfs -text
37
+ templates/frontend/assets/Index-Bk2HDCfO.js.map filter=lfs diff=lfs merge=lfs -text
CHANGELOG.md ADDED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Gradio
3
- emoji: 🏃
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.31.5
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: gradio
3
+ app_file: interface.py
 
 
4
  sdk: gradio
5
+ sdk_version: 4.31.4
 
 
6
  ---
 
 
__init__.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import gradio._simple_templates
4
+ import gradio.image_utils
5
+ import gradio.processing_utils
6
+ import gradio.templates
7
+ from gradio import components, layouts, themes
8
+ from gradio.blocks import Blocks
9
+ from gradio.chat_interface import ChatInterface
10
+ from gradio.components import (
11
+ HTML,
12
+ JSON,
13
+ AnnotatedImage,
14
+ Annotatedimage,
15
+ Audio,
16
+ BarPlot,
17
+ Button,
18
+ Chatbot,
19
+ Checkbox,
20
+ CheckboxGroup,
21
+ Checkboxgroup,
22
+ ClearButton,
23
+ Code,
24
+ ColorPicker,
25
+ DataFrame,
26
+ Dataframe,
27
+ Dataset,
28
+ DownloadButton,
29
+ Dropdown,
30
+ DuplicateButton,
31
+ File,
32
+ FileExplorer,
33
+ Gallery,
34
+ Highlight,
35
+ HighlightedText,
36
+ Highlightedtext,
37
+ Image,
38
+ ImageEditor,
39
+ Json,
40
+ Label,
41
+ LinePlot,
42
+ LoginButton,
43
+ LogoutButton,
44
+ Markdown,
45
+ Model3D,
46
+ MultimodalTextbox,
47
+ Number,
48
+ ParamViewer,
49
+ Plot,
50
+ Radio,
51
+ ScatterPlot,
52
+ Slider,
53
+ State,
54
+ Text,
55
+ Textbox,
56
+ UploadButton,
57
+ Video,
58
+ component,
59
+ )
60
+ from gradio.components.audio import WaveformOptions
61
+ from gradio.components.image_editor import Brush, Eraser
62
+ from gradio.data_classes import FileData
63
+ from gradio.events import EventData, KeyUpData, LikeData, SelectData, on
64
+ from gradio.exceptions import Error
65
+ from gradio.external import load
66
+ from gradio.flagging import (
67
+ CSVLogger,
68
+ FlaggingCallback,
69
+ HuggingFaceDatasetSaver,
70
+ SimpleCSVLogger,
71
+ )
72
+ from gradio.helpers import (
73
+ Info,
74
+ Progress,
75
+ Warning,
76
+ make_waveform,
77
+ skip,
78
+ update,
79
+ )
80
+ from gradio.helpers import create_examples as Examples # noqa: N812
81
+ from gradio.interface import Interface, TabbedInterface, close_all
82
+ from gradio.layouts import Accordion, Column, Group, Row, Tab, TabItem, Tabs
83
+ from gradio.oauth import OAuthProfile, OAuthToken
84
+ from gradio.renderable import render
85
+ from gradio.routes import Request, mount_gradio_app
86
+ from gradio.templates import (
87
+ Files,
88
+ ImageMask,
89
+ List,
90
+ Matrix,
91
+ Mic,
92
+ Microphone,
93
+ Numpy,
94
+ Paint,
95
+ PlayableVideo,
96
+ Sketchpad,
97
+ TextArea,
98
+ )
99
+ from gradio.themes import Base as Theme
100
+ from gradio.utils import NO_RELOAD, FileSize, get_package_version, set_static_paths
101
+ from gradio.wasm_utils import IS_WASM
102
+
103
+ if not IS_WASM:
104
+ from gradio.cli import deploy
105
+ from gradio.ipython_ext import load_ipython_extension
106
+
107
+ __version__ = get_package_version()
__pycache__/__init__.cpython-310.pyc ADDED
Binary file (3.22 kB). View file
 
__pycache__/analytics.cpython-310.pyc ADDED
Binary file (8.65 kB). View file
 
__pycache__/blocks.cpython-310.pyc ADDED
Binary file (84.1 kB). View file
 
__pycache__/blocks_events.cpython-310.pyc ADDED
Binary file (1.34 kB). View file
 
__pycache__/chat_interface.cpython-310.pyc ADDED
Binary file (20.3 kB). View file
 
__pycache__/component_meta.cpython-310.pyc ADDED
Binary file (9.91 kB). View file
 
__pycache__/context.cpython-310.pyc ADDED
Binary file (2.2 kB). View file
 
__pycache__/data_classes.cpython-310.pyc ADDED
Binary file (9.23 kB). View file
 
__pycache__/events.cpython-310.pyc ADDED
Binary file (24.3 kB). View file
 
__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (3.51 kB). View file
 
__pycache__/external.cpython-310.pyc ADDED
Binary file (14.2 kB). View file
 
__pycache__/external_utils.cpython-310.pyc ADDED
Binary file (8.79 kB). View file
 
__pycache__/flagging.cpython-310.pyc ADDED
Binary file (15 kB). View file
 
__pycache__/helpers.cpython-310.pyc ADDED
Binary file (40.4 kB). View file
 
__pycache__/http_server.cpython-310.pyc ADDED
Binary file (5.35 kB). View file
 
__pycache__/image_utils.cpython-310.pyc ADDED
Binary file (2.35 kB). View file
 
__pycache__/interface.cpython-310.pyc ADDED
Binary file (31.4 kB). View file
 
__pycache__/ipython_ext.cpython-310.pyc ADDED
Binary file (3.49 kB). View file
 
__pycache__/networking.cpython-310.pyc ADDED
Binary file (1.87 kB). View file
 
__pycache__/oauth.cpython-310.pyc ADDED
Binary file (10.1 kB). View file
 
__pycache__/pipelines.cpython-310.pyc ADDED
Binary file (3.17 kB). View file
 
__pycache__/pipelines_utils.cpython-310.pyc ADDED
Binary file (19.8 kB). View file
 
__pycache__/processing_utils.cpython-310.pyc ADDED
Binary file (28.1 kB). View file
 
__pycache__/queueing.cpython-310.pyc ADDED
Binary file (16.7 kB). View file
 
__pycache__/ranged_response.cpython-310.pyc ADDED
Binary file (5.86 kB). View file
 
__pycache__/renderable.cpython-310.pyc ADDED
Binary file (2.75 kB). View file
 
__pycache__/route_utils.cpython-310.pyc ADDED
Binary file (27.2 kB). View file
 
__pycache__/routes.cpython-310.pyc ADDED
Binary file (38.1 kB). View file
 
__pycache__/server_messages.cpython-310.pyc ADDED
Binary file (3.19 kB). View file
 
__pycache__/state_holder.cpython-310.pyc ADDED
Binary file (4.46 kB). View file
 
__pycache__/strings.cpython-310.pyc ADDED
Binary file (2.63 kB). View file
 
__pycache__/templates.cpython-310.pyc ADDED
Binary file (14.3 kB). View file
 
__pycache__/tunneling.cpython-310.pyc ADDED
Binary file (3.87 kB). View file
 
__pycache__/utils.cpython-310.pyc ADDED
Binary file (43.1 kB). View file
 
__pycache__/wasm_utils.cpython-310.pyc ADDED
Binary file (1.49 kB). View file
 
_frontend_code/accordion/Index.svelte ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import Accordion from "./shared/Accordion.svelte";
3
+ import { Block } from "@gradio/atoms";
4
+ import { StatusTracker } from "@gradio/statustracker";
5
+ import type { LoadingStatus } from "@gradio/statustracker";
6
+
7
+ import Column from "@gradio/column";
8
+ import type { Gradio } from "@gradio/utils";
9
+
10
+ export let label: string;
11
+ export let elem_id: string;
12
+ export let elem_classes: string[];
13
+ export let visible = true;
14
+ export let open = true;
15
+ export let loading_status: LoadingStatus;
16
+ export let gradio: Gradio;
17
+ </script>
18
+
19
+ <Block {elem_id} {elem_classes} {visible}>
20
+ <StatusTracker
21
+ autoscroll={gradio.autoscroll}
22
+ i18n={gradio.i18n}
23
+ {...loading_status}
24
+ />
25
+
26
+ <Accordion {label} bind:open>
27
+ <Column>
28
+ <slot />
29
+ </Column>
30
+ </Accordion>
31
+ </Block>
_frontend_code/accordion/package.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/accordion",
3
+ "version": "0.3.14",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": true,
9
+ "main_changeset": true,
10
+ "dependencies": {
11
+ "@gradio/atoms": "workspace:^",
12
+ "@gradio/column": "workspace:^",
13
+ "@gradio/statustracker": "workspace:^",
14
+ "@gradio/utils": "workspace:0.4.1"
15
+ },
16
+ "devDependencies": {
17
+ "@gradio/preview": "workspace:^"
18
+ },
19
+ "exports": {
20
+ ".": "./Index.svelte",
21
+ "./package.json": "./package.json"
22
+ }
23
+ }
_frontend_code/accordion/shared/Accordion.svelte ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let open = true;
3
+ export let label = "";
4
+ </script>
5
+
6
+ <button on:click={() => (open = !open)} class="label-wrap" class:open>
7
+ <span>{label}</span>
8
+ <span style:transform={open ? "rotate(0)" : "rotate(90deg)"} class="icon">
9
+
10
+ </span>
11
+ </button>
12
+ <div style:display={open ? "block" : "none"}>
13
+ <slot />
14
+ </div>
15
+
16
+ <style>
17
+ span {
18
+ font-weight: var(--section-header-text-weight);
19
+ font-size: var(--section-header-text-size);
20
+ }
21
+ .label-wrap {
22
+ display: flex;
23
+ justify-content: space-between;
24
+ cursor: pointer;
25
+ width: var(--size-full);
26
+ }
27
+ .label-wrap.open {
28
+ margin-bottom: var(--size-2);
29
+ }
30
+
31
+ .icon {
32
+ transition: 150ms;
33
+ }
34
+ </style>
_frontend_code/annotatedimage/Index.svelte ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio, SelectData } from "@gradio/utils";
3
+
4
+ import { Block, BlockLabel, Empty } from "@gradio/atoms";
5
+ import { Image } from "@gradio/icons";
6
+ import { StatusTracker } from "@gradio/statustracker";
7
+ import type { LoadingStatus } from "@gradio/statustracker";
8
+ import { type FileData } from "@gradio/client";
9
+ import { resolve_wasm_src } from "@gradio/wasm/svelte";
10
+
11
+ export let elem_id = "";
12
+ export let elem_classes: string[] = [];
13
+ export let visible = true;
14
+ export let value: {
15
+ image: FileData;
16
+ annotations: { image: FileData; label: string }[] | [];
17
+ } | null = null;
18
+ let old_value: {
19
+ image: FileData;
20
+ annotations: { image: FileData; label: string }[] | [];
21
+ } | null = null;
22
+ let _value: {
23
+ image: FileData;
24
+ annotations: { image: FileData; label: string }[];
25
+ } | null = null;
26
+ export let gradio: Gradio<{
27
+ change: undefined;
28
+ select: SelectData;
29
+ }>;
30
+ export let label = gradio.i18n("annotated_image.annotated_image");
31
+ export let show_label = true;
32
+ export let show_legend = true;
33
+ export let height: number | undefined;
34
+ export let width: number | undefined;
35
+ export let color_map: Record<string, string>;
36
+ export let container = true;
37
+ export let scale: number | null = null;
38
+ export let min_width: number | undefined = undefined;
39
+ let active: string | null = null;
40
+ export let loading_status: LoadingStatus;
41
+
42
+ // `value` can be updated before the Promises from `resolve_wasm_src` are resolved.
43
+ // In such a case, the resolved values for the old `value` have to be discarded,
44
+ // This variable `latest_promise` is used to pick up only the values resolved for the latest `value`.
45
+ let latest_promise: Promise<unknown> | null = null;
46
+ $: {
47
+ if (value !== old_value) {
48
+ old_value = value;
49
+ gradio.dispatch("change");
50
+ }
51
+ if (value) {
52
+ const normalized_value = {
53
+ image: value.image as FileData,
54
+ annotations: value.annotations.map((ann) => ({
55
+ image: ann.image as FileData,
56
+ label: ann.label
57
+ }))
58
+ };
59
+ _value = normalized_value;
60
+
61
+ // In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed values immediately
62
+ // without waiting for `resolve_wasm_src()` to resolve.
63
+ // If it waits, a blank image is displayed until the async task finishes
64
+ // and it leads to undesirable flickering.
65
+ // So set `_value` immediately above, and update it with the resolved values below later.
66
+ const image_url_promise = resolve_wasm_src(normalized_value.image.url);
67
+ const annotation_urls_promise = Promise.all(
68
+ normalized_value.annotations.map((ann) =>
69
+ resolve_wasm_src(ann.image.url)
70
+ )
71
+ );
72
+ const current_promise = Promise.all([
73
+ image_url_promise,
74
+ annotation_urls_promise
75
+ ]);
76
+ latest_promise = current_promise;
77
+ current_promise.then(([image_url, annotation_urls]) => {
78
+ if (latest_promise !== current_promise) {
79
+ return;
80
+ }
81
+ const async_resolved_value: typeof _value = {
82
+ image: {
83
+ ...normalized_value.image,
84
+ url: image_url ?? undefined
85
+ },
86
+ annotations: normalized_value.annotations.map((ann, i) => ({
87
+ ...ann,
88
+ image: {
89
+ ...ann.image,
90
+ url: annotation_urls[i] ?? undefined
91
+ }
92
+ }))
93
+ };
94
+ _value = async_resolved_value;
95
+ });
96
+ } else {
97
+ _value = null;
98
+ }
99
+ }
100
+ function handle_mouseover(_label: string): void {
101
+ active = _label;
102
+ }
103
+ function handle_mouseout(): void {
104
+ active = null;
105
+ }
106
+
107
+ function handle_click(i: number, value: string): void {
108
+ gradio.dispatch("select", {
109
+ value: label,
110
+ index: i
111
+ });
112
+ }
113
+ </script>
114
+
115
+ <Block
116
+ {visible}
117
+ {elem_id}
118
+ {elem_classes}
119
+ padding={false}
120
+ {height}
121
+ {width}
122
+ allow_overflow={false}
123
+ {container}
124
+ {scale}
125
+ {min_width}
126
+ >
127
+ <StatusTracker
128
+ autoscroll={gradio.autoscroll}
129
+ i18n={gradio.i18n}
130
+ {...loading_status}
131
+ />
132
+ <BlockLabel
133
+ {show_label}
134
+ Icon={Image}
135
+ label={label || gradio.i18n("image.image")}
136
+ />
137
+
138
+ <div class="container">
139
+ {#if _value == null}
140
+ <Empty size="large" unpadded_box={true}><Image /></Empty>
141
+ {:else}
142
+ <div class="image-container">
143
+ <img
144
+ class="base-image"
145
+ class:fit-height={height}
146
+ src={_value ? _value.image.url : null}
147
+ alt="the base file that is annotated"
148
+ />
149
+ {#each _value ? _value?.annotations : [] as ann, i}
150
+ <img
151
+ alt="segmentation mask identifying {label} within the uploaded file"
152
+ class="mask fit-height"
153
+ class:active={active == ann.label}
154
+ class:inactive={active != ann.label && active != null}
155
+ src={ann.image.url}
156
+ style={color_map && ann.label in color_map
157
+ ? null
158
+ : `filter: hue-rotate(${Math.round(
159
+ (i * 360) / _value?.annotations.length
160
+ )}deg);`}
161
+ />
162
+ {/each}
163
+ </div>
164
+ {#if show_legend && _value}
165
+ <div class="legend">
166
+ {#each _value.annotations as ann, i}
167
+ <button
168
+ class="legend-item"
169
+ style="background-color: {color_map && ann.label in color_map
170
+ ? color_map[ann.label] + '88'
171
+ : `hsla(${Math.round(
172
+ (i * 360) / _value.annotations.length
173
+ )}, 100%, 50%, 0.3)`}"
174
+ on:mouseover={() => handle_mouseover(ann.label)}
175
+ on:focus={() => handle_mouseover(ann.label)}
176
+ on:mouseout={() => handle_mouseout()}
177
+ on:blur={() => handle_mouseout()}
178
+ on:click={() => handle_click(i, ann.label)}
179
+ >
180
+ {ann.label}
181
+ </button>
182
+ {/each}
183
+ </div>
184
+ {/if}
185
+ {/if}
186
+ </div>
187
+ </Block>
188
+
189
+ <style>
190
+ .base-image {
191
+ display: block;
192
+ width: 100%;
193
+ height: auto;
194
+ }
195
+ .container {
196
+ display: flex;
197
+ position: relative;
198
+ flex-direction: column;
199
+ justify-content: center;
200
+ align-items: center;
201
+ width: var(--size-full);
202
+ height: var(--size-full);
203
+ }
204
+ .image-container {
205
+ position: relative;
206
+ top: 0;
207
+ left: 0;
208
+ flex-grow: 1;
209
+ width: 100%;
210
+ overflow: hidden;
211
+ }
212
+ .fit-height {
213
+ position: absolute;
214
+ top: 0;
215
+ left: 0;
216
+ width: 100%;
217
+ height: 100%;
218
+ object-fit: contain;
219
+ }
220
+ .mask {
221
+ opacity: 0.85;
222
+ transition: all 0.2s ease-in-out;
223
+ }
224
+ .image-container:hover .mask {
225
+ opacity: 0.3;
226
+ }
227
+ .mask.active {
228
+ opacity: 1;
229
+ }
230
+ .mask.inactive {
231
+ opacity: 0;
232
+ }
233
+ .legend {
234
+ display: flex;
235
+ flex-direction: row;
236
+ flex-wrap: wrap;
237
+ align-content: center;
238
+ justify-content: center;
239
+ align-items: center;
240
+ gap: var(--spacing-sm);
241
+ padding: var(--spacing-sm);
242
+ }
243
+ .legend-item {
244
+ display: flex;
245
+ flex-direction: row;
246
+ align-items: center;
247
+ cursor: pointer;
248
+ border-radius: var(--radius-sm);
249
+ padding: var(--spacing-sm);
250
+ }
251
+ </style>
_frontend_code/annotatedimage/package.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/annotatedimage",
3
+ "version": "0.6.4",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": true,
9
+ "main_changeset": true,
10
+ "exports": {
11
+ ".": "./Index.svelte",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "devDependencies": {
15
+ "@gradio/preview": "workspace:^"
16
+ },
17
+ "dependencies": {
18
+ "@gradio/atoms": "workspace:^",
19
+ "@gradio/icons": "workspace:^",
20
+ "@gradio/statustracker": "workspace:^",
21
+ "@gradio/upload": "workspace:^",
22
+ "@gradio/utils": "workspace:^",
23
+ "@gradio/client": "workspace:^",
24
+ "@gradio/wasm": "workspace:^"
25
+ }
26
+ }
_frontend_code/atoms/package.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/atoms",
3
+ "version": "0.7.3",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "dependencies": {
10
+ "@gradio/utils": "workspace:^",
11
+ "@gradio/icons": "workspace:^"
12
+ },
13
+ "main_changeset": true
14
+ }
_frontend_code/atoms/src/Block.svelte ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let height: number | string | undefined = undefined;
3
+ export let width: number | string | undefined = undefined;
4
+ export let elem_id = "";
5
+ export let elem_classes: string[] = [];
6
+ export let variant: "solid" | "dashed" | "none" = "solid";
7
+ export let border_mode: "base" | "focus" | "contrast" = "base";
8
+ export let padding = true;
9
+ export let type: "normal" | "fieldset" = "normal";
10
+ export let test_id: string | undefined = undefined;
11
+ export let explicit_call = false;
12
+ export let container = true;
13
+ export let visible = true;
14
+ export let allow_overflow = true;
15
+ export let scale: number | null = null;
16
+ export let min_width = 0;
17
+
18
+ let tag = type === "fieldset" ? "fieldset" : "div";
19
+
20
+ const get_dimension = (
21
+ dimension_value: string | number | undefined
22
+ ): string | undefined => {
23
+ if (dimension_value === undefined) {
24
+ return undefined;
25
+ }
26
+ if (typeof dimension_value === "number") {
27
+ return dimension_value + "px";
28
+ } else if (typeof dimension_value === "string") {
29
+ return dimension_value;
30
+ }
31
+ };
32
+ </script>
33
+
34
+ <svelte:element
35
+ this={tag}
36
+ data-testid={test_id}
37
+ id={elem_id}
38
+ class:hidden={visible === false}
39
+ class="block {elem_classes.join(' ')}"
40
+ class:padded={padding}
41
+ class:border_focus={border_mode === "focus"}
42
+ class:border_contrast={border_mode === "contrast"}
43
+ class:hide-container={!explicit_call && !container}
44
+ style:height={get_dimension(height)}
45
+ style:width={typeof width === "number"
46
+ ? `calc(min(${width}px, 100%))`
47
+ : get_dimension(width)}
48
+ style:border-style={variant}
49
+ style:overflow={allow_overflow ? "visible" : "hidden"}
50
+ style:flex-grow={scale}
51
+ style:min-width={`calc(min(${min_width}px, 100%))`}
52
+ style:border-width="var(--block-border-width)"
53
+ >
54
+ <slot />
55
+ </svelte:element>
56
+
57
+ <style>
58
+ .block {
59
+ position: relative;
60
+ margin: 0;
61
+ box-shadow: var(--block-shadow);
62
+ border-width: var(--block-border-width);
63
+ border-color: var(--block-border-color);
64
+ border-radius: var(--block-radius);
65
+ background: var(--block-background-fill);
66
+ width: 100%;
67
+ line-height: var(--line-sm);
68
+ }
69
+
70
+ .block.border_focus {
71
+ border-color: var(--color-accent);
72
+ }
73
+
74
+ .block.border_contrast {
75
+ border-color: var(--body-text-color);
76
+ }
77
+
78
+ .padded {
79
+ padding: var(--block-padding);
80
+ }
81
+
82
+ .hidden {
83
+ display: none;
84
+ }
85
+ .hide-container {
86
+ margin: 0;
87
+ box-shadow: none;
88
+ --block-border-width: 0;
89
+ background: transparent;
90
+ padding: 0;
91
+ overflow: visible;
92
+ }
93
+ </style>
_frontend_code/atoms/src/BlockLabel.svelte ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let label: string | null = null;
3
+ export let Icon: any;
4
+ export let show_label = true;
5
+ export let disable = false;
6
+ export let float = true;
7
+ </script>
8
+
9
+ <label
10
+ for=""
11
+ class:hide={!show_label}
12
+ class:sr-only={!show_label}
13
+ class:float
14
+ class:hide-label={disable}
15
+ data-testid="block-label"
16
+ >
17
+ <span>
18
+ <Icon />
19
+ </span>
20
+ {label}
21
+ </label>
22
+
23
+ <style>
24
+ label {
25
+ display: inline-flex;
26
+ align-items: center;
27
+ z-index: var(--layer-2);
28
+ box-shadow: var(--block-label-shadow);
29
+ border: var(--block-label-border-width) solid var(--border-color-primary);
30
+ border-top: none;
31
+ border-left: none;
32
+ border-radius: var(--block-label-radius);
33
+ background: var(--block-label-background-fill);
34
+ padding: var(--block-label-padding);
35
+ pointer-events: none;
36
+ color: var(--block-label-text-color);
37
+ font-weight: var(--block-label-text-weight);
38
+ font-size: var(--block-label-text-size);
39
+ line-height: var(--line-sm);
40
+ }
41
+ :global(.gr-group) label {
42
+ border-top-left-radius: 0;
43
+ }
44
+
45
+ label.float {
46
+ position: absolute;
47
+ top: var(--block-label-margin);
48
+ left: var(--block-label-margin);
49
+ }
50
+ label:not(.float) {
51
+ position: static;
52
+ margin-top: var(--block-label-margin);
53
+ margin-left: var(--block-label-margin);
54
+ }
55
+
56
+ .hide {
57
+ height: 0;
58
+ }
59
+
60
+ span {
61
+ opacity: 0.8;
62
+ margin-right: var(--size-2);
63
+ width: calc(var(--block-label-text-size) - 1px);
64
+ height: calc(var(--block-label-text-size) - 1px);
65
+ }
66
+ .hide-label {
67
+ box-shadow: none;
68
+ border-width: 0;
69
+ background: transparent;
70
+ overflow: visible;
71
+ }
72
+ </style>
_frontend_code/atoms/src/BlockTitle.svelte ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { default as Info } from "./Info.svelte";
3
+ export let show_label = true;
4
+ export let info: string | undefined = undefined;
5
+ </script>
6
+
7
+ <span
8
+ class:sr-only={!show_label}
9
+ class:hide={!show_label}
10
+ class:has-info={info != null}
11
+ data-testid="block-info"
12
+ >
13
+ <slot />
14
+ </span>
15
+ {#if info}
16
+ <Info>{info}</Info>
17
+ {/if}
18
+
19
+ <style>
20
+ span.has-info {
21
+ margin-bottom: var(--spacing-xs);
22
+ }
23
+ span:not(.has-info) {
24
+ margin-bottom: var(--spacing-lg);
25
+ }
26
+ span {
27
+ display: inline-block;
28
+ position: relative;
29
+ z-index: var(--layer-4);
30
+ border: solid var(--block-title-border-width)
31
+ var(--block-title-border-color);
32
+ border-radius: var(--block-title-radius);
33
+ background: var(--block-title-background-fill);
34
+ padding: var(--block-title-padding);
35
+ color: var(--block-title-text-color);
36
+ font-weight: var(--block-title-text-weight);
37
+ font-size: var(--block-title-text-size);
38
+ line-height: var(--line-sm);
39
+ }
40
+
41
+ .hide {
42
+ margin: 0;
43
+ height: 0;
44
+ }
45
+ </style>
_frontend_code/atoms/src/Empty.svelte ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let size: "small" | "large" = "small";
3
+ export let unpadded_box = false;
4
+
5
+ let el: HTMLDivElement;
6
+ $: parent_height = compare_el_to_parent(el);
7
+
8
+ function compare_el_to_parent(el: HTMLDivElement): boolean {
9
+ if (!el) return false;
10
+
11
+ const { height: el_height } = el.getBoundingClientRect();
12
+ const { height: parent_height } =
13
+ el.parentElement?.getBoundingClientRect() || { height: el_height };
14
+
15
+ return el_height > parent_height + 2;
16
+ }
17
+ </script>
18
+
19
+ <div
20
+ class="empty"
21
+ class:small={size === "small"}
22
+ class:large={size === "large"}
23
+ class:unpadded_box
24
+ bind:this={el}
25
+ class:small_parent={parent_height}
26
+ aria-label="Empty value"
27
+ >
28
+ <div class="icon">
29
+ <slot />
30
+ </div>
31
+ </div>
32
+
33
+ <style>
34
+ .empty {
35
+ display: flex;
36
+ justify-content: center;
37
+ align-items: center;
38
+ margin-top: calc(0px - var(--size-6));
39
+ height: var(--size-full);
40
+ }
41
+
42
+ .icon {
43
+ opacity: 0.5;
44
+ height: var(--size-5);
45
+ color: var(--body-text-color);
46
+ }
47
+
48
+ .small {
49
+ min-height: calc(var(--size-32) - 20px);
50
+ }
51
+
52
+ .large {
53
+ min-height: calc(var(--size-64) - 20px);
54
+ }
55
+
56
+ .unpadded_box {
57
+ margin-top: 0;
58
+ }
59
+
60
+ .small_parent {
61
+ min-height: 100% !important;
62
+ }
63
+ </style>