@webwriter/deep-learning-model 0.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.github/workflows/main.yml +8 -0
  2. package/LICENSE +7 -0
  3. package/README.md +290 -0
  4. package/components/dataset-input/dataset-input.styles.ts +20 -0
  5. package/components/dataset-input/dataset-input.ts +196 -0
  6. package/components/inference-fields/class-input.ts +83 -0
  7. package/components/inference-fields/class-output.ts +62 -0
  8. package/components/inference-fields/image-input.ts +182 -0
  9. package/components/inference-fields/image.ts +82 -0
  10. package/components/inference-fields/inference-interfaces.ts +15 -0
  11. package/components/inference-fields/number-input.ts +62 -0
  12. package/components/inference-fields/number-output.ts +56 -0
  13. package/components/model-editor.ts +288 -0
  14. package/components/model-tests/bad-samples.ts +152 -0
  15. package/components/model-tests/loss-distribution.ts +174 -0
  16. package/components/reference-element-select.ts +105 -0
  17. package/custom-elements.json +1470 -0
  18. package/custom.d.ts +180 -0
  19. package/dist/widgets/webwriter-feature-engineering.css +444 -0
  20. package/dist/widgets/webwriter-feature-engineering.js +112763 -0
  21. package/dist/widgets/webwriter-model-designing.css +444 -0
  22. package/dist/widgets/webwriter-model-designing.js +114587 -0
  23. package/dist/widgets/webwriter-model-evaluation.css +444 -0
  24. package/dist/widgets/webwriter-model-evaluation.js +119010 -0
  25. package/dist/widgets/webwriter-model-prediction.css +444 -0
  26. package/dist/widgets/webwriter-model-prediction.js +109251 -0
  27. package/dist/widgets/webwriter-model-training.css +444 -0
  28. package/dist/widgets/webwriter-model-training.js +121465 -0
  29. package/editing-config.json +73 -0
  30. package/icon.svg +1 -0
  31. package/lib/dataset/class.ts +155 -0
  32. package/lib/dataset/dataset.ts +293 -0
  33. package/lib/dataset/feature.ts +110 -0
  34. package/lib/dataset/image.ts +312 -0
  35. package/lib/dataset/linear.ts +120 -0
  36. package/lib/layers/activation.ts +48 -0
  37. package/lib/layers/add.ts +50 -0
  38. package/lib/layers/attention.ts +74 -0
  39. package/lib/layers/concat.ts +50 -0
  40. package/lib/layers/conv.ts +83 -0
  41. package/lib/layers/dropout.ts +44 -0
  42. package/lib/layers/fcl.ts +66 -0
  43. package/lib/layers/flatten.ts +48 -0
  44. package/lib/layers/index.ts +770 -0
  45. package/lib/layers/input.ts +55 -0
  46. package/lib/layers/noise.ts +43 -0
  47. package/lib/layers/output.ts +64 -0
  48. package/lib/layers/reshape.ts +76 -0
  49. package/lib/layers/transposeconv.ts +90 -0
  50. package/lib/tflib.ts +10 -0
  51. package/lit-localize.json +47 -0
  52. package/localization/ar.xlf +553 -0
  53. package/localization/bg.xlf +552 -0
  54. package/localization/cs.xlf +553 -0
  55. package/localization/da.xlf +552 -0
  56. package/localization/de.xlf +552 -0
  57. package/localization/el.xlf +554 -0
  58. package/localization/es.xlf +553 -0
  59. package/localization/et.xlf +553 -0
  60. package/localization/fi.xlf +552 -0
  61. package/localization/fr.xlf +553 -0
  62. package/localization/generated/ar.ts +159 -0
  63. package/localization/generated/bg.ts +158 -0
  64. package/localization/generated/cs.ts +159 -0
  65. package/localization/generated/da.ts +158 -0
  66. package/localization/generated/de.ts +158 -0
  67. package/localization/generated/el.ts +160 -0
  68. package/localization/generated/es.ts +159 -0
  69. package/localization/generated/et.ts +159 -0
  70. package/localization/generated/fi.ts +158 -0
  71. package/localization/generated/fr.ts +159 -0
  72. package/localization/generated/hu.ts +158 -0
  73. package/localization/generated/id.ts +159 -0
  74. package/localization/generated/index.js +3 -0
  75. package/localization/generated/it.ts +159 -0
  76. package/localization/generated/ja.ts +158 -0
  77. package/localization/generated/ko.ts +158 -0
  78. package/localization/generated/locale-codes.js +83 -0
  79. package/localization/generated/lt.ts +158 -0
  80. package/localization/generated/lv.ts +158 -0
  81. package/localization/generated/nb.ts +158 -0
  82. package/localization/generated/nl.ts +158 -0
  83. package/localization/generated/pl.ts +159 -0
  84. package/localization/generated/pt-BR.ts +159 -0
  85. package/localization/generated/pt-PT.ts +159 -0
  86. package/localization/generated/ro.ts +159 -0
  87. package/localization/generated/ru.ts +159 -0
  88. package/localization/generated/sk.ts +159 -0
  89. package/localization/generated/sl.ts +159 -0
  90. package/localization/generated/sv.ts +158 -0
  91. package/localization/generated/tr.ts +158 -0
  92. package/localization/generated/uk.ts +158 -0
  93. package/localization/generated/zh-hans.ts +141 -0
  94. package/localization/generated/zh-hant.ts +141 -0
  95. package/localization/hu.xlf +552 -0
  96. package/localization/id.xlf +553 -0
  97. package/localization/it.xlf +553 -0
  98. package/localization/ja.xlf +552 -0
  99. package/localization/ko.xlf +552 -0
  100. package/localization/lt.xlf +552 -0
  101. package/localization/lv.xlf +552 -0
  102. package/localization/nb.xlf +552 -0
  103. package/localization/nl.xlf +552 -0
  104. package/localization/pkg/ar.xliff +7 -0
  105. package/localization/pkg/bg.xliff +7 -0
  106. package/localization/pkg/cs.xliff +7 -0
  107. package/localization/pkg/da.xliff +7 -0
  108. package/localization/pkg/de.xliff +7 -0
  109. package/localization/pkg/el.xliff +7 -0
  110. package/localization/pkg/es.xliff +7 -0
  111. package/localization/pkg/et.xliff +7 -0
  112. package/localization/pkg/fi.xliff +7 -0
  113. package/localization/pkg/fr.xliff +7 -0
  114. package/localization/pkg/hu.xliff +7 -0
  115. package/localization/pkg/id.xliff +7 -0
  116. package/localization/pkg/it.xliff +7 -0
  117. package/localization/pkg/ja.xliff +7 -0
  118. package/localization/pkg/ko.xliff +7 -0
  119. package/localization/pkg/lt.xliff +7 -0
  120. package/localization/pkg/lv.xliff +7 -0
  121. package/localization/pkg/nb.xliff +7 -0
  122. package/localization/pkg/nl.xliff +7 -0
  123. package/localization/pkg/pl.xliff +7 -0
  124. package/localization/pkg/pt-BR.xliff +7 -0
  125. package/localization/pkg/pt-PT.xliff +7 -0
  126. package/localization/pkg/ro.xliff +7 -0
  127. package/localization/pkg/ru.xliff +7 -0
  128. package/localization/pkg/sk.xliff +7 -0
  129. package/localization/pkg/sl.xliff +7 -0
  130. package/localization/pkg/sv.xliff +7 -0
  131. package/localization/pkg/tr.xliff +7 -0
  132. package/localization/pkg/uk.xliff +7 -0
  133. package/localization/pkg/zh-hans.xliff +7 -0
  134. package/localization/pkg/zh-hant.xliff +7 -0
  135. package/localization/pl.xlf +553 -0
  136. package/localization/pt-BR.xlf +553 -0
  137. package/localization/pt-PT.xlf +553 -0
  138. package/localization/ro.xlf +553 -0
  139. package/localization/ru.xlf +553 -0
  140. package/localization/sk.xlf +553 -0
  141. package/localization/sl.xlf +553 -0
  142. package/localization/snippets/ar.xliff +16 -0
  143. package/localization/snippets/bg.xliff +16 -0
  144. package/localization/snippets/cs.xliff +16 -0
  145. package/localization/snippets/da.xliff +16 -0
  146. package/localization/snippets/de.xliff +16 -0
  147. package/localization/snippets/el.xliff +16 -0
  148. package/localization/snippets/es.xliff +16 -0
  149. package/localization/snippets/et.xliff +16 -0
  150. package/localization/snippets/fi.xliff +16 -0
  151. package/localization/snippets/fr.xliff +16 -0
  152. package/localization/snippets/hu.xliff +16 -0
  153. package/localization/snippets/id.xliff +16 -0
  154. package/localization/snippets/it.xliff +16 -0
  155. package/localization/snippets/ja.xliff +16 -0
  156. package/localization/snippets/ko.xliff +16 -0
  157. package/localization/snippets/lt.xliff +16 -0
  158. package/localization/snippets/lv.xliff +16 -0
  159. package/localization/snippets/nb.xliff +16 -0
  160. package/localization/snippets/nl.xliff +16 -0
  161. package/localization/snippets/pl.xliff +16 -0
  162. package/localization/snippets/pt-BR.xliff +16 -0
  163. package/localization/snippets/pt-PT.xliff +16 -0
  164. package/localization/snippets/ro.xliff +16 -0
  165. package/localization/snippets/ru.xliff +16 -0
  166. package/localization/snippets/sk.xliff +16 -0
  167. package/localization/snippets/sl.xliff +16 -0
  168. package/localization/snippets/sv.xliff +16 -0
  169. package/localization/snippets/tr.xliff +16 -0
  170. package/localization/snippets/uk.xliff +16 -0
  171. package/localization/snippets/zh-hans.xliff +16 -0
  172. package/localization/snippets/zh-hant.xliff +16 -0
  173. package/localization/sv.xlf +552 -0
  174. package/localization/tr.xlf +552 -0
  175. package/localization/uk.xlf +552 -0
  176. package/localization/zh-hans.xlf +552 -0
  177. package/localization/zh-hant.xlf +552 -0
  178. package/package.json +103 -2
  179. package/snippets/MNIST.html +21 -0
  180. package/test.json +63 -0
  181. package/tsconfig.json +8 -0
  182. package/widgets/webwriter-feature-engineering.ts +421 -0
  183. package/widgets/webwriter-model-designing.ts +323 -0
  184. package/widgets/webwriter-model-evaluation.ts +215 -0
  185. package/widgets/webwriter-model-prediction.ts +307 -0
  186. package/widgets/webwriter-model-training.ts +709 -0
