yufan commited on
Commit
aeee123
·
verified ·
1 Parent(s): 756f65a

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 +15 -0
  3. CHANGELOG.md +0 -0
  4. README.md +3 -9
  5. __init__.py +117 -0
  6. __pycache__/__init__.cpython-311.pyc +0 -0
  7. __pycache__/analytics.cpython-311.pyc +0 -0
  8. __pycache__/blocks.cpython-311.pyc +3 -0
  9. __pycache__/blocks_events.cpython-311.pyc +0 -0
  10. __pycache__/chat_interface.cpython-311.pyc +0 -0
  11. __pycache__/component_meta.cpython-311.pyc +0 -0
  12. __pycache__/context.cpython-311.pyc +0 -0
  13. __pycache__/data_classes.cpython-311.pyc +0 -0
  14. __pycache__/events.cpython-311.pyc +0 -0
  15. __pycache__/exceptions.cpython-311.pyc +0 -0
  16. __pycache__/external.cpython-311.pyc +0 -0
  17. __pycache__/external_utils.cpython-311.pyc +0 -0
  18. __pycache__/flagging.cpython-311.pyc +0 -0
  19. __pycache__/helpers.cpython-311.pyc +0 -0
  20. __pycache__/http_server.cpython-311.pyc +0 -0
  21. __pycache__/image_utils.cpython-311.pyc +0 -0
  22. __pycache__/interface.cpython-311.pyc +0 -0
  23. __pycache__/ipython_ext.cpython-311.pyc +0 -0
  24. __pycache__/monitoring_dashboard.cpython-311.pyc +0 -0
  25. __pycache__/networking.cpython-311.pyc +0 -0
  26. __pycache__/node_server.cpython-311.pyc +0 -0
  27. __pycache__/oauth.cpython-311.pyc +0 -0
  28. __pycache__/pipelines.cpython-311.pyc +0 -0
  29. __pycache__/pipelines_utils.cpython-311.pyc +0 -0
  30. __pycache__/processing_utils.cpython-311.pyc +0 -0
  31. __pycache__/queueing.cpython-311.pyc +0 -0
  32. __pycache__/ranged_response.cpython-311.pyc +0 -0
  33. __pycache__/renderable.cpython-311.pyc +0 -0
  34. __pycache__/route_utils.cpython-311.pyc +0 -0
  35. __pycache__/routes.cpython-311.pyc +0 -0
  36. __pycache__/server_messages.cpython-311.pyc +0 -0
  37. __pycache__/state_holder.cpython-311.pyc +0 -0
  38. __pycache__/strings.cpython-311.pyc +0 -0
  39. __pycache__/templates.cpython-311.pyc +0 -0
  40. __pycache__/tunneling.cpython-311.pyc +0 -0
  41. __pycache__/utils.cpython-311.pyc +0 -0
  42. __pycache__/wasm_utils.cpython-311.pyc +0 -0
  43. _frontend_code/accordion/Index.svelte +31 -0
  44. _frontend_code/accordion/package.json +34 -0
  45. _frontend_code/accordion/shared/Accordion.svelte +35 -0
  46. _frontend_code/annotatedimage/Index.svelte +295 -0
  47. _frontend_code/annotatedimage/package.json +38 -0
  48. _frontend_code/atoms/package.json +33 -0
  49. _frontend_code/atoms/src/Block.svelte +107 -0
  50. _frontend_code/atoms/src/BlockLabel.svelte +73 -0
.dockerignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ templates/frontend
2
+ templates/frontend/**/*
.gitattributes CHANGED
@@ -33,3 +33,18 @@ 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
+ __pycache__/blocks.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
37
+ frpc_linux_amd64_v0.3 filter=lfs diff=lfs merge=lfs -text
38
+ templates/frontend/assets/Canvas3D-DOa1DZdS.js.map filter=lfs diff=lfs merge=lfs -text
39
+ templates/frontend/static/fonts/Source[[:space:]]Sans[[:space:]]Pro/SourceSansPro-Bold.woff2 filter=lfs diff=lfs merge=lfs -text
40
+ templates/frontend/static/fonts/Source[[:space:]]Sans[[:space:]]Pro/SourceSansPro-Regular.woff2 filter=lfs diff=lfs merge=lfs -text
41
+ templates/frontend/static/img/Duck.glb filter=lfs diff=lfs merge=lfs -text
42
+ templates/node/build/client/_app/immutable/chunks/2.BS1fgMUm.js.br filter=lfs diff=lfs merge=lfs -text
43
+ templates/node/build/client/_app/immutable/chunks/Canvas3D.WZNhCk7S.js.br filter=lfs diff=lfs merge=lfs -text
44
+ templates/node/build/client/_app/immutable/chunks/Index.DMrntMgy.js.br filter=lfs diff=lfs merge=lfs -text
45
+ templates/node/build/client/_app/immutable/chunks/Index.UTvV8BW1.js.br filter=lfs diff=lfs merge=lfs -text
46
+ templates/node/build/client/_app/immutable/chunks/PlotlyPlot.DVKAk09u.js.br filter=lfs diff=lfs merge=lfs -text
47
+ templates/node/build/client/_app/immutable/chunks/hls.CFPBCiRi.js.br filter=lfs diff=lfs merge=lfs -text
48
+ templates/node/build/client/_app/immutable/chunks/vega-embed.module.D7e2uyLa.js.br filter=lfs diff=lfs merge=lfs -text
49
+ templates/node/build/server/chunks/Canvas3D-BIK03foZ.js.map filter=lfs diff=lfs merge=lfs -text
50
+ templates/node/build/server/chunks/PlotlyPlot-BO4zgLFc.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: Podcast For Fun
3
- emoji: 👁
4
- colorFrom: gray
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 5.22.0
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: podcast_for_fun
3
+ app_file: /msn/shares/UDC/RnR/RecallFoundation_Models/Innovation/PodCastLLM/inference.py
 
 
4
  sdk: gradio
5
+ sdk_version: 5.21.0
 
 
6
  ---
 
 
__init__.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ChatMessage,
20
+ Checkbox,
21
+ CheckboxGroup,
22
+ Checkboxgroup,
23
+ ClearButton,
24
+ Code,
25
+ ColorPicker,
26
+ DataFrame,
27
+ Dataframe,
28
+ Dataset,
29
+ DateTime,
30
+ DownloadButton,
31
+ Dropdown,
32
+ DuplicateButton,
33
+ File,
34
+ FileExplorer,
35
+ Gallery,
36
+ Highlight,
37
+ HighlightedText,
38
+ Highlightedtext,
39
+ Image,
40
+ ImageEditor,
41
+ Json,
42
+ Label,
43
+ LinePlot,
44
+ LoginButton,
45
+ Markdown,
46
+ MessageDict,
47
+ Model3D,
48
+ MultimodalTextbox,
49
+ Number,
50
+ ParamViewer,
51
+ Plot,
52
+ Radio,
53
+ ScatterPlot,
54
+ Slider,
55
+ State,
56
+ Text,
57
+ Textbox,
58
+ Timer,
59
+ UploadButton,
60
+ Video,
61
+ component,
62
+ )
63
+ from gradio.components.audio import WaveformOptions
64
+ from gradio.components.image_editor import Brush, Eraser
65
+ from gradio.data_classes import FileData
66
+ from gradio.events import (
67
+ DeletedFileData,
68
+ EventData,
69
+ KeyUpData,
70
+ LikeData,
71
+ RetryData,
72
+ SelectData,
73
+ UndoData,
74
+ on,
75
+ )
76
+ from gradio.exceptions import Error
77
+ from gradio.external import load
78
+ from gradio.flagging import (
79
+ CSVLogger,
80
+ FlaggingCallback,
81
+ SimpleCSVLogger,
82
+ )
83
+ from gradio.helpers import (
84
+ Info,
85
+ Progress,
86
+ Warning,
87
+ skip,
88
+ update,
89
+ )
90
+ from gradio.helpers import create_examples as Examples # noqa: N812
91
+ from gradio.interface import Interface, TabbedInterface, close_all
92
+ from gradio.layouts import Accordion, Column, Group, Row, Tab, TabItem, Tabs
93
+ from gradio.oauth import OAuthProfile, OAuthToken
94
+ from gradio.renderable import render
95
+ from gradio.routes import Request, mount_gradio_app
96
+ from gradio.templates import (
97
+ Files,
98
+ ImageMask,
99
+ List,
100
+ Matrix,
101
+ Mic,
102
+ Microphone,
103
+ Numpy,
104
+ Paint,
105
+ PlayableVideo,
106
+ Sketchpad,
107
+ TextArea,
108
+ )
109
+ from gradio.themes import Base as Theme
110
+ from gradio.utils import NO_RELOAD, FileSize, get_package_version, set_static_paths
111
+ from gradio.wasm_utils import IS_WASM
112
+
113
+ if not IS_WASM:
114
+ from gradio.cli import deploy
115
+ from gradio.ipython_ext import load_ipython_extension
116
+
117
+ __version__ = get_package_version()
__pycache__/__init__.cpython-311.pyc ADDED
Binary file (4.6 kB). View file
 
