Skip to content

Commit

Permalink
🚨
Browse files Browse the repository at this point in the history
  • Loading branch information
coyotte508 committed Nov 20, 2023
1 parent e21faee commit dcdf8e6
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 719 deletions.
1 change: 1 addition & 0 deletions packages/tasks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./Types";
export { TASKS_DATA } from "./tasksData";
export { PIPELINE_DATA, type PipelineType, type PipelineData, type Modality, MODALITIES } from "./pipelines";
export { ModelLibrary } from "./modelLibraries";
export type { ModelLibraryKey } from "./modelLibraries";
11 changes: 11 additions & 0 deletions packages/tasks/src/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ export const MODALITIES = ["cv", "nlp", "audio", "tabular", "multimodal", "rl",

export type Modality = (typeof MODALITIES)[number];

export const MODALITY_LABELS = {
multimodal: "Multimodal",
nlp: "Natural Language Processing",
audio: "Audio",
cv: "Computer Vision",
rl: "Reinforcement Learning",
tabular: "Tabular",
other: "Other",
} satisfies Record<Modality, string>;


/**
* Public interface for a sub task.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import VisualQuestionAnsweringWidget from "./widgets/VisualQuestionAnsweringWidget/VisualQuestionAnsweringWidget.svelte";
import ZeroShotClassificationWidget from "./widgets/ZeroShowClassificationWidget/ZeroShotClassificationWidget.svelte";
import ZeroShotImageClassificationWidget from "./widgets/ZeroShotImageClassificationWidget/ZeroShotImageClassificationWidget.svelte";
import type { PipelineType } from "$lib/interfaces/Types.js";
import type { PipelineType } from "@huggingface/tasks";
export let apiToken: WidgetProps["apiToken"] = undefined;
export let callApiOnMount = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script lang="ts">
import { TASKS_DATA } from "@huggingface/tasks";
import { TASKS_DATA, type PipelineType } from "@huggingface/tasks";
import { getPipelineTask } from "../../../../utils/ViewUtils.js";
import IconInfo from "$lib/components/Icons/IconInfo.svelte";
import IconLightning from "$lib/components/Icons/IconLightning.svelte";
import PipelineTag from "../../../PipelineTag/PipelineTag.svelte";
import type { PipelineType } from "$lib/interfaces/Types.js";
export let noTitle = false;
export let title: string | null = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "$lib/components/InferenceWidget/shared/types.js";
import type { PipelineType } from "$lib/interfaces/Types.js";
import type {
WidgetExampleTextInput,
WidgetExampleOutputText,
Expand All @@ -21,6 +20,7 @@
} from "$lib/components/InferenceWidget/shared/helpers.js";
import { isValidOutputText } from "$lib/components/InferenceWidget/shared/outputValidation.js";
import { isTextInput } from "$lib/components/InferenceWidget/shared/inputValidation.js";
import type { PipelineType } from "@huggingface/tasks";
export let apiToken: WidgetProps["apiToken"];
export let apiUrl: WidgetProps["apiUrl"];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import type { SvelteComponent } from "svelte";
import type { PipelineType } from "../../interfaces/Types.js";
import IconAudioClassification from "../Icons/IconAudioClassification.svelte";
import IconAudioToAudio from "../Icons/IconAudioToAudio.svelte";
Expand Down Expand Up @@ -36,6 +35,7 @@
import IconUnconditionalImageGeneration from "../Icons/IconUnconditionalImageGeneration.svelte";
import IconDocumentQuestionAnswering from "../Icons/IconDocumentQuestionAnswering.svelte";
import IconGraphML from "../Icons/IconGraphML.svelte";
import type { PipelineType } from "@huggingface/tasks";
export let classNames = "";
export let pipeline = "";
Expand Down
3 changes: 2 additions & 1 deletion packages/widgets/src/lib/inferenceSnippets/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PipelineType, ModelData } from "../interfaces/Types.js";
import type { PipelineType } from "@huggingface/tasks";
import type { ModelData } from "../interfaces/Types.js";

const inputsZeroShotClassification = () =>
`"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"`;
Expand Down
3 changes: 2 additions & 1 deletion packages/widgets/src/lib/inferenceSnippets/serveCurl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PipelineType, ModelData } from "../interfaces/Types.js";
import type { PipelineType } from "@huggingface/tasks";
import type { ModelData } from "../interfaces/Types.js";
import { getModelInputSnippet } from "./inputs.js";

export const snippetBasic = (model: ModelData, accessToken: string): string =>
Expand Down
3 changes: 2 additions & 1 deletion packages/widgets/src/lib/inferenceSnippets/serveJs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PipelineType, ModelData } from "../interfaces/Types.js";
import type { PipelineType } from "@huggingface/tasks";
import type { ModelData } from "../interfaces/Types.js";
import { getModelInputSnippet } from "./inputs.js";

export const snippetBasic = (model: ModelData, accessToken: string): string =>
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/src/lib/inferenceSnippets/servePython.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PipelineType } from "@huggingface/tasks";
import type { ModelData } from "../interfaces/Types.js";
import type { PipelineType } from "../interfaces/Types.js";
import { getModelInputSnippet } from "./inputs.js";

export const snippetZeroShotClassification = (model: ModelData): string =>
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/src/lib/interfaces/DefaultWidget.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PipelineType } from "@huggingface/tasks";
import type { WidgetExample } from "../components/InferenceWidget/shared/WidgetExample.js";
import type { PipelineType } from "./Types.js";

type LanguageCode = string;

Expand Down
52 changes: 1 addition & 51 deletions packages/widgets/src/lib/interfaces/Libraries.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,7 @@
import type { ModelLibraryKey } from "@huggingface/tasks";
/* eslint-disable @typescript-eslint/naming-convention */
import type { ModelData } from "./Types.js";

/**
* Add your new library here.
*
* This is for modeling (= architectures) libraries, not for file formats (like ONNX, etc).
* File formats live in an enum inside the internal codebase.
*/
export enum ModelLibrary {
"adapter-transformers" = "Adapter Transformers",
"allennlp" = "allenNLP",
"asteroid" = "Asteroid",
"bertopic" = "BERTopic",
"diffusers" = "Diffusers",
"doctr" = "docTR",
"espnet" = "ESPnet",
"fairseq" = "Fairseq",
"flair" = "Flair",
"keras" = "Keras",
"k2" = "K2",
"nemo" = "NeMo",
"open_clip" = "OpenCLIP",
"paddlenlp" = "PaddleNLP",
"peft" = "PEFT",
"pyannote-audio" = "pyannote.audio",
"sample-factory" = "Sample Factory",
"sentence-transformers" = "Sentence Transformers",
"sklearn" = "Scikit-learn",
"spacy" = "spaCy",
"span-marker" = "SpanMarker",
"speechbrain" = "speechbrain",
"tensorflowtts" = "TensorFlowTTS",
"timm" = "Timm",
"fastai" = "fastai",
"transformers" = "Transformers",
"transformers.js" = "Transformers.js",
"stanza" = "Stanza",
"fasttext" = "fastText",
"stable-baselines3" = "Stable-Baselines3",
"ml-agents" = "ML-Agents",
"pythae" = "Pythae",
"mindspore" = "MindSpore",
}

export type ModelLibraryKey = keyof typeof ModelLibrary;
export const ALL_MODEL_LIBRARY_KEYS = Object.keys(ModelLibrary) as ModelLibraryKey[];

const EXCLUDE_THOSE_LIBRARIES_FROM_DISPLAY: ModelLibraryKey[] = ["doctr", "k2", "mindspore", "tensorflowtts"];

export const ALL_DISPLAY_MODEL_LIBRARY_KEYS = ALL_MODEL_LIBRARY_KEYS.filter(
(k) => !EXCLUDE_THOSE_LIBRARIES_FROM_DISPLAY.includes(k)
);

/**
* Elements configurable by a model library.
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/widgets/src/lib/interfaces/LibrariesToTasks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ModelLibraryKey } from "./Libraries.js";
import type { PipelineType } from "./Types.js";
import type { ModelLibraryKey, PipelineType } from "@huggingface/tasks";

/**
* Mapping from library name (excluding Transformers) to its supported tasks.
Expand Down
Loading

0 comments on commit dcdf8e6

Please sign in to comment.