@@ -0,0 +1,55 @@
1
+ import { SlSelect } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private fields: TransformedDataset;
13
+ private select: SlSelect;
14
+
15
+ constructor(fields: TransformedDataset, editor: Editor) {
16
+ super(0, 1, "Input", editor)
17
+ if (fields == null) {
18
+ let span = document.createElement("span");
19
+ span.innerText = msg("No Feature Data avaliable");
20
+ this.addTextElement("",span)
21
+ return;
22
+ }
23
+ this.fields = fields;
24
+ this.select = this.addSelect(msg("Input field"), Object.keys(this.fields.featureMaps))
25
+ this.select.disabled = editor.editMode != "edit";
26
+
27
+ let that = this;
28
+ this.select.addEventListener("sl-change", function () {
29
+ that.getNodeOutputElement("output_1").innerText = fields.featureMaps[that.select.value as string].size().join(SIZE_SEP);
30
+ that.update();
31
+ });
32
+ }
33
+ update() {
34
+ super.notifyOutputChange();
35
+ }
36
+ getState() {
37
+ let state = super.getState();
38
+ state.select = this.select.value;
39
+ state.type = "input";
40
+ return state;
41
+ }
42
+ setState(state) {
43
+ super.setState(state);
44
+ if (!this.select)
45
+ return;
46
+ this.select.value = state.select;
47
+ this.select.dispatchEvent(new Event('sl-change', { bubbles: true }))
48
+ }
49
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
50
+ return {output_1: inputs[this.select.value as string] };
51
+ }
52
+ protected getDisplayName(): string {
53
+ return msg("Input");
54
+ }
55
+ }
@@ -0,0 +1,43 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private strength: SlInput;
13
+
14
+ constructor(fields: TransformedDataset, editor: Editor) {
15
+ super(1, 1, "Noise", editor)
16
+
17
+ this.strength = this.addNumberInput(msg("Strength"), 0, 1)
18
+ this.strength.step = 0.01;
19
+ this.strength.value = "0.2";
20
+ }
21
+ update() {
22
+ this.updateInputLabels();
23
+ this.getNodeOutputElement("output_1").innerText = this.getNodeInputElement("input_1").innerText;
24
+ this.notifyOutputChange();
25
+ }
26
+ getState() {
27
+ let state = super.getState();
28
+ state.type = "noise";
29
+ state.dim = this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).map(v => parseInt(v));
30
+ state.strength = this.strength.value;
31
+ return state;
32
+ }
33
+ setState(state) {
34
+ super.setState(state);
35
+ this.strength.value = state.strength;
36
+ }
37
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
38
+ return { output_1: tf.layers.gaussianNoise({ stddev: parseFloat(this.strength.value)}).apply(inputs.input_1) as TF.SymbolicTensor };
39
+ }
40
+ protected getDisplayName(): string {
41
+ return msg("Noise");
42
+ }
43
+ }
@@ -0,0 +1,64 @@
1
+ import { SlSelect } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private fields: TransformedDataset;
13
+ private select: SlSelect;
14
+ private loss: SlSelect;
15
+
16
+ constructor(fields: TransformedDataset, editor: Editor) {
17
+ super(1, 0, "Output", editor)
18
+ if (fields == null) {
19
+ let span = document.createElement("span");
20
+ span.innerText = msg("No Feature Data avaliable");
21
+ this.addTextElement("",span)
22
+ return;
23
+ }
24
+ this.fields = fields;
25
+ this.select = this.addSelect(msg("Output"), Object.keys(this.fields.featureMaps))
26
+ this.select.disabled = editor.editMode != "edit";
27
+
28
+ this.loss = this.addSelect(msg("Loss Function"), ["BCE", "MAE", "MSE", "Huber","Difference","WL","CosDist"])
29
+ this.loss.value = "MSE";
30
+
31
+ let that = this;
32
+ this.select.addEventListener("sl-change", function () {
33
+ that.getNodeInputElement("input_1").innerText = that.fields.featureMaps[that.select.value as string].size().join(SIZE_SEP);
34
+ that.update()
35
+ });
36
+ }
37
+ update() {
38
+ if (this.fields && this.select)
39
+ this.getNodeInputElement("input_1").innerText = this.fields.featureMaps[this.select.value as string].size().join(SIZE_SEP);
40
+ super.checkInputs();
41
+ }
42
+ getState() {
43
+ let state = super.getState();
44
+ state.select = this.select.value;
45
+ state.type = "output";
46
+ state.loss = this.loss.value;
47
+ return state;
48
+ }
49
+ setState(state: Record<string, any>) {
50
+ super.setState(state);
51
+ if (!this.select || !this.loss)
52
+ return;
53
+ this.select.value = state.select;
54
+ this.loss.value = state.loss;
55
+ this.select.dispatchEvent(new Event('sl-change', { bubbles: true }))
56
+ }
57
+
58
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
59
+ return null;
60
+ }
61
+ protected getDisplayName(): string {
62
+ return msg("Output");
63
+ }
64
+ }
@@ -0,0 +1,76 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg, str } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private shapeInputs: SlInput[] = [];
13
+ private error: HTMLSpanElement;
14
+
15
+ constructor(fields: TransformedDataset, editor: Editor) {
16
+ super(1, 1, "Reshape", editor)
17
+
18
+ for (let i = 0; i < 3; i++) {
19
+ this.shapeInputs[i] = this.addNumberInput(msg(str`${(i + 1)}th dim`), 0, 9999999);
20
+ this.shapeInputs[i].value = "1";
21
+ }
22
+
23
+ this.error = document.createElement("span");
24
+ this.error.style.color="red";
25
+ this.addTextElement("", this.error);
26
+ }
27
+ update() {
28
+ this.updateInputLabels();
29
+ let inDim = 1;
30
+ this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).forEach(v => inDim *= parseInt(v));
31
+ let outDim = 1;
32
+ let outputDims = [];
33
+ for (let i = 0; i < this.shapeInputs.length; i++) {
34
+ let value = parseInt(this.shapeInputs[i].value)
35
+ if (value > 0) {
36
+ outputDims.push(parseInt(this.shapeInputs[i].value));
37
+ outDim *= value;
38
+ }
39
+ }
40
+ if (inDim != outDim) {
41
+ this.error.innerText = msg(str`Output shape invalid: ${inDim} != ${outDim}`);
42
+ } else {
43
+ this.error.innerText = "";
44
+ }
45
+ this.getNodeOutputElement("output_1").innerText = outputDims.join(SIZE_SEP)
46
+ this.notifyOutputChange();
47
+ }
48
+ valid() {
49
+ return super.valid() && this.error.innerText == "";
50
+ }
51
+ getState() {
52
+ let state = super.getState();
53
+ state.shape = this.shapeInputs.map(input => input.value)
54
+ state.type = "reshape";
55
+ return state;
56
+ }
57
+
58
+ setState(state) {
59
+ super.setState(state);
60
+ for (let i = 0; i < this.shapeInputs.length; i++) {
61
+ this.shapeInputs[i].value = state.shape[i];
62
+ }
63
+ }
64
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
65
+ let outputDims = [];
66
+ for (let i = 0; i < this.shapeInputs.length; i++) {
67
+ let value = parseInt(this.shapeInputs[i].value)
68
+ if (value > 0)
69
+ outputDims.push(parseInt(this.shapeInputs[i].value));
70
+ }
71
+ return { output_1: tf.layers.reshape({ targetShape: outputDims}).apply(inputs.input_1) as TF.SymbolicTensor };
72
+ }
73
+ protected getDisplayName(): string {
74
+ return msg("Reshape");
75
+ }
76
+ }
@@ -0,0 +1,90 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private kernelInput: SlInput;
13
+ private strideInput: SlInput;
14
+ private kernelNumInput: SlInput;
15
+ private params: HTMLElement;
16
+ private numHeads: SlInput;
17
+
18
+ constructor(fields: TransformedDataset, editor: Editor) {
19
+ super(1, 1, "Transpose Convolution", editor)
20
+
21
+ let that = this;
22
+ this.kernelInput = this.addNumberInput(msg("Kernel Size"), 1, 9);
23
+ this.kernelInput.value = "3";
24
+
25
+ this.strideInput = this.addNumberInput(msg("Stride"), 1, 7);
26
+ this.strideInput.onchange = function () {
27
+ that.update();
28
+ that.notifyOutputChange();
29
+ }
30
+ this.strideInput.value = "2";
31
+
32
+ this.kernelNumInput = this.addNumberInput(msg("# of Kernels"), 1, 20);
33
+ this.kernelNumInput.onchange = function () {
34
+ that.update();
35
+ that.notifyOutputChange();
36
+ }
37
+ this.kernelNumInput.value = "4";
38
+
39
+ this.params = document.createElement("span");
40
+ this.addTextElement(msg("Parameters: "), this.params);
41
+ }
42
+
43
+ public getNumberOfParameters() {
44
+ this.update();
45
+ return parseInt(this.params.innerText);
46
+ }
47
+
48
+ update() {
49
+ this.updateInputLabels();
50
+ let numKernels = parseInt(this.kernelNumInput.value)
51
+ this.params.innerText = String(parseInt(this.kernelInput.value) ** 2 * numKernels + numKernels);
52
+ let inDims = this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).map(s => parseInt(s));
53
+ let kernelSize = parseInt(this.kernelInput.value)
54
+ this.getNodeOutputElement("output_1").innerText = [Math.ceil(inDims[0] * parseInt(this.strideInput.value)), Math.ceil(inDims[1] * parseInt(this.strideInput.value)), numKernels].join(SIZE_SEP)
55
+ this.notifyOutputChange();
56
+ }
57
+
58
+ valid() {
59
+ let numKernels = parseInt(this.kernelNumInput.value)
60
+ let params = parseInt(this.kernelInput.value) ** 2 * numKernels + numKernels
61
+ this.params.title = params > this.editor.maxLayerParams ? msg("Layer has to many trainable parameters. Try reducing the input size or the tunable properties.") : "";
62
+ return super.valid() && params <= this.editor.maxLayerParams;
63
+ }
64
+
65
+ getState() {
66
+ let state = super.getState();
67
+ state.kernel = this.kernelInput.value;
68
+ state.stride = this.strideInput.value;
69
+ state.numkernels = this.kernelNumInput.value;
70
+ state.type = "transposeconv";
71
+ return state;
72
+ }
73
+
74
+ setState(state) {
75
+ super.setState(state);
76
+ this.kernelInput.value = state.kernel;
77
+ this.strideInput.value = state.stride;
78
+ this.strideInput.onchange(null);
79
+ this.kernelNumInput.value = state.numkernels;
80
+ this.kernelNumInput.onchange(null);
81
+ }
82
+
83
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
84
+ return { output_1: tf.layers.conv2dTranspose({ filters:parseInt(this.kernelNumInput.value), kernelSize:parseInt(this.kernelInput.value), strides:parseInt(this.strideInput.value) , padding:"same"}).apply(inputs.input_1) as TF.SymbolicTensor };
85
+ }
86
+
87
+ protected getDisplayName(): string {
88
+ return msg("Transpose Convolution");
89
+ }
90
+ }
package/lib/tflib.ts ADDED
@@ -0,0 +1,10 @@
1
+ /** Weird workaround with a dynamic import in order to only import tf once. */
2
+ export default function getTF(): Promise<typeof import("@tensorflow/tfjs")> {
3
+ const w = window as any;
4
+ if (w.__TFPromise == null) {
5
+ w.__TFPromise = w.TF != null
6
+ ? Promise.resolve(w.TF)
7
+ : import("@tensorflow/tfjs").then(tf => (w.TF = tf));
8
+ }
9
+ return w.__TFPromise;
10
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/lit/lit/main/packages/localize-tools/config.schema.json",
3
+ "sourceLocale": "en",
4
+ "targetLocales": [
5
+ "de",
6
+ "ar",
7
+ "bg",
8
+ "cs",
9
+ "da",
10
+ "nl",
11
+ "et",
12
+ "fi",
13
+ "fr",
14
+ "el",
15
+ "hu",
16
+ "it",
17
+ "lv",
18
+ "lt",
19
+ "nb",
20
+ "pl",
21
+ "pt-PT",
22
+ "ro",
23
+ "ru",
24
+ "sk",
25
+ "sl",
26
+ "es",
27
+ "sv",
28
+ "tr",
29
+ "uk",
30
+ "pt-BR",
31
+ "ko",
32
+ "ja",
33
+ "id",
34
+ "zh-hans",
35
+ "zh-hant"
36
+ ],
37
+ "tsConfig": "./tsconfig.json",
38
+ "output": {
39
+ "mode": "runtime",
40
+ "outputDir": "./localization/generated",
41
+ "localeCodesModule": "./localization/generated/locale-codes.js"
42
+ },
43
+ "interchange": {
44
+ "format": "xliff",
45
+ "xliffDir": "./localization"
46
+ }
47
+ }