__pycache__/analytics.cpython-311.pyc ADDED
Binary file (12 kB). View file
 
__pycache__/blocks.cpython-311.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ea00a84ca52982a5f7de49e47ab1dd9d1495dac624ed56f65e530157822942b
3
+ size 146042
__pycache__/blocks_events.cpython-311.pyc ADDED
Binary file (1.96 kB). View file
 
__pycache__/chat_interface.cpython-311.pyc ADDED
Binary file (41.3 kB). View file
 
__pycache__/component_meta.cpython-311.pyc ADDED
Binary file (14.9 kB). View file
 
__pycache__/context.cpython-311.pyc ADDED
Binary file (3.56 kB). View file
 
__pycache__/data_classes.cpython-311.pyc ADDED
Binary file (19 kB). View file
 
__pycache__/events.cpython-311.pyc ADDED
Binary file (46.7 kB). View file
 
__pycache__/exceptions.cpython-311.pyc ADDED
Binary file (5.62 kB). View file
 
__pycache__/external.cpython-311.pyc ADDED
Binary file (23.7 kB). View file
 
__pycache__/external_utils.cpython-311.pyc ADDED
Binary file (14.9 kB). View file
 
__pycache__/flagging.cpython-311.pyc ADDED
Binary file (20.9 kB). View file
 
__pycache__/helpers.cpython-311.pyc ADDED
Binary file (60.4 kB). View file
 
__pycache__/http_server.cpython-311.pyc ADDED
Binary file (8.27 kB). View file
 
__pycache__/image_utils.cpython-311.pyc ADDED
Binary file (7.92 kB). View file
 
__pycache__/interface.cpython-311.pyc ADDED
Binary file (50.1 kB). View file
 
__pycache__/ipython_ext.cpython-311.pyc ADDED
Binary file (5.09 kB). View file
 
__pycache__/monitoring_dashboard.cpython-311.pyc ADDED
Binary file (5.5 kB). View file
 
__pycache__/networking.cpython-311.pyc ADDED
Binary file (3.58 kB). View file
 
__pycache__/node_server.cpython-311.pyc ADDED
Binary file (8.44 kB). View file
 
__pycache__/oauth.cpython-311.pyc ADDED
Binary file (16.2 kB). View file
 
__pycache__/pipelines.cpython-311.pyc ADDED
Binary file (5.36 kB). View file
 
__pycache__/pipelines_utils.cpython-311.pyc ADDED
Binary file (42 kB). View file
 
__pycache__/processing_utils.cpython-311.pyc ADDED
Binary file (62.2 kB). View file
 
__pycache__/queueing.cpython-311.pyc ADDED
Binary file (38.6 kB). View file
 
__pycache__/ranged_response.cpython-311.pyc ADDED
Binary file (9.92 kB). View file
 
__pycache__/renderable.cpython-311.pyc ADDED
Binary file (9.3 kB). View file
 
__pycache__/route_utils.cpython-311.pyc ADDED
Binary file (49.9 kB). View file
 
__pycache__/routes.cpython-311.pyc ADDED
Binary file (88.1 kB). View file
 
__pycache__/server_messages.cpython-311.pyc ADDED
Binary file (5.24 kB). View file
 
__pycache__/state_holder.cpython-311.pyc ADDED
Binary file (7.31 kB). View file
 
__pycache__/strings.cpython-311.pyc ADDED
Binary file (3.45 kB). View file
 
__pycache__/templates.cpython-311.pyc ADDED
Binary file (19.9 kB). View file
 
__pycache__/tunneling.cpython-311.pyc ADDED
Binary file (10.2 kB). View file
 
__pycache__/utils.cpython-311.pyc ADDED
Binary file (84.5 kB). View file
 
__pycache__/wasm_utils.cpython-311.pyc ADDED
Binary file (2.25 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,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/accordion",
3
+ "version": "0.4.1",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "main_changeset": true,
9
+ "dependencies": {
10
+ "@gradio/atoms": "workspace:^",
11
+ "@gradio/column": "workspace:^",
12
+ "@gradio/statustracker": "workspace:^",
13
+ "@gradio/utils": "workspace:^"
14
+ },
15
+ "peerDependencies": {
16
+ "svelte": "^4.0.0"
17
+ },
18
+ "devDependencies": {
19
+ "@gradio/preview": "workspace:^"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "gradio": "./Index.svelte",
24
+ "svelte": "./dist/Index.svelte",
25
+ "types": "./dist/Index.svelte.d.ts"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/gradio-app/gradio.git",
32
+ "directory": "js/accordion"
33
+ }
34
+ }
_frontend_code/accordion/shared/Accordion.svelte ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ color: var(--accordion-text-color);
27
+ }
28
+ .label-wrap.open {
29
+ margin-bottom: var(--size-2);
30
+ }
31
+
32
+ .icon {
33
+ transition: 150ms;
34
+ }
35
+ </style>
_frontend_code/annotatedimage/Index.svelte ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio, SelectData } from "@gradio/utils";
3
+
4
+ import { onMount } from "svelte";
5
+ import {
6
+ Block,
7
+ BlockLabel,
8
+ Empty,
9
+ IconButton,
10
+ IconButtonWrapper
11
+ } from "@gradio/atoms";
12
+ import { Image, Maximize, Minimize } from "@gradio/icons";
13
+ import { StatusTracker } from "@gradio/statustracker";
14
+ import type { LoadingStatus } from "@gradio/statustracker";
15
+ import { type FileData } from "@gradio/client";
16
+ import { resolve_wasm_src } from "@gradio/wasm/svelte";
17
+
18
+ export let elem_id = "";
19
+ export let elem_classes: string[] = [];
20
+ export let visible = true;
21
+ export let value: {
22
+ image: FileData;
23
+ annotations: { image: FileData; label: string }[] | [];
24
+ } | null = null;
25
+ let old_value: {
26
+ image: FileData;
27
+ annotations: { image: FileData; label: string }[] | [];
28
+ } | null = null;
29
+ let _value: {
30
+ image: FileData;
31
+ annotations: { image: FileData; label: string }[];
32
+ } | null = null;
33
+ export let gradio: Gradio<{
34
+ change: undefined;
35
+ select: SelectData;
36
+ }>;
37
+ export let label = gradio.i18n("annotated_image.annotated_image");
38
+ export let show_label = true;
39
+ export let show_legend = true;
40
+ export let height: number | undefined;
41
+ export let width: number | undefined;
42
+ export let color_map: Record<string, string>;
43
+ export let container = true;
44
+ export let scale: number | null = null;
45
+ export let min_width: number | undefined = undefined;
46
+ let active: string | null = null;
47
+ export let loading_status: LoadingStatus;
48
+ export let show_fullscreen_button = true;
49
+
50
+ let is_full_screen = false;
51
+ let image_container: HTMLElement;
52
+
53
+ onMount(() => {
54
+ document.addEventListener("fullscreenchange", () => {
55
+ is_full_screen = !!document.fullscreenElement;
56
+ });
57
+ });
58
+
59
+ const toggle_full_screen = async (): Promise<void> => {
60
+ if (!is_full_screen) {
61
+ await image_container.requestFullscreen();
62
+ } else {
63
+ await document.exitFullscreen();
64
+ }
65
+ };
66
+
67
+ // `value` can be updated before the Promises from `resolve_wasm_src` are resolved.
68
+ // In such a case, the resolved values for the old `value` have to be discarded,
69
+ // This variable `latest_promise` is used to pick up only the values resolved for the latest `value`.
70
+ let latest_promise: Promise<unknown> | null = null;
71
+ $: {
72
+ if (value !== old_value) {
73
+ old_value = value;
74
+ gradio.dispatch("change");
75
+ }
76
+ if (value) {
77
+ const normalized_value = {
78
+ image: value.image as FileData,
79
+ annotations: value.annotations.map((ann) => ({
80
+ image: ann.image as FileData,
81
+ label: ann.label
82
+ }))
83
+ };
84
+ _value = normalized_value;
85
+
86
+ // In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed values immediately
87
+ // without waiting for `resolve_wasm_src()` to resolve.
88
+ // If it waits, a blank image is displayed until the async task finishes
89
+ // and it leads to undesirable flickering.
90
+ // So set `_value` immediately above, and update it with the resolved values below later.
91
+ const image_url_promise = resolve_wasm_src(normalized_value.image.url);
92
+ const annotation_urls_promise = Promise.all(
93
+ normalized_value.annotations.map((ann) =>
94
+ resolve_wasm_src(ann.image.url)
95
+ )
96
+ );
97
+ const current_promise = Promise.all([
98
+ image_url_promise,
99
+ annotation_urls_promise
100
+ ]);
101
+ latest_promise = current_promise;
102
+ current_promise.then(([image_url, annotation_urls]) => {
103
+ if (latest_promise !== current_promise) {
104
+ return;
105
+ }
106
+ const async_resolved_value: typeof _value = {
107
+ image: {
108
+ ...normalized_value.image,
109
+ url: image_url ?? undefined
110
+ },
111
+ annotations: normalized_value.annotations.map((ann, i) => ({
112
+ ...ann,
113
+ image: {
114
+ ...ann.image,
115
+ url: annotation_urls[i] ?? undefined
116
+ }
117
+ }))
118
+ };
119
+ _value = async_resolved_value;
120
+ });
121
+ } else {
122
+ _value = null;
123
+ }
124
+ }
125
+ function handle_mouseover(_label: string): void {
126
+ active = _label;
127
+ }
128
+ function handle_mouseout(): void {
129
+ active = null;
130
+ }
131
+
132
+ function handle_click(i: number, value: string): void {
133
+ gradio.dispatch("select", {
134
+ value: label,
135
+ index: i
136
+ });
137
+ }
138
+ </script>
139
+
140
+ <Block
141
+ {visible}
142
+ {elem_id}
143
+ {elem_classes}
144
+ padding={false}
145
+ {height}
146
+ {width}
147
+ allow_overflow={false}
148
+ {container}
149
+ {scale}
150
+ {min_width}
151
+ >
152
+ <StatusTracker
153
+ autoscroll={gradio.autoscroll}
154
+ i18n={gradio.i18n}
155
+ {...loading_status}
156
+ />
157
+ <BlockLabel
158
+ {show_label}
159
+ Icon={Image}
160
+ label={label || gradio.i18n("image.image")}
161
+ />
162
+
163
+ <div class="container">
164
+ {#if _value == null}
165
+ <Empty size="large" unpadded_box={true}><Image /></Empty>
166
+ {:else}
167
+ <div class="image-container" bind:this={image_container}>
168
+ <IconButtonWrapper>
169
+ {#if !is_full_screen && show_fullscreen_button}
170
+ <IconButton
171
+ Icon={Maximize}
172
+ label="View in full screen"
173
+ on:click={toggle_full_screen}
174
+ />
175
+ {/if}
176
+
177
+ {#if is_full_screen}
178
+ <IconButton
179
+ Icon={Minimize}
180
+ label="Exit full screen"
181
+ on:click={toggle_full_screen}
182
+ />
183
+ {/if}
184
+ </IconButtonWrapper>
185
+
186
+ <img
187
+ class="base-image"
188
+ class:fit-height={height && !is_full_screen}
189
+ src={_value ? _value.image.url : null}
190
+ alt="the base file that is annotated"
191
+ />
192
+ {#each _value ? _value?.annotations : [] as ann, i}
193
+ <img
194
+ alt="segmentation mask identifying {label} within the uploaded file"
195
+ class="mask fit-height"
196
+ class:fit-height={!is_full_screen}
197
+ class:active={active == ann.label}
198
+ class:inactive={active != ann.label && active != null}
199
+ src={ann.image.url}
200
+ style={color_map && ann.label in color_map
201
+ ? null
202
+ : `filter: hue-rotate(${Math.round(
203
+ (i * 360) / _value?.annotations.length
204
+ )}deg);`}
205
+ />
206
+ {/each}
207
+ </div>
208
+ {#if show_legend && _value}
209
+ <div class="legend">
210
+ {#each _value.annotations as ann, i}
211
+ <button
212
+ class="legend-item"
213
+ style="background-color: {color_map && ann.label in color_map
214
+ ? color_map[ann.label] + '88'
215
+ : `hsla(${Math.round(
216
+ (i * 360) / _value.annotations.length
217
+ )}, 100%, 50%, 0.3)`}"
218
+ on:mouseover={() => handle_mouseover(ann.label)}
219
+ on:focus={() => handle_mouseover(ann.label)}
220
+ on:mouseout={() => handle_mouseout()}
221
+ on:blur={() => handle_mouseout()}
222
+ on:click={() => handle_click(i, ann.label)}
223
+ >
224
+ {ann.label}
225
+ </button>
226
+ {/each}
227
+ </div>
228
+ {/if}
229
+ {/if}
230
+ </div>
231
+ </Block>
232
+
233
+ <style>
234
+ .base-image {
235
+ display: block;
236
+ width: 100%;
237
+ height: auto;
238
+ }
239
+ .container {
240
+ display: flex;
241
+ position: relative;
242
+ flex-direction: column;
243
+ justify-content: center;
244
+ align-items: center;
245
+ width: var(--size-full);
246
+ height: var(--size-full);
247
+ }
248
+ .image-container {
249
+ position: relative;
250
+ top: 0;
251
+ left: 0;
252
+ flex-grow: 1;
253
+ width: 100%;
254
+ overflow: hidden;
255
+ }
256
+ .fit-height {
257
+ top: 0;
258
+ left: 0;
259
+ width: 100%;
260
+ height: 100%;
261
+ object-fit: contain;
262
+ }
263
+ .mask {
264
+ opacity: 0.85;
265
+ transition: all 0.2s ease-in-out;
266
+ position: absolute;
267
+ }
268
+ .image-container:hover .mask {
269
+ opacity: 0.3;
270
+ }
271
+ .mask.active {
272
+ opacity: 1;
273
+ }
274
+ .mask.inactive {
275
+ opacity: 0;
276
+ }
277
+ .legend {
278
+ display: flex;
279
+ flex-direction: row;
280
+ flex-wrap: wrap;
281
+ align-content: center;
282
+ justify-content: center;
283
+ align-items: center;
284
+ gap: var(--spacing-sm);
285
+ padding: var(--spacing-sm);
286
+ }
287
+ .legend-item {
288
+ display: flex;
289
+ flex-direction: row;
290
+ align-items: center;
291
+ cursor: pointer;
292
+ border-radius: var(--radius-sm);
293
+ padding: var(--spacing-sm);
294
+ }
295
+ </style>
_frontend_code/annotatedimage/package.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/annotatedimage",
3
+ "version": "0.8.2",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "exports": {
11
+ ".": {
12
+ "gradio": "./Index.svelte",
13
+ "svelte": "./dist/Index.svelte",
14
+ "types": "./dist/Index.svelte.d.ts"
15
+ },
16
+ "./package.json": "./package.json"
17
+ },
18
+ "devDependencies": {
19
+ "@gradio/preview": "workspace:^"
20
+ },
21
+ "peerDependencies": {
22
+ "svelte": "^4.0.0"
23
+ },
24
+ "dependencies": {
25
+ "@gradio/atoms": "workspace:^",
26
+ "@gradio/icons": "workspace:^",
27
+ "@gradio/statustracker": "workspace:^",
28
+ "@gradio/upload": "workspace:^",
29
+ "@gradio/utils": "workspace:^",
30
+ "@gradio/client": "workspace:^",
31
+ "@gradio/wasm": "workspace:^"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/gradio-app/gradio.git",
36
+ "directory": "js/annotatedimage"
37
+ }
38
+ }
_frontend_code/atoms/package.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/atoms",
3
+ "version": "0.9.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "dependencies": {
10
+ "@gradio/icons": "workspace:^",
11
+ "@gradio/utils": "workspace:^"
12
+ },
13
+ "peerDependencies": {
14
+ "svelte": "^4.0.0"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "gradio": "./src/index.ts",
19
+ "svelte": "./dist/src/index.js",
20
+ "types": "./dist/src/index.d.ts"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "main_changeset": true,
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/gradio-app/gradio.git",
28
+ "directory": "js/atoms"
29
+ },
30
+ "scripts": {
31
+ "sv-pkg": "svelte-package --input=. --cwd=../../.config/"
32
+ }
33
+ }
_frontend_code/atoms/src/Block.svelte ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let height: number | string | undefined = undefined;
3
+ export let min_height: number | string | undefined = undefined;
4
+ export let max_height: number | string | undefined = undefined;
5
+ export let width: number | string | undefined = undefined;
6
+ export let elem_id = "";
7
+ export let elem_classes: string[] = [];
8
+ export let variant: "solid" | "dashed" | "none" = "solid";
9
+ export let border_mode: "base" | "focus" | "contrast" = "base";
10
+ export let padding = true;
11
+ export let type: "normal" | "fieldset" = "normal";
12
+ export let test_id: string | undefined = undefined;
13
+ export let explicit_call = false;
14
+ export let container = true;
15
+ export let visible = true;
16
+ export let allow_overflow = true;
17
+ export let overflow_behavior: "visible" | "auto" = "auto";
18
+ export let scale: number | null = null;
19
+ export let min_width = 0;
20
+ export let flex = false;
21
+
22
+ let tag = type === "fieldset" ? "fieldset" : "div";
23
+
24
+ const get_dimension = (
25
+ dimension_value: string | number | undefined
26
+ ): string | undefined => {
27
+ if (dimension_value === undefined) {
28
+ return undefined;
29
+ }
30
+ if (typeof dimension_value === "number") {
31
+ return dimension_value + "px";
32
+ } else if (typeof dimension_value === "string") {
33
+ return dimension_value;
34
+ }
35
+ };
36
+ </script>
37
+
38
+ <svelte:element
39
+ this={tag}
40
+ data-testid={test_id}
41
+ id={elem_id}
42
+ class:hidden={visible === false}
43
+ class="block {elem_classes.join(' ')}"
44
+ class:padded={padding}
45
+ class:flex
46
+ class:border_focus={border_mode === "focus"}
47
+ class:border_contrast={border_mode === "contrast"}
48
+ class:hide-container={!explicit_call && !container}
49
+ style:height={get_dimension(height)}
50
+ style:min-height={get_dimension(min_height)}
51
+ style:max-height={get_dimension(max_height)}
52
+ style:width={typeof width === "number"
53
+ ? `calc(min(${width}px, 100%))`
54
+ : get_dimension(width)}
55
+ style:border-style={variant}
56
+ style:overflow={allow_overflow ? overflow_behavior : "hidden"}
57
+ style:flex-grow={scale}
58
+ style:min-width={`calc(min(${min_width}px, 100%))`}
59
+ style:border-width="var(--block-border-width)"
60
+ >
61
+ <slot />
62
+ </svelte:element>
63
+
64
+ <style>
65
+ .block {
66
+ position: relative;
67
+ margin: 0;
68
+ box-shadow: var(--block-shadow);
69
+ border-width: var(--block-border-width);
70
+ border-color: var(--block-border-color);
71
+ border-radius: var(--block-radius);
72
+ background: var(--block-background-fill);
73
+ width: 100%;
74
+ line-height: var(--line-sm);
75
+ margin-left: auto;
76
+ margin-right: auto;
77
+ }
78
+
79
+ .block.border_focus {
80
+ border-color: var(--color-accent);
81
+ }
82
+
83
+ .block.border_contrast {
84
+ border-color: var(--body-text-color);
85
+ }
86
+
87
+ .padded {
88
+ padding: var(--block-padding);
89
+ }
90
+
91
+ .hidden {
92
+ display: none;
93
+ }
94
+
95
+ .flex {
96
+ display: flex;
97
+ flex-direction: column;
98
+ }
99
+ .hide-container {
100
+ margin: 0;
101
+ box-shadow: none;
102
+ --block-border-width: 0;
103
+ background: transparent;
104
+ padding: 0;
105
+ overflow: visible;
106
+ }
107
+ </style>
_frontend_code/atoms/src/BlockLabel.svelte ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
+ var(--block-label-border-color);
31
+ border-top: none;
32
+ border-left: none;
33
+ border-radius: var(--block-label-radius);
34
+ background: var(--block-label-background-fill);
35
+ padding: var(--block-label-padding);
36
+ pointer-events: none;
37
+ color: var(--block-label-text-color);
38
+ font-weight: var(--block-label-text-weight);
39
+ font-size: var(--block-label-text-size);
40
+ line-height: var(--line-sm);
41
+ }
42
+ :global(.gr-group) label {
43
+ border-top-left-radius: 0;
44
+ }
45
+
46
+ label.float {
47
+ position: absolute;
48
+ top: var(--block-label-margin);
49
+ left: var(--block-label-margin);
50
+ }
51
+ label:not(.float) {
52
+ position: static;
53
+ margin-top: var(--block-label-margin);
54
+ margin-left: var(--block-label-margin);
55
+ }
56
+
57
+ .hide {
58
+ height: 0;
59
+ }
60
+
61
+ span {
62
+ opacity: 0.8;
63
+ margin-right: var(--size-2);
64
+ width: calc(var(--block-label-text-size) - 1px);
65
+ height: calc(var(--block-label-text-size) - 1px);
66
+ }
67
+ .hide-label {
68
+ box-shadow: none;
69
+ border-width: 0;
70
+ background: transparent;
71
+ overflow: visible;
72
+ }
73
+ </style>