diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..23ff6576f4a0f6e8cee58c7500193af6426f7738 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-segmentation/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA8Ff,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.js new file mode 100644 index 0000000000000000000000000000000000000000..378202a2bc1bd8c4958972289cb9e763026d348c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/data.js @@ -0,0 +1,93 @@ +const taskData = { + datasets: [ + { + description: "Scene segmentation dataset.", + id: "scene_parse_150", + }, + ], + demo: { + inputs: [ + { + filename: "image-segmentation-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-segmentation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: "Average Precision (AP) is the Area Under the PR Curve (AUC-PR). It is calculated for each semantic class separately", + id: "Average Precision", + }, + { + description: "Mean Average Precision (mAP) is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: "Intersection over Union (IoU) is the overlap of segmentation masks. Mean IoU is the average of the IoU of all semantic classes", + id: "Mean Intersection over Union", + }, + { + description: "APα is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + // TO DO: write description + description: "Solid panoptic segmentation model trained on COCO.", + id: "tue-mps/coco_panoptic_eomt_large_640", + }, + { + description: "Background removal model.", + id: "briaai/RMBG-1.4", + }, + { + description: "A multipurpose image segmentation model for high resolution images.", + id: "ZhengPeng7/BiRefNet", + }, + { + description: "Powerful human-centric image segmentation model.", + id: "facebook/sapiens-seg-1b", + }, + { + description: "Panoptic segmentation model trained on the COCO (common objects) dataset.", + id: "facebook/mask2former-swin-large-coco-panoptic", + }, + ], + spaces: [ + { + description: "A semantic segmentation application that can predict unseen instances out of the box.", + id: "facebook/ov-seg", + }, + { + description: "One of the strongest segmentation applications.", + id: "jbrinkma/segment-anything", + }, + { + description: "A human-centric segmentation model.", + id: "facebook/sapiens-pose", + }, + { + description: "An instance segmentation application to predict neuronal cell types from microscopy images.", + id: "rashmi/sartorius-cell-instance-segmentation", + }, + { + description: "An application that segments videos.", + id: "ArtGAN/Segment-Anything-Video", + }, + { + description: "An panoptic segmentation application built for outdoor environments.", + id: "segments/panoptic-segment-anything", + }, + ], + summary: "Image Segmentation divides an image into segments where each pixel in the image is mapped to an object. This task has multiple variants such as instance segmentation, panoptic segmentation and semantic segmentation.", + widgetModels: ["nvidia/segformer-b0-finetuned-ade-512-512"], + youtubeId: "dKE8SIt9C-w", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62893d683d831473f37662e89e8742a0582f6d4f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts @@ -0,0 +1,68 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Segmentation inference + */ +export interface ImageSegmentationInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image Segmentation + */ + parameters?: ImageSegmentationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Segmentation + */ +export interface ImageSegmentationParameters { + /** + * Threshold to use when turning the predicted masks into binary values. + */ + mask_threshold?: number; + /** + * Mask overlap threshold to eliminate small, disconnected segments. + */ + overlap_mask_area_threshold?: number; + /** + * Segmentation task to be performed, depending on model capabilities. + */ + subtask?: ImageSegmentationSubtask; + /** + * Probability threshold to filter out predicted masks. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * Segmentation task to be performed, depending on model capabilities. + */ +export type ImageSegmentationSubtask = "instance" | "panoptic" | "semantic"; +export type ImageSegmentationOutput = ImageSegmentationOutputElement[]; +/** + * Outputs of inference for the Image Segmentation task + * + * A predicted mask / segment + */ +export interface ImageSegmentationOutputElement { + /** + * The label of the predicted segment. + */ + label: string; + /** + * The corresponding mask as a black-and-white image (base64-encoded). + */ + mask: string; + /** + * The score or confidence degree the model has. + */ + score?: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..002f53684e81edb0b5ac7dd0ed180a404781f3e2 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-segmentation/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,EAAE,CAAC;AACvE;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-segmentation/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..53a0eeeace77cd5956a7331e9ab7cb5c8f3fd1fb --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-text-to-image/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAiDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.js new file mode 100644 index 0000000000000000000000000000000000000000..a171a1390db0bdb9bdaeabe80ff411b211e00410 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/data.js @@ -0,0 +1,48 @@ +const taskData = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-image-input.jpeg", + type: "img", + }, + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-image-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: "CLIP Score measures the similarity between the generated image and the text prompt using CLIP embeddings. A higher score indicates better alignment with the text prompt.", + id: "CLIP", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + spaces: [ + { + description: "An application for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + summary: "Image-text-to-image models take an image and a text prompt as input and generate a new image based on the reference image and text instructions. These models are useful for image editing, style transfer, image variations, and guided image generation tasks.", + widgetModels: ["black-forest-labs/FLUX.2-dev"], + youtubeId: undefined, +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6d2dab3a0b73c4600be87602613629b9d288570 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts @@ -0,0 +1,76 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Image + */ + parameters?: ImageTextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Image + */ +export interface ImageTextToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Image task + */ +export interface ImageTextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e0caa1a268aacfd85428f46c8615abf68d4f0606 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-text-to-image/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-image/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b600eb9ac66eb184e991671ecca7a6e8d4b6e8ab --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-text-to-text/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAiFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.js new file mode 100644 index 0000000000000000000000000000000000000000..7c3b498b4143f7f4b5b83001fe42402dbc91296e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-text/data.js @@ -0,0 +1,81 @@ +const taskData = { + datasets: [ + { + description: "Instructions composed of image and text.", + id: "liuhaotian/LLaVA-Instruct-150K", + }, + { + description: "Collection of image-text pairs on scientific topics.", + id: "DAMO-NLP-SG/multimodal_textbook", + }, + { + description: "A collection of datasets made for model fine-tuning.", + id: "HuggingFaceM4/the_cauldron", + }, + { + description: "Screenshots of websites with their HTML/CSS codes.", + id: "HuggingFaceM4/WebSight", + }, + ], + demo: { + inputs: [ + { + filename: "image-text-to-text-input.png", + type: "img", + }, + { + label: "Text Prompt", + content: "Describe the position of the bee in detail.", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: "The bee is sitting on a pink flower, surrounded by other flowers. The bee is positioned in the center of the flower, with its head and front legs sticking out.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Small and efficient yet powerful vision language model.", + id: "HuggingFaceTB/SmolVLM-Instruct", + }, + { + description: "Cutting-edge reasoning vision language model.", + id: "zai-org/GLM-4.5V", + }, + { + description: "Cutting-edge small vision language model to convert documents to text.", + id: "rednote-hilab/dots.ocr", + }, + { + description: "Small yet powerful model.", + id: "Qwen/Qwen2.5-VL-3B-Instruct", + }, + { + description: "Image-text-to-text model with agentic capabilities.", + id: "microsoft/Magma-8B", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate vision language models.", + id: "opencompass/open_vlm_leaderboard", + }, + { + description: "An application that compares object detection capabilities of different vision language models.", + id: "sergiopaniego/vlm_object_understanding", + }, + { + description: "An application to compare different OCR models.", + id: "prithivMLmods/Multimodal-OCR", + }, + ], + summary: "Image-text-to-text models take in an image and text prompt and output text. These models are also called vision-language models, or VLMs. The difference from image-to-text models is that these models take an additional text input, not restricting the model to certain use cases like image captioning, and may also be trained to accept a conversation as input.", + widgetModels: ["zai-org/GLM-4.5V"], + youtubeId: "IoGaGfU1CIg", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4b9e273281951252ef914c15fc3f2df7c63fdfbd --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-text-to-video/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAiDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.js new file mode 100644 index 0000000000000000000000000000000000000000..3dc8ae377373ff0068695d7ebe9b64bd89ee6a8e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/data.js @@ -0,0 +1,48 @@ +const taskData = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-video-input.jpg", + type: "img", + }, + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-video generation.", + id: "Lightricks/LTX-Video", + }, + ], + spaces: [ + { + description: "An application for image-text-to-video generation.", + id: "Lightricks/ltx-video-distilled", + }, + ], + summary: "Image-text-to-video models take an reference image and a text instructions as and generate a video based on them. These models are useful for animating still images, creating dynamic content from static references, and generating videos with specific motion or transformation guidance.", + widgetModels: ["Lightricks/LTX-Video"], + youtubeId: undefined, +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..069db05bcf626591087431e5284525e1b189cc41 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts @@ -0,0 +1,78 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Video + */ + parameters?: ImageTextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Video + */ +export interface ImageTextToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Video task + */ +export interface ImageTextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..dddebe7ae1d8e967527b72e26ba1a9b5f1544c2c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-text-to-video/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-text-to-video/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8c8b2f7cc89572fcc9c798d136a3bc242d3d98bd --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-3d/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAsEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.js new file mode 100644 index 0000000000000000000000000000000000000000..2382dec02e4181451cd45d5c2c21be5ac9851702 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-3d/data.js @@ -0,0 +1,72 @@ +const taskData = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "A dataset of isolated object images for evaluating image-to-3D models.", + id: "dylanebert/iso3d", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-3d-image-input.png", + type: "img", + }, + ], + outputs: [ + { + label: "Result", + content: "image-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Fast image-to-3D mesh model by Tencent.", + id: "TencentARC/InstantMesh", + }, + { + description: "3D world generation model.", + id: "tencent/HunyuanWorld-1", + }, + { + description: "A scaled up image-to-3D mesh model derived from TripoSR.", + id: "hwjiang/Real3D", + }, + { + description: "Consistent image-to-3d generation model.", + id: "stabilityai/stable-point-aware-3d", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate image-to-3D models.", + id: "dylanebert/3d-arena", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "TencentARC/InstantMesh", + }, + { + description: "Image-to-3D demo.", + id: "stabilityai/stable-point-aware-3d", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "hwjiang/Real3D", + }, + { + description: "Image-to-3D demo with splat outputs.", + id: "dylanebert/LGM-mini", + }, + ], + summary: "Image-to-3D models take in image input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..df6672e2ac2e6e69cdfdc88c3e5300bb1a441eb8 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-image/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA2Ff,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.js new file mode 100644 index 0000000000000000000000000000000000000000..0244d38c4c9be4d6f45298cdae10c76273f72f9b --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/data.js @@ -0,0 +1,89 @@ +const taskData = { + datasets: [ + { + description: "Synthetic dataset, for image relighting", + id: "VIDIT", + }, + { + description: "Multiple images of celebrities, used for facial expression translation", + id: "huggan/CelebA-faces", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-image-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-to-image-output.png", + type: "img", + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "Peak Signal to Noise Ratio (PSNR) is an approximation of the human perception, considering the ratio of the absolute intensity with respect to the variations. Measured in dB, a high value indicates a high fidelity.", + id: "PSNR", + }, + { + description: "Structural Similarity Index (SSIM) is a perceptual metric which compares the luminance, contrast and structure of two images. The values of SSIM range between -1 and 1, and higher values indicate closer resemblance to the original image.", + id: "SSIM", + }, + { + description: "Inception Score (IS) is an analysis of the labels predicted by an image classification model when presented with a sample of the generated images.", + id: "IS", + }, + ], + models: [ + { + description: "An image-to-image model to improve image resolution.", + id: "fal/AuraSR-v2", + }, + { + description: "Powerful image editing model.", + id: "black-forest-labs/FLUX.1-Kontext-dev", + }, + { + description: "Virtual try-on model.", + id: "yisol/IDM-VTON", + }, + { + description: "Image re-lighting model.", + id: "kontext-community/relighting-kontext-dev-lora-v3", + }, + { + description: "Strong model for inpainting and outpainting.", + id: "black-forest-labs/FLUX.1-Fill-dev", + }, + { + description: "Strong model for image editing using depth maps.", + id: "black-forest-labs/FLUX.1-Depth-dev-lora", + }, + ], + spaces: [ + { + description: "Image editing application.", + id: "black-forest-labs/FLUX.1-Kontext-Dev", + }, + { + description: "Image relighting application.", + id: "lllyasviel/iclight-v2-vary", + }, + { + description: "An application for image upscaling.", + id: "jasperai/Flux.1-dev-Controlnet-Upscaler", + }, + ], + summary: "Image-to-image is the task of transforming an input image through a variety of possible manipulations and enhancements, such as super-resolution, image inpainting, colorization, and more.", + widgetModels: ["Qwen/Qwen-Image"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5c7a1dc660bc32cac43d7d9298c4710c82fc186 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts @@ -0,0 +1,69 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Image inference + */ +export interface ImageToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Image + */ + parameters?: ImageToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Image + */ +export interface ImageToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. + */ + prompt?: string; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Image task + */ +export interface ImageToImageOutput { + /** + * The output image returned as raw bytes in the payload. + */ + image?: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..6a40c1d8e247354fc5934c1b438879b3888011e6 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-image/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-image/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..aa4d932b0466467f4b50fda065faf7fd02b50f87 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-text/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAyDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.js new file mode 100644 index 0000000000000000000000000000000000000000..2f2ab05e7c120985ebb55428eb532c66250f88d1 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/data.js @@ -0,0 +1,58 @@ +const taskData = { + datasets: [ + { + // TODO write proper description + description: "Dataset from 12M image-text of Reddit", + id: "red_caps", + }, + { + // TODO write proper description + description: "Dataset from 3.3M images of Google", + id: "datasets/conceptual_captions", + }, + ], + demo: { + inputs: [ + { + filename: "savanna.jpg", + type: "img", + }, + ], + outputs: [ + { + label: "Detailed description", + content: "a herd of giraffes and zebras grazing in a field", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Strong OCR model.", + id: "allenai/olmOCR-7B-0725", + }, + { + description: "Powerful image captioning model.", + id: "fancyfeast/llama-joycaption-beta-one-hf-llava", + }, + ], + spaces: [ + { + description: "SVG generator app from images.", + id: "multimodalart/OmniSVG-3B", + }, + { + description: "An application that converts documents to markdown.", + id: "numind/NuMarkdown-8B-Thinking", + }, + { + description: "An application that can caption images.", + id: "fancyfeast/joy-caption-beta-one", + }, + ], + summary: "Image to text models output a text from a given image. Image captioning or optical character recognition can be considered as the most common applications of image to text.", + widgetModels: ["Salesforce/blip-image-captioning-large"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9944a906d4fa9529af0e38ef2473969de421da4c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts @@ -0,0 +1,135 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Text inference + */ +export interface ImageToTextInput { + /** + * The input image data + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Text + */ + parameters?: ImageToTextParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Text + */ +export interface ImageToTextParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + /** + * The amount of maximum tokens to generate. + */ + max_new_tokens?: number; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +/** + * Outputs of inference for the Image To Text task + */ +export interface ImageToTextOutput { + generatedText: unknown; + /** + * The generated text. + */ + generated_text?: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b4d812f2f06619307ca7ebf5c53526474c51ab2d --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-text/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,qBAAqB,CAAC,EAAE,oBAAoB,CAAC;IAC7C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,CAAC;AACnD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-text/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e5d0273d48ff15ed08a8d8bcd0d85efb1ba1a091 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-video/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAyHf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.js new file mode 100644 index 0000000000000000000000000000000000000000..153be3c7ca096b06a8bd1239dfb7390d99b8be3f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/data.js @@ -0,0 +1,117 @@ +const taskData = { + datasets: [ + { + description: "A benchmark dataset for reference image controlled video generation.", + id: "ali-vilab/VACE-Benchmark", + }, + { + description: "A dataset of video generation style preferences.", + id: "Rapidata/sora-video-generation-style-likert-scoring", + }, + { + description: "A dataset with videos and captions throughout the videos.", + id: "BestWishYsh/ChronoMagic", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-video-input.jpg", + type: "img", + }, + { + label: "Optional Text Prompt", + content: "This penguin is dancing", + type: "text", + }, + ], + outputs: [ + { + filename: "image-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: "Fréchet Video Distance (FVD) measures the perceptual similarity between the distributions of generated videos and a set of real videos, assessing overall visual quality and temporal coherence of the video generated from an input image.", + id: "fvd", + }, + { + description: "CLIP Score measures the semantic similarity between a textual prompt (if provided alongside the input image) and the generated video frames. It evaluates how well the video's generated content and motion align with the textual description, conditioned on the initial image.", + id: "clip_score", + }, + { + description: "First Frame Fidelity, often measured using LPIPS (Learned Perceptual Image Patch Similarity), PSNR, or SSIM, quantifies how closely the first frame of the generated video matches the input conditioning image.", + id: "lpips", + }, + { + description: "Identity Preservation Score measures the consistency of identity (e.g., a person's face or a specific object's characteristics) between the input image and throughout the generated video frames, often calculated using features from specialized models like face recognition (e.g., ArcFace) or re-identification models.", + id: "identity_preservation", + }, + { + description: "Motion Score evaluates the quality, realism, and temporal consistency of motion in the video generated from a static image. This can be based on optical flow analysis (e.g., smoothness, magnitude), consistency of object trajectories, or specific motion plausibility assessments.", + id: "motion_score", + }, + ], + models: [ + { + description: "LTX-Video, a 13B parameter model for high quality video generation", + id: "Lightricks/LTX-Video-0.9.7-dev", + }, + { + description: "A 14B parameter model for reference image controlled video generation", + id: "Wan-AI/Wan2.1-VACE-14B", + }, + { + description: "An image-to-video generation model using FramePack F1 methodology with Hunyuan-DiT architecture", + id: "lllyasviel/FramePack_F1_I2V_HY_20250503", + }, + { + description: "A distilled version of the LTX-Video-0.9.7-dev model for faster inference", + id: "Lightricks/LTX-Video-0.9.7-distilled", + }, + { + description: "An image-to-video generation model by Skywork AI, 14B parameters, producing 720p videos.", + id: "Skywork/SkyReels-V2-I2V-14B-720P", + }, + { + description: "Image-to-video variant of Tencent's HunyuanVideo.", + id: "tencent/HunyuanVideo-I2V", + }, + { + description: "A 14B parameter model for 720p image-to-video generation by Wan-AI.", + id: "Wan-AI/Wan2.1-I2V-14B-720P", + }, + { + description: "A Diffusers version of the Wan2.1-I2V-14B-720P model for 720p image-to-video generation.", + id: "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers", + }, + ], + spaces: [ + { + description: "An application to generate videos fast.", + id: "Lightricks/ltx-video-distilled", + }, + { + description: "Generate videos with the FramePack-F1", + id: "linoyts/FramePack-F1", + }, + { + description: "Generate videos with the FramePack", + id: "lisonallen/framepack-i2v", + }, + { + description: "Wan2.1 with CausVid LoRA", + id: "multimodalart/wan2-1-fast", + }, + { + description: "A demo for Stable Video Diffusion", + id: "multimodalart/stable-video-diffusion", + }, + ], + summary: "Image-to-video models take a still image as input and generate a video. These models can be guided by text prompts to influence the content and style of the output video.", + widgetModels: [], + youtubeId: undefined, +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d6c62757ec0115df3abf86575056526232d0a7b --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts @@ -0,0 +1,75 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Video inference + */ +export interface ImageToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Video + */ + parameters?: ImageToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Video + */ +export interface ImageToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Video task + */ +export interface ImageToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..81dcff95e010b3e686370e299598f3966b398664 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-to-video/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/image-to-video/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..94fdc2d6ba6abd243bae015279941067d3e51a2e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts @@ -0,0 +1,91 @@ +import type { PipelineType } from "../pipelines.js"; +export type * from "./audio-classification/inference.js"; +export type * from "./automatic-speech-recognition/inference.js"; +export type { ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionInputMessageChunkType, ChatCompletionOutput, ChatCompletionOutputComplete, ChatCompletionOutputMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, } from "./chat-completion/inference.js"; +export type * from "./document-question-answering/inference.js"; +export type * from "./feature-extraction/inference.js"; +export type * from "./fill-mask/inference.js"; +export type { ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, } from "./image-classification/inference.js"; +export type * from "./image-to-image/inference.js"; +export type { ImageToTextInput, ImageToTextOutput, ImageToTextParameters } from "./image-to-text/inference.js"; +export type * from "./image-segmentation/inference.js"; +export type { ImageToVideoInput, ImageToVideoOutput, ImageToVideoParameters } from "./image-to-video/inference.js"; +export type { ImageTextToImageInput, ImageTextToImageOutput, ImageTextToImageParameters, } from "./image-text-to-image/inference.js"; +export type { ImageTextToVideoInput, ImageTextToVideoOutput, ImageTextToVideoParameters, } from "./image-text-to-video/inference.js"; +export type * from "./object-detection/inference.js"; +export type * from "./depth-estimation/inference.js"; +export type * from "./question-answering/inference.js"; +export type * from "./sentence-similarity/inference.js"; +export type * from "./summarization/inference.js"; +export type * from "./table-question-answering/inference.js"; +export type { TextToImageInput, TextToImageOutput, TextToImageParameters } from "./text-to-image/inference.js"; +export type { TextToVideoParameters, TextToVideoOutput, TextToVideoInput } from "./text-to-video/inference.js"; +export type { TextToSpeechParameters, TextToSpeechInput, TextToSpeechOutput } from "./text-to-speech/inference.js"; +export type * from "./token-classification/inference.js"; +export type { TranslationInput, TranslationOutput } from "./translation/inference.js"; +export type { ClassificationOutputTransform, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, } from "./text-classification/inference.js"; +export type { TextGenerationOutputFinishReason, TextGenerationOutputPrefillToken, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationInputGenerateParameters, TextGenerationOutputBestOfSequence, TextGenerationOutputToken, TextGenerationStreamOutputStreamDetails, TextGenerationStreamOutput, } from "./text-generation/inference.js"; +export type * from "./video-classification/inference.js"; +export type * from "./visual-question-answering/inference.js"; +export type * from "./zero-shot-classification/inference.js"; +export type * from "./zero-shot-image-classification/inference.js"; +export type { BoundingBox, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, } from "./zero-shot-object-detection/inference.js"; +import type { ModelLibraryKey } from "../model-libraries.js"; +/** + * Model libraries compatible with each ML task + */ +export declare const TASKS_MODEL_LIBRARIES: Record; +export declare const TASKS_DATA: Record; +export interface ExampleRepo { + description: string; + id: string; +} +export type TaskDemoEntry = { + filename: string; + type: "audio"; +} | { + data: Array<{ + label: string; + score: number; + }>; + type: "chart"; +} | { + filename: string; + type: "img"; +} | { + table: string[][]; + type: "tabular"; +} | { + content: string; + label: string; + type: "text"; +} | { + text: string; + tokens: Array<{ + end: number; + start: number; + type: string; + }>; + type: "text-with-tokens"; +}; +export interface TaskDemo { + inputs: TaskDemoEntry[]; + outputs: TaskDemoEntry[]; +} +export interface TaskData { + datasets: ExampleRepo[]; + demo: TaskDemo; + id: PipelineType; + canonicalId?: PipelineType; + isPlaceholder?: boolean; + label: string; + libraries: ModelLibraryKey[]; + metrics: ExampleRepo[]; + models: ExampleRepo[]; + spaces: ExampleRepo[]; + summary: string; + widgetModels: string[]; + youtubeId?: string; +} +export type TaskDataCustom = Omit; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..18a818e806f1140958715845584c04b5182319f1 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAoDpD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,6CAA6C,CAAC;AACjE,YAAY,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,mCAAmC,EACnC,oBAAoB,EACpB,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,gCAAgC,EAChC,+BAA+B,GAC/B,MAAM,gCAAgC,CAAC;AACxC,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,0BAA0B,CAAC;AAC9C,YAAY,EACX,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,6BAA6B,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB,+BAA+B,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/G,mBAAmB,mCAAmC,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACnH,YAAY,EACX,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACX,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5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M,EAAE,WAAW,EAAE,CAAC;IACtB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/index.js b/node_modules/@huggingface/tasks/dist/esm/tasks/index.js new file mode 100644 index 0000000000000000000000000000000000000000..db0af44e7f1f527b240c206bcd91430c05c2615a --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/index.js @@ -0,0 +1,195 @@ +import { PIPELINE_DATA } from "../pipelines.js"; +import anyToAny from "./any-to-any/data.js"; +import audioClassification from "./audio-classification/data.js"; +import audioTextToText from "./audio-text-to-text/data.js"; +import audioToAudio from "./audio-to-audio/data.js"; +import automaticSpeechRecognition from "./automatic-speech-recognition/data.js"; +import documentQuestionAnswering from "./document-question-answering/data.js"; +import featureExtraction from "./feature-extraction/data.js"; +import fillMask from "./fill-mask/data.js"; +import imageClassification from "./image-classification/data.js"; +import imageFeatureExtraction from "./image-feature-extraction/data.js"; +import imageToImage from "./image-to-image/data.js"; +import imageToText from "./image-to-text/data.js"; +import imageTextToText from "./image-text-to-text/data.js"; +import imageTextToImage from "./image-text-to-image/data.js"; +import imageTextToVideo from "./image-text-to-video/data.js"; +import imageSegmentation from "./image-segmentation/data.js"; +import imageToVideo from "./image-to-video/data.js"; +import maskGeneration from "./mask-generation/data.js"; +import objectDetection from "./object-detection/data.js"; +import depthEstimation from "./depth-estimation/data.js"; +import placeholder from "./placeholder/data.js"; +import reinforcementLearning from "./reinforcement-learning/data.js"; +import questionAnswering from "./question-answering/data.js"; +import sentenceSimilarity from "./sentence-similarity/data.js"; +import summarization from "./summarization/data.js"; +import tableQuestionAnswering from "./table-question-answering/data.js"; +import tabularClassification from "./tabular-classification/data.js"; +import tabularRegression from "./tabular-regression/data.js"; +import textToImage from "./text-to-image/data.js"; +import textToSpeech from "./text-to-speech/data.js"; +import tokenClassification from "./token-classification/data.js"; +import translation from "./translation/data.js"; +import textClassification from "./text-classification/data.js"; +import textGeneration from "./text-generation/data.js"; +import textRanking from "./text-ranking/data.js"; +import textToVideo from "./text-to-video/data.js"; +import unconditionalImageGeneration from "./unconditional-image-generation/data.js"; +import videoClassification from "./video-classification/data.js"; +import visualDocumentRetrieval from "./visual-document-retrieval/data.js"; +import visualQuestionAnswering from "./visual-question-answering/data.js"; +import zeroShotClassification from "./zero-shot-classification/data.js"; +import zeroShotImageClassification from "./zero-shot-image-classification/data.js"; +import zeroShotObjectDetection from "./zero-shot-object-detection/data.js"; +import imageTo3D from "./image-to-3d/data.js"; +import textTo3D from "./text-to-3d/data.js"; +import keypointDetection from "./keypoint-detection/data.js"; +import videoTextToText from "./video-text-to-text/data.js"; +import videoToVideo from "./video-to-video/data.js"; +/** + * Model libraries compatible with each ML task + */ +export const TASKS_MODEL_LIBRARIES = { + "audio-classification": ["speechbrain", "transformers", "transformers.js"], + "audio-to-audio": ["asteroid", "fairseq", "speechbrain"], + "automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"], + "audio-text-to-text": ["transformers"], + "depth-estimation": ["transformers", "transformers.js"], + "document-question-answering": ["transformers", "transformers.js"], + "feature-extraction": ["sentence-transformers", "transformers", "transformers.js"], + "fill-mask": ["transformers", "transformers.js"], + "graph-ml": ["transformers"], + "image-classification": ["keras", "timm", "transformers", "transformers.js"], + "image-feature-extraction": ["timm", "transformers"], + "image-segmentation": ["transformers", "transformers.js"], + "image-text-to-text": ["transformers"], + "image-text-to-image": ["diffusers"], + "image-text-to-video": ["diffusers"], + "image-to-image": ["diffusers", "transformers", "transformers.js"], + "image-to-text": ["transformers", "transformers.js"], + "image-to-video": ["diffusers"], + "keypoint-detection": ["transformers"], + "video-classification": ["transformers"], + "mask-generation": ["transformers"], + "multiple-choice": ["transformers"], + "object-detection": ["transformers", "transformers.js", "ultralytics"], + other: [], + "question-answering": ["adapter-transformers", "allennlp", "transformers", "transformers.js"], + robotics: [], + "reinforcement-learning": ["transformers", "stable-baselines3", "ml-agents", "sample-factory"], + "sentence-similarity": ["sentence-transformers", "spacy", "transformers.js"], + summarization: ["transformers", "transformers.js"], + "table-question-answering": ["transformers"], + "table-to-text": ["transformers"], + "tabular-classification": ["sklearn"], + "tabular-regression": ["sklearn"], + "tabular-to-text": ["transformers"], + "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"], + "text-generation": ["transformers", "transformers.js"], + "text-ranking": ["sentence-transformers", "transformers"], + "text-retrieval": [], + "text-to-image": ["diffusers"], + "text-to-speech": ["espnet", "tensorflowtts", "transformers", "transformers.js"], + "text-to-audio": ["transformers", "transformers.js"], + "text-to-video": ["diffusers"], + "time-series-forecasting": [], + "token-classification": [ + "adapter-transformers", + "flair", + "spacy", + "span-marker", + "stanza", + "transformers", + "transformers.js", + ], + translation: ["transformers", "transformers.js"], + "unconditional-image-generation": ["diffusers"], + "video-text-to-text": ["transformers"], + "visual-question-answering": ["transformers", "transformers.js"], + "voice-activity-detection": [], + "zero-shot-classification": ["transformers", "transformers.js"], + "zero-shot-image-classification": ["transformers", "transformers.js"], + "zero-shot-object-detection": ["transformers", "transformers.js"], + "text-to-3d": ["diffusers"], + "image-to-3d": ["diffusers"], + "any-to-any": ["transformers"], + "visual-document-retrieval": ["transformers"], + "video-to-video": ["diffusers"], +}; +/** + * Return the whole TaskData object for a certain task. + * If the partialTaskData argument is left undefined, + * the default placeholder data will be used. + */ +function getData(type, partialTaskData = placeholder) { + return { + ...partialTaskData, + id: type, + label: PIPELINE_DATA[type].name, + libraries: TASKS_MODEL_LIBRARIES[type], + }; +} +// To make comparisons easier, task order is the same as in const.ts +// Tasks set to undefined won't have an associated task page. +// Tasks that call getData() without the second argument will +// have a "placeholder" page. +export const TASKS_DATA = { + "any-to-any": getData("any-to-any", anyToAny), + "audio-classification": getData("audio-classification", audioClassification), + "audio-to-audio": getData("audio-to-audio", audioToAudio), + "audio-text-to-text": getData("audio-text-to-text", audioTextToText), + "automatic-speech-recognition": getData("automatic-speech-recognition", automaticSpeechRecognition), + "depth-estimation": getData("depth-estimation", depthEstimation), + "document-question-answering": getData("document-question-answering", documentQuestionAnswering), + "visual-document-retrieval": getData("visual-document-retrieval", visualDocumentRetrieval), + "feature-extraction": getData("feature-extraction", featureExtraction), + "fill-mask": getData("fill-mask", fillMask), + "graph-ml": undefined, + "image-classification": getData("image-classification", imageClassification), + "image-feature-extraction": getData("image-feature-extraction", imageFeatureExtraction), + "image-segmentation": getData("image-segmentation", imageSegmentation), + "image-to-image": getData("image-to-image", imageToImage), + "image-text-to-text": getData("image-text-to-text", imageTextToText), + "image-text-to-image": getData("image-text-to-image", imageTextToImage), + "image-text-to-video": getData("image-text-to-video", imageTextToVideo), + "image-to-text": getData("image-to-text", imageToText), + "image-to-video": getData("image-to-video", imageToVideo), + "keypoint-detection": getData("keypoint-detection", keypointDetection), + "mask-generation": getData("mask-generation", maskGeneration), + "multiple-choice": undefined, + "object-detection": getData("object-detection", objectDetection), + "video-classification": getData("video-classification", videoClassification), + other: undefined, + "question-answering": getData("question-answering", questionAnswering), + "reinforcement-learning": getData("reinforcement-learning", reinforcementLearning), + robotics: undefined, + "sentence-similarity": getData("sentence-similarity", sentenceSimilarity), + summarization: getData("summarization", summarization), + "table-question-answering": getData("table-question-answering", tableQuestionAnswering), + "table-to-text": undefined, + "tabular-classification": getData("tabular-classification", tabularClassification), + "tabular-regression": getData("tabular-regression", tabularRegression), + "tabular-to-text": undefined, + "text-classification": getData("text-classification", textClassification), + "text-generation": getData("text-generation", textGeneration), + "text-ranking": getData("text-ranking", textRanking), + "text-retrieval": undefined, + "text-to-image": getData("text-to-image", textToImage), + "text-to-speech": getData("text-to-speech", textToSpeech), + "text-to-audio": undefined, + "text-to-video": getData("text-to-video", textToVideo), + "time-series-forecasting": undefined, + "token-classification": getData("token-classification", tokenClassification), + translation: getData("translation", translation), + "unconditional-image-generation": getData("unconditional-image-generation", unconditionalImageGeneration), + "video-text-to-text": getData("video-text-to-text", videoTextToText), + "video-to-video": getData("video-to-video", videoToVideo), + "visual-question-answering": getData("visual-question-answering", visualQuestionAnswering), + "voice-activity-detection": undefined, + "zero-shot-classification": getData("zero-shot-classification", zeroShotClassification), + "zero-shot-image-classification": getData("zero-shot-image-classification", zeroShotImageClassification), + "zero-shot-object-detection": getData("zero-shot-object-detection", zeroShotObjectDetection), + "text-to-3d": getData("text-to-3d", textTo3D), + "image-to-3d": getData("image-to-3d", imageTo3D), +}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..eb823f21e8304e3e89965c2360ab9594e5d59139 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/keypoint-detection/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAqDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.js new file mode 100644 index 0000000000000000000000000000000000000000..667a7c1e36e849486f73ebcc3dddc84c72d1c56e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/keypoint-detection/data.js @@ -0,0 +1,55 @@ +const taskData = { + datasets: [ + { + description: "A dataset of hand keypoints of over 500k examples.", + id: "Vincent-luo/hagrid-mediapipe-hands", + }, + ], + demo: { + inputs: [ + { + filename: "keypoint-detection-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "keypoint-detection-output.png", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust keypoint detection model.", + id: "magic-leap-community/superpoint", + }, + { + description: "A robust keypoint matching model.", + id: "magic-leap-community/superglue_outdoor", + }, + { + description: "Strong keypoint detection model used to detect human pose.", + id: "qualcomm/RTMPose-Body2d", + }, + { + description: "Powerful keypoint matching model.", + id: "ETH-CVG/lightglue_disk", + }, + ], + spaces: [ + { + description: "An application that detects hand keypoints in real-time.", + id: "datasciencedojo/Hand-Keypoint-Detection-Realtime", + }, + { + description: "An application for keypoint detection and matching.", + id: "ETH-CVG/LightGlue", + }, + ], + summary: "Keypoint detection is the task of identifying meaningful distinctive points or features in an image.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4c15a98fdabb31e019d38076d691da7391cefa47 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/mask-generation/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAgEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.js new file mode 100644 index 0000000000000000000000000000000000000000..2013d36d168346be75ffdb1651778dd4df3abfb5 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/mask-generation/data.js @@ -0,0 +1,64 @@ +const taskData = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple Vision tasks.", + id: "merve/coco2017", + }, + { + description: "Medical Imaging dataset of the Human Brain for segmentation and mask generating tasks", + id: "rocky93/BraTS_segmentation", + }, + ], + demo: { + inputs: [ + { + filename: "mask-generation-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "mask-generation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: "IoU is used to measure the overlap between predicted mask and the ground truth mask.", + id: "Intersection over Union (IoU)", + }, + ], + models: [ + { + description: "Small yet powerful mask generation model.", + id: "Zigeng/SlimSAM-uniform-50", + }, + { + description: "Very strong mask generation model.", + id: "facebook/sam2-hiera-large", + }, + ], + spaces: [ + { + description: "An application that combines a mask generation model with a zero-shot object detection model for text-guided image segmentation.", + id: "merve/OWLSAM2", + }, + { + description: "An application that compares the performance of a large and a small mask generation model.", + id: "merve/slimsam", + }, + { + description: "An application based on an improved mask generation model.", + id: "SkalskiP/segment-anything-model-2", + }, + { + description: "An application to remove objects from videos using mask generation models.", + id: "SkalskiP/SAM_and_ProPainter", + }, + ], + summary: "Mask generation is the task of generating masks that identify a specific object or region of interest in a given image. Masks are often used in segmentation tasks, where they provide a precise way to isolate the object of interest for further processing or analysis.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..628b2c78e9a1f523dcab289b02218d52718855ac --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/object-detection/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAqFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.js new file mode 100644 index 0000000000000000000000000000000000000000..2722a892f542f7214b9d1080c0fc851c21b22287 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/data.js @@ -0,0 +1,84 @@ +const taskData = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple vision tasks.", + id: "merve/coco2017", + }, + { + description: "Multi-task computer vision benchmark.", + id: "merve/pascal-voc", + }, + ], + demo: { + inputs: [ + { + filename: "object-detection-input.jpg", + type: "img", + }, + ], + outputs: [ + { + filename: "object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid object detection model pre-trained on the COCO 2017 dataset.", + id: "facebook/detr-resnet-50", + }, + { + description: "Accurate object detection model.", + id: "IDEA-Research/dab-detr-resnet-50", + }, + { + description: "Fast and accurate object detection model.", + id: "PekingU/rtdetr_v2_r50vd", + }, + { + description: "Object detection model for low-lying objects.", + id: "StephanST/WALDO30", + }, + ], + spaces: [ + { + description: "Real-time object detection demo.", + id: "Roboflow/RF-DETR", + }, + { + description: "An application that contains various object detection models to try from.", + id: "Gradio-Blocks/Object-Detection-With-DETR-and-YOLOS", + }, + { + description: "A cutting-edge object detection application.", + id: "sunsmarterjieleaf/yolov12", + }, + { + description: "An object tracking, segmentation and inpainting application.", + id: "VIPLab/Track-Anything", + }, + { + description: "Very fast object tracking application based on object detection.", + id: "merve/RT-DETR-tracking-coco", + }, + ], + summary: "Object Detection models allow users to identify objects of certain defined classes. Object detection models receive an image as input and output the images with bounding boxes and labels on detected objects.", + widgetModels: ["facebook/detr-resnet-50"], + youtubeId: "WdAeKSOpxhw", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14661180189671f77efac91846a902f1f85d91a9 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts @@ -0,0 +1,74 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Object Detection inference + */ +export interface ObjectDetectionInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Object Detection + */ + parameters?: ObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Object Detection + */ +export interface ObjectDetectionParameters { + /** + * The probability necessary to make a prediction. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + /** + * The x-coordinate of the bottom-right corner of the bounding box. + */ + xmax: number; + /** + * The x-coordinate of the top-left corner of the bounding box. + */ + xmin: number; + /** + * The y-coordinate of the bottom-right corner of the bounding box. + */ + ymax: number; + /** + * The y-coordinate of the top-left corner of the bounding box. + */ + ymin: number; + [property: string]: unknown; +} +export type ObjectDetectionOutput = ObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Object Detection task + */ +export interface ObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * The predicted label for the bounding box. + */ + label: string; + /** + * The associated score / probability. + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..64ac1c743fb4d62b1c12cceb58c692b409d268e1 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/object-detection/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,yBAAyB,CAAC;IACvC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,EAAE,CAAC;AACnE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/object-detection/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5db21ad2a46706da5b2235bfb24ee2a5a9cc0757 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/placeholder/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAgBf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.js new file mode 100644 index 0000000000000000000000000000000000000000..6ce240dc187bfc5153e73c451aa90fef21e42ad5 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/placeholder/data.js @@ -0,0 +1,18 @@ +const taskData = { + datasets: [], + demo: { + inputs: [], + outputs: [], + }, + isPlaceholder: true, + metrics: [], + models: [], + spaces: [], + summary: "", + widgetModels: [], + youtubeId: undefined, + /// If this is a subtask, link to the most general task ID + /// (eg, text-generation is the canonical ID of text-simplification) + canonicalId: undefined, +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..796067455ff80c17a422ec70958bc4311e8124e3 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/question-answering/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAsEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.js new file mode 100644 index 0000000000000000000000000000000000000000..558d87c71d03d87bf4c0080f5a411e2df8c8adfd --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/data.js @@ -0,0 +1,69 @@ +const taskData = { + datasets: [ + { + // TODO write proper description + description: "A famous question answering dataset based on English articles from Wikipedia.", + id: "squad_v2", + }, + { + // TODO write proper description + description: "A dataset of aggregated anonymized actual queries issued to the Google search engine.", + id: "natural_questions", + }, + ], + demo: { + inputs: [ + { + label: "Question", + content: "Which name is also used to describe the Amazon rainforest in English?", + type: "text", + }, + { + label: "Context", + content: "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: "Amazonia", + type: "text", + }, + ], + }, + metrics: [ + { + description: "Exact Match is a metric based on the strict character match of the predicted answer and the right answer. For answers predicted correctly, the Exact Match will be 1. Even if only one character is different, Exact Match will be 0", + id: "exact-match", + }, + { + description: " The F1-Score metric is useful if we value both false positives and false negatives equally. The F1-Score is calculated on each word in the predicted sequence against the correct answer", + id: "f1", + }, + ], + models: [ + { + description: "A robust baseline model for most question answering domains.", + id: "deepset/roberta-base-squad2", + }, + { + description: "Small yet robust model that can answer questions.", + id: "distilbert/distilbert-base-cased-distilled-squad", + }, + { + description: "A special model that can answer questions from tables.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that can answer a long question from Wikipedia.", + id: "deepset/wikipedia-assistant", + }, + ], + summary: "Question Answering models can retrieve the answer to a question from a given text, which is useful for searching for an answer in a document. Some question answering models can generate answers without context!", + widgetModels: ["deepset/roberta-base-squad2"], + youtubeId: "ajPx5LwJD-I", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0956db6c47a1bb07ee6c2bd1fd5603b4d66b406f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts @@ -0,0 +1,98 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Question Answering inference + */ +export interface QuestionAnsweringInput { + /** + * One (context, question) pair to answer + */ + inputs: QuestionAnsweringInputData; + /** + * Additional inference parameters for Question Answering + */ + parameters?: QuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (context, question) pair to answer + */ +export interface QuestionAnsweringInputData { + /** + * The context to be used for answering the question + */ + context: string; + /** + * The question to be answered + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Question Answering + */ +export interface QuestionAnsweringParameters { + /** + * Attempts to align the answer to real words. Improves quality on space separated + * languages. Might hurt on non-space-separated languages (like Japanese or Chinese) + */ + align_to_words?: boolean; + /** + * If the context is too long to fit with the question for the model, it will be split in + * several chunks with some overlap. This argument controls the size of that overlap. + */ + doc_stride?: number; + /** + * Whether to accept impossible as an answer. + */ + handle_impossible_answer?: boolean; + /** + * The maximum length of predicted answers (e.g., only answers with a shorter length are + * considered). + */ + max_answer_len?: number; + /** + * The maximum length of the question after tokenization. It will be truncated if needed. + */ + max_question_len?: number; + /** + * The maximum length of the total sentence (context + question) in tokens of each chunk + * passed to the model. The context will be split in several chunks (using docStride as + * overlap) if needed. + */ + max_seq_len?: number; + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type QuestionAnsweringOutput = QuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Question Answering task + */ +export interface QuestionAnsweringOutputElement { + /** + * The answer to the question. + */ + answer: string; + /** + * The character position in the input where the answer ends. + */ + end: number; + /** + * The probability associated to the answer. + */ + score: number; + /** + * The character position in the input where the answer begins. + */ + start: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..bf237c1fb8f8f2de5f02091faf25bed254771a75 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/question-answering/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,MAAM,EAAE,0BAA0B,CAAC;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,EAAE,CAAC;AACvE;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/question-answering/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..da6859fc13463382ff95b67b4ee618679d06845c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/reinforcement-learning/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAsEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.js new file mode 100644 index 0000000000000000000000000000000000000000..54e250c9ccb5507b7941e74eaf3658f40b2578ca --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/reinforcement-learning/data.js @@ -0,0 +1,67 @@ +const taskData = { + datasets: [ + { + description: "A curation of widely used datasets for Data Driven Deep Reinforcement Learning (D4RL)", + id: "edbeeching/decision_transformer_gym_replay", + }, + ], + demo: { + inputs: [ + { + label: "State", + content: "Red traffic light, pedestrians are about to pass.", + type: "text", + }, + ], + outputs: [ + { + label: "Action", + content: "Stop the car.", + type: "text", + }, + { + label: "Next State", + content: "Yellow light, pedestrians have crossed.", + type: "text", + }, + ], + }, + metrics: [ + { + description: "Accumulated reward across all time steps discounted by a factor that ranges between 0 and 1 and determines how much the agent optimizes for future relative to immediate rewards. Measures how good is the policy ultimately found by a given algorithm considering uncertainty over the future.", + id: "Discounted Total Reward", + }, + { + description: "Average return obtained after running the policy for a certain number of evaluation episodes. As opposed to total reward, mean reward considers how much reward a given algorithm receives while learning.", + id: "Mean Reward", + }, + { + description: "Measures how good a given algorithm is after a predefined time. Some algorithms may be guaranteed to converge to optimal behavior across many time steps. However, an agent that reaches an acceptable level of optimality after a given time horizon may be preferable to one that ultimately reaches optimality but takes a long time.", + id: "Level of Performance After Some Time", + }, + ], + models: [ + { + description: "A Reinforcement Learning model trained on expert data from the Gym Hopper environment", + id: "edbeeching/decision-transformer-gym-hopper-expert", + }, + { + description: "A PPO agent playing seals/CartPole-v0 using the stable-baselines3 library and the RL Zoo.", + id: "HumanCompatibleAI/ppo-seals-CartPole-v0", + }, + ], + spaces: [ + { + description: "An application for a cute puppy agent learning to catch a stick.", + id: "ThomasSimonini/Huggy", + }, + { + description: "An application to play Snowball Fight with a reinforcement learning agent.", + id: "ThomasSimonini/SnowballFight", + }, + ], + summary: "Reinforcement learning is the computational approach of learning from action by interacting with an environment through trial and error and receiving rewards (negative or positive) as feedback", + widgetModels: [], + youtubeId: "q0BiUn5LiBc", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d457bc40bbb8d21b76a24e583381c7ea694b063e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/sentence-similarity/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAoGf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.js new file mode 100644 index 0000000000000000000000000000000000000000..3dca75956ece6eee1ee2275a3a7c82b4e96f3a88 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/data.js @@ -0,0 +1,97 @@ +const taskData = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 0.623, + }, + { + label: "This is so difficult, like rocket science.", + score: 0.413, + }, + { + label: "I can't believe how much I struggled with this.", + score: 0.256, + }, + ], + }, + ], + }, + metrics: [ + { + description: "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: "The similarity of the embeddings is evaluated mainly on cosine similarity. It is calculated as the cosine of the angle between two vectors. It is particularly useful when your texts are not the same length", + id: "Cosine Similarity", + }, + ], + models: [ + { + description: "This model works well for sentences and paragraphs and can be used for clustering/grouping and semantic searches.", + id: "sentence-transformers/all-mpnet-base-v2", + }, + { + description: "A multilingual robust sentence similarity model.", + id: "BAAI/bge-m3", + }, + { + description: "A robust sentence similarity model.", + id: "HIT-TMG/KaLM-embedding-multilingual-mini-instruct-v1.5", + }, + ], + spaces: [ + { + description: "An application that leverages sentence similarity to answer questions from YouTube videos.", + id: "Gradio-Blocks/Ask_Questions_To_YouTube_Videos", + }, + { + description: "An application that retrieves relevant PubMed abstracts for a given online article which can be used as further references.", + id: "Gradio-Blocks/pubmed-abstract-retriever", + }, + { + description: "An application that leverages sentence similarity to summarize text.", + id: "nickmuchi/article-text-summarizer", + }, + { + description: "A guide that explains how Sentence Transformers can be used for semantic search.", + id: "sentence-transformers/Sentence_Transformers_for_semantic_search", + }, + ], + summary: "Sentence Similarity is the task of determining how similar two texts are. Sentence similarity models convert input texts into vectors (embeddings) that capture semantic information and calculate how close (similar) they are between them. This task is particularly useful for information retrieval and clustering/grouping.", + widgetModels: ["sentence-transformers/all-MiniLM-L6-v2"], + youtubeId: "VCZq5AkbNEU", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7836ed35d431c28daa542326aca7ea75563f5b9c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts @@ -0,0 +1,32 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +export type SentenceSimilarityOutput = number[]; +/** + * Inputs for Sentence similarity inference + */ +export interface SentenceSimilarityInput { + inputs: SentenceSimilarityInputData; + /** + * Additional inference parameters for Sentence Similarity + */ + parameters?: { + [key: string]: unknown; + }; + [property: string]: unknown; +} +export interface SentenceSimilarityInputData { + /** + * A list of strings which will be compared against the source_sentence. + */ + sentences: string[]; + /** + * The string that you wish to compare the other strings with. This can be a phrase, + * sentence, or longer passage, depending on the model being used. + */ + source_sentence: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..1a31ca5b3e6cbd66e566a52e86cba1a024684a97 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/sentence-similarity/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,EAAE,CAAC;AAChD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,MAAM,EAAE,2BAA2B,CAAC;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/sentence-similarity/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7f112b24d58cd35588a17df77cc61bad268f5b37 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/summarization/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAuEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.js new file mode 100644 index 0000000000000000000000000000000000000000..6e984a19398bec160a6bf2414110ee132d5f92b3 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/data.js @@ -0,0 +1,67 @@ +const taskData = { + canonicalId: "text-generation", + datasets: [ + { + description: "News articles in five different languages along with their summaries. Widely used for benchmarking multilingual summarization models.", + id: "mlsum", + }, + { + description: "English conversations and their summaries. Useful for benchmarking conversational agents.", + id: "samsum", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. It was the first structure to reach a height of 300 metres. Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building. It was the first structure to reach a height of 300 metres.", + type: "text", + }, + ], + }, + metrics: [ + { + description: "The generated sequence is compared against its summary, and the overlap of tokens are counted. ROUGE-N refers to overlap of N subsequent tokens, ROUGE-1 refers to overlap of single tokens and ROUGE-2 is the overlap of two subsequent tokens.", + id: "rouge", + }, + ], + models: [ + { + description: "A strong summarization model trained on English news articles. Excels at generating factual summaries.", + id: "facebook/bart-large-cnn", + }, + { + description: "A summarization model trained on medical articles.", + id: "Falconsai/medical_summarization", + }, + ], + spaces: [ + { + description: "An application that can summarize long paragraphs.", + id: "pszemraj/summarize-long-text", + }, + { + description: "A much needed summarization application for terms and conditions.", + id: "ml6team/distilbart-tos-summarizer-tosdr", + }, + { + description: "An application that summarizes long documents.", + id: "pszemraj/document-summarization", + }, + { + description: "An application that can detect errors in abstractive summarization.", + id: "ml6team/post-processing-summarization", + }, + ], + summary: "Summarization is the task of producing a shorter version of a document while preserving its important information. Some models can extract text from the original input, while other models can generate entirely new text.", + widgetModels: ["facebook/bart-large-cnn"], + youtubeId: "yHnr5Dk2zCI", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3153fbb4fdb5eeb040516b68b90dfdda2057798 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts @@ -0,0 +1,54 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Summarization inference + */ +export interface SummarizationInput { + /** + * The input text to summarize. + */ + inputs: string; + /** + * Additional inference parameters for summarization. + */ + parameters?: SummarizationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for summarization. + */ +export interface SummarizationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The truncation strategy to use. + */ + truncation?: SummarizationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type SummarizationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Summarization task + */ +export interface SummarizationOutput { + /** + * The summarized text. + */ + summary_text: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e2834ebbaa672e6227241c2f2c7fad3e67a586ba --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/summarization/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,mBAAmB,CAAC,EAAE;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF;;OAEG;IACH,UAAU,CAAC,EAAE,+BAA+B,CAAC;IAC7C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,CAAC;AACjH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/summarization/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7df5547173450d1e1d1218adc4b5e3c9a2d90075 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/table-question-answering/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAsDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.js new file mode 100644 index 0000000000000000000000000000000000000000..7afd54c44761c1c33a555717c3254c51bd022d8e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/data.js @@ -0,0 +1,52 @@ +const taskData = { + datasets: [ + { + description: "The WikiTableQuestions dataset is a large-scale dataset for the task of question answering on semi-structured tables.", + id: "wikitablequestions", + }, + { + description: "WikiSQL is a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia.", + id: "wikisql", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Rank", "Name", "No.of reigns", "Combined days"], + ["1", "lou Thesz", "3", "3749"], + ["2", "Ric Flair", "8", "3103"], + ["3", "Harley Race", "7", "1799"], + ], + type: "tabular", + }, + { label: "Question", content: "What is the number of reigns for Harley Race?", type: "text" }, + ], + outputs: [{ label: "Result", content: "7", type: "text" }], + }, + metrics: [ + { + description: "Checks whether the predicted answer(s) is the same as the ground-truth answer(s).", + id: "Denotation Accuracy", + }, + ], + models: [ + { + description: "A table question answering model that is capable of neural SQL execution, i.e., employ TAPEX to execute a SQL query on a given table.", + id: "microsoft/tapex-base", + }, + { + description: "A robust table question answering model.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that answers questions based on table CSV files.", + id: "katanaml/table-query", + }, + ], + summary: "Table Question Answering (Table QA) is the answering a question about an information on a given table.", + widgetModels: ["google/tapas-base-finetuned-wtq"], +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfe5048481141e19695ee9459efa19ceda69949d --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts @@ -0,0 +1,84 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Table Question Answering inference + */ +export interface TableQuestionAnsweringInput { + /** + * One (table, question) pair to answer + */ + inputs: TableQuestionAnsweringInputData; + /** + * Additional inference parameters for Table Question Answering + */ + parameters?: TableQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (table, question) pair to answer + */ +export interface TableQuestionAnsweringInputData { + /** + * The question to be answered about the table + */ + question: string; + /** + * The table to serve as context for the questions + */ + table: { + [key: string]: string[]; + }; + [property: string]: unknown; +} +/** + * Additional inference parameters for Table Question Answering + */ +export interface TableQuestionAnsweringParameters { + /** + * Activates and controls padding. + */ + padding?: Padding; + /** + * Whether to do inference sequentially or as a batch. Batching is faster, but models like + * SQA require the inference to be done sequentially to extract relations within sequences, + * given their conversational nature. + */ + sequential?: boolean; + /** + * Activates and controls truncation. + */ + truncation?: boolean; + [property: string]: unknown; +} +/** + * Activates and controls padding. + */ +export type Padding = "do_not_pad" | "longest" | "max_length"; +export type TableQuestionAnsweringOutput = TableQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Table Question Answering task + */ +export interface TableQuestionAnsweringOutputElement { + /** + * If the model has an aggregator, this returns the aggregator. + */ + aggregator?: string; + /** + * The answer of the question given the table. If there is an aggregator, the answer will be + * preceded by `AGGREGATOR >`. + */ + answer: string; + /** + * List of strings made up of the answer cell values. + */ + cells: string[]; + /** + * Coordinates of the cells of the answers. + */ + coordinates: Array; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..662dc6b5c7390184441f95d326a449f226b02dbb --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/table-question-answering/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE,+BAA+B,CAAC;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,gCAAgC,CAAC;IAC9C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACxB,CAAC;IACF,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC;AAC9D,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,EAAE,CAAC;AACjF;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/table-question-answering/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5a327b8a6c01a349e8a3eb677fa7d63a604fd2a6 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/tabular-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA+Df,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..4897081943f0c5206b1fa979aed8e8756339a671 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-classification/data.js @@ -0,0 +1,65 @@ +const taskData = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Glucose", "Blood Pressure ", "Skin Thickness", "Insulin", "BMI"], + ["148", "72", "35", "0", "33.6"], + ["150", "50", "30", "0", "35.1"], + ["141", "60", "29", "1", "39.2"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["Diabetes"], ["1"], ["1"], ["0"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "Breast cancer prediction model based on decision trees.", + id: "scikit-learn/cancer-prediction-trees", + }, + ], + spaces: [ + { + description: "An application that can predict defective products on a production line.", + id: "scikit-learn/tabular-playground", + }, + { + description: "An application that compares various tabular classification techniques on different datasets.", + id: "scikit-learn/classification", + }, + ], + summary: "Tabular classification is the task of classifying a target category (a group) based on set of attributes.", + widgetModels: ["scikit-learn/tabular-playground"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8603a1fb917be27322c628610908f41d7228a969 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/tabular-regression/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAoDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.js new file mode 100644 index 0000000000000000000000000000000000000000..d283cd9f04db9934267603a3aa1b5df58f8ba361 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/tabular-regression/data.js @@ -0,0 +1,53 @@ +const taskData = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Car Name", "Horsepower", "Weight"], + ["ford torino", "140", "3,449"], + ["amc hornet", "97", "2,774"], + ["toyota corolla", "65", "1,773"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["MPG (miles per gallon)"], ["17"], ["18"], ["31"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "mse", + }, + { + description: "Coefficient of determination (or R-squared) is a measure of how well the model fits the data. Higher R-squared is considered a better fit.", + id: "r-squared", + }, + ], + models: [ + { + description: "Fish weight prediction based on length measurements and species.", + id: "scikit-learn/Fish-Weight", + }, + ], + spaces: [ + { + description: "An application that can predict weight of a fish based on set of attributes.", + id: "scikit-learn/fish-weight-prediction", + }, + ], + summary: "Tabular regression is the task of predicting a numerical value given a set of attributes.", + widgetModels: ["scikit-learn/Fish-Weight"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..90bc031f2e0d672008b73b37088e7779fba975a2 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAkGf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..d7d1664356ff91dc99f9ee31504dd097d84b5d56 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/data.js @@ -0,0 +1,98 @@ +const taskData = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: "A text classification dataset used to benchmark natural language inference models", + id: "stanfordnlp/snli", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love Hugging Face!", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "POSITIVE", + score: 0.9, + }, + { + label: "NEUTRAL", + score: 0.1, + }, + { + label: "NEGATIVE", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "The F1 metric is the harmonic mean of the precision and recall. It can be calculated as: F1 = 2 * (precision * recall) / (precision + recall)", + id: "f1", + }, + ], + models: [ + { + description: "A robust model trained for sentiment analysis.", + id: "distilbert/distilbert-base-uncased-finetuned-sst-2-english", + }, + { + description: "A sentiment analysis model specialized in financial sentiment.", + id: "ProsusAI/finbert", + }, + { + description: "A sentiment analysis model specialized in analyzing tweets.", + id: "cardiffnlp/twitter-roberta-base-sentiment-latest", + }, + { + description: "A model that can classify languages.", + id: "papluca/xlm-roberta-base-language-detection", + }, + { + description: "A model that can classify text generation attacks.", + id: "meta-llama/Prompt-Guard-86M", + }, + ], + spaces: [ + { + description: "An application that can classify financial sentiment.", + id: "IoannisTr/Tech_Stocks_Trading_Assistant", + }, + { + description: "A dashboard that contains various text classification tasks.", + id: "miesnerjacob/Multi-task-NLP", + }, + { + description: "An application that analyzes user reviews in healthcare.", + id: "spacy/healthsea-demo", + }, + ], + summary: "Text Classification is the task of assigning a label or class to a given text. Some use cases are sentiment analysis, natural language inference, and assessing grammatical correctness.", + widgetModels: ["distilbert/distilbert-base-uncased-finetuned-sst-2-english"], + youtubeId: "leNG9fN9FQU", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff29b09e9a909bb94b21f96d8a939dadcd7deb3b --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text Classification inference + */ +export interface TextClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Text Classification + */ + parameters?: TextClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text Classification + */ +export interface TextClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type TextClassificationOutput = TextClassificationOutputElement[]; +/** + * Outputs of inference for the Text Classification task + */ +export interface TextClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..328ab1be6f6979d09ce733cb3208285bba6b5fba --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,4BAA4B,CAAC;IAC1C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,EAAE,CAAC;AACzE;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-classification/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..1cb375d4130e99f5926dd0eacd8fe90366df7b10 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-generation/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA6Hf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.js new file mode 100644 index 0000000000000000000000000000000000000000..557887b6b3b6b450edc3abc8178ede1539619d90 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/data.js @@ -0,0 +1,123 @@ +const taskData = { + datasets: [ + { + description: "Multilingual dataset used to evaluate text generation models.", + id: "CohereForAI/Global-MMLU", + }, + { + description: "High quality multilingual data used to train text-generation models.", + id: "HuggingFaceFW/fineweb-2", + }, + { + description: "Truly open-source, curated and cleaned dialogue dataset.", + id: "HuggingFaceH4/ultrachat_200k", + }, + { + description: "A reasoning dataset.", + id: "open-r1/OpenThoughts-114k-math", + }, + { + description: "A multilingual instruction dataset with preference ratings on responses.", + id: "allenai/tulu-3-sft-mixture", + }, + { + description: "A large synthetic dataset for alignment of text generation models.", + id: "HuggingFaceTB/smoltalk", + }, + { + description: "A dataset made for training text generation models solving math questions.", + id: "HuggingFaceTB/finemath", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Once upon a time,", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: "Once upon a time, we knew that our ancestors were on the verge of extinction. The great explorers and poets of the Old World, from Alexander the Great to Chaucer, are dead and gone. A good many of our ancient explorers and poets have", + type: "text", + }, + ], + }, + metrics: [ + { + description: "Cross Entropy is a metric that calculates the difference between two probability distributions. Each probability distribution is the distribution of predicted words", + id: "Cross Entropy", + }, + { + description: "The Perplexity metric is the exponential of the cross-entropy loss. It evaluates the probabilities assigned to the next word by the model. Lower perplexity indicates better performance", + id: "Perplexity", + }, + ], + models: [ + { description: "A text-generation model trained to follow instructions.", id: "google/gemma-2-2b-it" }, + { + description: "Powerful text generation model for coding.", + id: "Qwen/Qwen3-Coder-480B-A35B-Instruct", + }, + { + description: "Great text generation model with top-notch tool calling capabilities.", + id: "openai/gpt-oss-120b", + }, + { + description: "Powerful text generation model.", + id: "zai-org/GLM-4.5", + }, + { + description: "A powerful small model with reasoning capabilities.", + id: "Qwen/Qwen3-4B-Thinking-2507", + }, + { + description: "Strong conversational model that supports very long instructions.", + id: "Qwen/Qwen2.5-7B-Instruct-1M", + }, + { + description: "Text generation model used to write code.", + id: "Qwen/Qwen2.5-Coder-32B-Instruct", + }, + { + description: "Powerful reasoning based open large language model.", + id: "deepseek-ai/DeepSeek-R1", + }, + ], + spaces: [ + { + description: "An application that writes and executes code from text instructions and supports many models.", + id: "akhaliq/anycoder", + }, + { + description: "An application that builds websites from natural language prompts.", + id: "enzostvs/deepsite", + }, + { + description: "A leaderboard for comparing chain-of-thought performance of models.", + id: "logikon/open_cot_leaderboard", + }, + { + description: "An text generation based application based on a very powerful LLaMA2 model.", + id: "ysharma/Explore_llamav2_with_TGI", + }, + { + description: "An text generation based application to converse with Zephyr model.", + id: "HuggingFaceH4/zephyr-chat", + }, + { + description: "A leaderboard that ranks text generation models based on blind votes from people.", + id: "lmsys/chatbot-arena-leaderboard", + }, + { + description: "An chatbot to converse with a very powerful text generation model.", + id: "mlabonne/phixtral-chat", + }, + ], + summary: "Generating text is the task of generating new text given another text. These models can, for example, fill in incomplete text or paraphrase.", + widgetModels: ["mistralai/Mistral-Nemo-Instruct-2407"], + youtubeId: "e9gNEAlsOvU", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0495ad64fc55455d8b2a2933ae99b37d86775f1f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts @@ -0,0 +1,188 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Text Generation Input. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationInput { + inputs: string; + parameters?: TextGenerationInputGenerateParameters; + stream?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGenerateParameters { + /** + * Lora adapter id + */ + adapter_id?: string; + /** + * Generate best_of sequences and return the one if the highest token logprobs. + */ + best_of?: number; + /** + * Whether to return decoder input token logprobs and ids. + */ + decoder_input_details?: boolean; + /** + * Whether to return generation details. + */ + details?: boolean; + /** + * Activate logits sampling. + */ + do_sample?: boolean; + /** + * The parameter for frequency penalty. 1.0 means no penalty + * Penalize new tokens based on their existing frequency in the text so far, + * decreasing the model's likelihood to repeat the same line verbatim. + */ + frequency_penalty?: number; + grammar?: TextGenerationInputGrammarType; + /** + * Maximum number of tokens to generate. + */ + max_new_tokens?: number; + /** + * The parameter for repetition penalty. 1.0 means no penalty. + * See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details. + */ + repetition_penalty?: number; + /** + * Whether to prepend the prompt to the generated text + */ + return_full_text?: boolean; + /** + * Random sampling seed. + */ + seed?: number; + /** + * Stop generating tokens if a member of `stop` is generated. + */ + stop?: string[]; + /** + * The value used to module the logits distribution. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-n-filtering. + */ + top_n_tokens?: number; + /** + * Top-p value for nucleus sampling. + */ + top_p?: number; + /** + * Truncate inputs tokens to the given size. + */ + truncate?: number; + /** + * Typical Decoding mass + * See [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) + * for more information. + */ + typical_p?: number; + /** + * Watermarking with [A Watermark for Large Language + * Models](https://arxiv.org/abs/2301.10226). + */ + watermark?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGrammarType { + type: Type; + /** + * A string that represents a [JSON Schema](https://json-schema.org/). + * + * JSON Schema is a declarative language that allows to annotate JSON documents + * with types and descriptions. + */ + value: unknown; + [property: string]: unknown; +} +export type Type = "json" | "regex" | "json_schema"; +/** + * Text Generation Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationOutput { + details?: TextGenerationOutputDetails; + generated_text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputDetails { + best_of_sequences?: TextGenerationOutputBestOfSequence[]; + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export interface TextGenerationOutputBestOfSequence { + finish_reason: TextGenerationOutputFinishReason; + generated_text: string; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export type TextGenerationOutputFinishReason = "length" | "eos_token" | "stop_sequence"; +export interface TextGenerationOutputPrefillToken { + id: number; + logprob: number; + text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} +/** + * Text Generation Stream Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationStreamOutput { + details?: TextGenerationStreamOutputStreamDetails; + generated_text?: string; + index: number; + token: TextGenerationStreamOutputToken; + top_tokens?: TextGenerationStreamOutputToken[]; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputStreamDetails { + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + input_length: number; + seed?: number; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..44c5f235fb539f2e65e39fae7af67582b0bf0a04 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-generation/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,qCAAqC,CAAC;IACnD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,WAAW,qCAAqC;IACrD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,8BAA8B,CAAC;IACzC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,C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end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-generation/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4e751a3bbd1ecc3171184413375e276af5c186d3 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-ranking/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAsFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.js new file mode 100644 index 0000000000000000000000000000000000000000..75c662056be4d92a33b647048b078ff2e5b70a48 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-ranking/data.js @@ -0,0 +1,84 @@ +const taskData = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 2.2006407, + }, + { + label: "This is so difficult, like rocket science.", + score: -6.2634873, + }, + { + label: "I can't believe how much I struggled with this.", + score: -10.251488, + }, + ], + }, + ], + }, + metrics: [ + { + description: "Discounted Cumulative Gain (DCG) measures the gain, or usefulness, of search results discounted by their position. The normalization is done by dividing the DCG by the ideal DCG, which is the DCG of the perfect ranking.", + id: "Normalized Discounted Cumulative Gain", + }, + { + description: "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: "Mean Average Precision (mAP) is the overall average of the Average Precision (AP) values, where AP is the Area Under the PR Curve (AUC-PR)", + id: "Mean Average Precision", + }, + ], + models: [ + { + description: "An extremely efficient text ranking model trained on a web search dataset.", + id: "cross-encoder/ms-marco-MiniLM-L6-v2", + }, + { + description: "A strong multilingual text reranker model.", + id: "Alibaba-NLP/gte-multilingual-reranker-base", + }, + { + description: "An efficient text ranking model that punches above its weight.", + id: "Alibaba-NLP/gte-reranker-modernbert-base", + }, + ], + spaces: [], + summary: "Text Ranking is the task of ranking a set of texts based on their relevance to a query. Text ranking models are trained on large datasets of queries and relevant documents to learn how to rank documents based on their relevance to the query. This task is particularly useful for search engines and information retrieval systems.", + widgetModels: ["cross-encoder/ms-marco-MiniLM-L6-v2"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a56f91f9a5ea203fe8a085e3c5d555f5306b119e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-3d/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAmDf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.js new file mode 100644 index 0000000000000000000000000000000000000000..bac716d4308cbd938b635061e83ecd6d34d277d2 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-3d/data.js @@ -0,0 +1,53 @@ +const taskData = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "Descriptive captions for 3D objects in Objaverse.", + id: "tiange/Cap3D", + }, + ], + demo: { + inputs: [ + { + label: "Prompt", + content: "a cat statue", + type: "text", + }, + ], + outputs: [ + { + label: "Result", + content: "text-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Text-to-3D mesh model by OpenAI", + id: "openai/shap-e", + }, + { + description: "Generative 3D gaussian splatting model.", + id: "ashawkey/LGM", + }, + ], + spaces: [ + { + description: "Text-to-3D demo with mesh outputs.", + id: "hysts/Shap-E", + }, + { + description: "Text/image-to-3D demo with splat outputs.", + id: "ashawkey/LGM", + }, + ], + summary: "Text-to-3D models take in text input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..811850173233fed08a447e510bede7a576e09822 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts @@ -0,0 +1,134 @@ +/** + * Outputs of inference for the Text To Audio task + */ +export interface TextToAudioOutput { + /** + * The generated audio waveform. + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Audio inference + */ +export interface TextToAudioInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Audio + */ + parameters?: TextToAudioParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Audio + */ +export interface TextToAudioParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..eec3725373942525186fac3145889c21d7eab2d7 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-audio/inference.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,KAAK,EAAE,IAAI,CAAC;IACZ;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,qBAAqB,CAAC,EAAE,oBAAoB,CAAC;IAC7C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-audio/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f3b6ad845035578c7d5be1c8af56971c67a1f3f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-image/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAmGf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.js new file mode 100644 index 0000000000000000000000000000000000000000..9ab998a4f0f3ab6f71b55c27ac9ab6cc5232e0b6 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/data.js @@ -0,0 +1,97 @@ +const taskData = { + datasets: [ + { + description: "RedCaps is a large-scale dataset of 12M image-text pairs collected from Reddit.", + id: "red_caps", + }, + { + description: "Conceptual Captions is a dataset consisting of ~3.3M images annotated with captions.", + id: "conceptual_captions", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: "The Inception Score (IS) measure assesses diversity and meaningfulness. It uses a generated image sample to predict its label. A higher score signifies more diverse and meaningful images.", + id: "IS", + }, + { + description: "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: "R-precision assesses how the generated image aligns with the provided text description. It uses the generated images as queries to retrieve relevant text descriptions. The top 'r' relevant descriptions are selected and used to calculate R-precision as r/R, where 'R' is the number of ground truth descriptions associated with the generated images. A higher R-precision value indicates a better model.", + id: "R-Precision", + }, + ], + models: [ + { + description: "One of the most powerful image generation models that can generate realistic outputs.", + id: "black-forest-labs/FLUX.1-Krea-dev", + }, + { + description: "A powerful image generation model.", + id: "Qwen/Qwen-Image", + }, + { + description: "Powerful and fast image generation model.", + id: "ByteDance/SDXL-Lightning", + }, + { + description: "A powerful text-to-image model.", + id: "ByteDance/Hyper-SD", + }, + ], + spaces: [ + { + description: "A powerful text-to-image application.", + id: "stabilityai/stable-diffusion-3-medium", + }, + { + description: "A text-to-image application to generate comics.", + id: "jbilcke-hf/ai-comic-factory", + }, + { + description: "An application to match multiple custom image generation models.", + id: "multimodalart/flux-lora-lab", + }, + { + description: "A powerful yet very fast image generation application.", + id: "latent-consistency/lcm-lora-for-sdxl", + }, + { + description: "A gallery to explore various text-to-image models.", + id: "multimodalart/LoraTheExplorer", + }, + { + description: "An application for `text-to-image`, `image-to-image` and image inpainting.", + id: "ArtGAN/Stable-Diffusion-ControlNet-WebUI", + }, + { + description: "An application to generate realistic images given photos of a person and a prompt.", + id: "InstantX/InstantID", + }, + ], + summary: "Text-to-image is the task of generating images from input text. These pipelines can also be used to modify and edit images based on text prompts.", + widgetModels: ["black-forest-labs/FLUX.1-dev"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af711fe85ee463c28cdd3f514466a6344a3a2cdb --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts @@ -0,0 +1,66 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Image inference + */ +export interface TextToImageInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Image + */ + parameters?: TextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Image + */ +export interface TextToImageParameters { + /** + * A higher guidance scale value encourages the model to generate images closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * The height in pixels of the output image + */ + height?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Override the scheduler with a compatible one. + */ + scheduler?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The width in pixels of the output image + */ + width?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Image task + */ +export interface TextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..03467437eb89c69ccf8ef265aa92d9e6eae427e5 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-image/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-image/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..ed4c56895bf73bf3252bfe24ad8c688f910332fc --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAiFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.js new file mode 100644 index 0000000000000000000000000000000000000000..76d375ab5181baff63bfaa6dc812ad2c845831bd --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/data.js @@ -0,0 +1,82 @@ +const taskData = { + canonicalId: "text-to-audio", + datasets: [ + { + description: "10K hours of multi-speaker English dataset.", + id: "parler-tts/mls_eng_10k", + }, + { + description: "Multi-speaker English dataset.", + id: "mythicinfinity/libritts_r", + }, + { + description: "Multi-lingual dataset.", + id: "facebook/multilingual_librispeech", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love audio models on the Hub!", + type: "text", + }, + ], + outputs: [ + { + filename: "audio.wav", + type: "audio", + }, + ], + }, + metrics: [ + { + description: "The Mel Cepstral Distortion (MCD) metric is used to calculate the quality of generated speech.", + id: "mel cepstral distortion", + }, + ], + models: [ + { + description: "Small yet powerful TTS model.", + id: "KittenML/kitten-tts-nano-0.1", + }, + { + description: "Bleeding edge TTS model.", + id: "ResembleAI/chatterbox", + }, + { + description: "A massively multi-lingual TTS model.", + id: "fishaudio/fish-speech-1.5", + }, + { + description: "A text-to-dialogue model.", + id: "nari-labs/Dia-1.6B-0626", + }, + ], + spaces: [ + { + description: "An application for generate high quality speech in different languages.", + id: "hexgrad/Kokoro-TTS", + }, + { + description: "A multilingual text-to-speech application.", + id: "fishaudio/fish-speech-1", + }, + { + description: "Performant TTS application.", + id: "ResembleAI/Chatterbox", + }, + { + description: "An application to compare different TTS models.", + id: "TTS-AGI/TTS-Arena-V2", + }, + { + description: "An application that generates podcast episodes.", + id: "ngxson/kokoro-podcast-generator", + }, + ], + summary: "Text-to-Speech (TTS) is the task of generating natural sounding speech given text input. TTS models can be extended to have a single model that generates speech for multiple speakers and multiple languages.", + widgetModels: ["suno/bark"], + youtubeId: "NW62DpzJ274", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6cc131914ae1bf76593f4a2958c5cda23baff842 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts @@ -0,0 +1,134 @@ +/** + * Outputs of inference for the Text To Speech task + */ +export interface TextToSpeechOutput { + /** + * The generated audio + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate?: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Speech inference + */ +export interface TextToSpeechInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Speech + */ + parameters?: TextToSpeechParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Speech + */ +export interface TextToSpeechParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..47fb15af47a221be88e3d57de5fdb4b950d5af25 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/inference.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,EAAE,IAAI,CAAC;IACZ;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,qBAAqB,CAAC,EAAE,oBAAoB,CAAC;IAC7C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-speech/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..15f63d971713a969dbf522ff03184c46e982cf0e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-video/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAqGf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.js new file mode 100644 index 0000000000000000000000000000000000000000..6659ef5d32e775ce846aa8faa0b6932c8fd2e0d1 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/data.js @@ -0,0 +1,97 @@ +const taskData = { + datasets: [ + { + description: "Microsoft Research Video to Text is a large-scale dataset for open domain video captioning", + id: "iejMac/CLIP-MSR-VTT", + }, + { + description: "UCF101 Human Actions dataset consists of 13,320 video clips from YouTube, with 101 classes.", + id: "quchenyuan/UCF101-ZIP", + }, + { + description: "A high-quality dataset for human action recognition in YouTube videos.", + id: "nateraw/kinetics", + }, + { + description: "A dataset of video clips of humans performing pre-defined basic actions with everyday objects.", + id: "HuggingFaceM4/something_something_v2", + }, + { + description: "This dataset consists of text-video pairs and contains noisy samples with irrelevant video descriptions", + id: "HuggingFaceM4/webvid", + }, + { + description: "A dataset of short Flickr videos for the temporal localization of events with descriptions.", + id: "iejMac/CLIP-DiDeMo", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: "Inception Score uses an image classification model that predicts class labels and evaluates how distinct and diverse the images are. A higher score indicates better video generation.", + id: "is", + }, + { + description: "Frechet Inception Distance uses an image classification model to obtain image embeddings. The metric compares mean and standard deviation of the embeddings of real and generated images. A smaller score indicates better video generation.", + id: "fid", + }, + { + description: "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A strong model for consistent video generation.", + id: "tencent/HunyuanVideo", + }, + { + description: "A text-to-video model with high fidelity motion and strong prompt adherence.", + id: "Lightricks/LTX-Video", + }, + { + description: "A text-to-video model focusing on physics-aware applications like robotics.", + id: "nvidia/Cosmos-1.0-Diffusion-7B-Text2World", + }, + { + description: "Very fast model for video generation.", + id: "Lightricks/LTX-Video-0.9.8-13B-distilled", + }, + ], + spaces: [ + { + description: "An application that generates video from text.", + id: "VideoCrafter/VideoCrafter", + }, + { + description: "Consistent video generation application.", + id: "Wan-AI/Wan2.1", + }, + { + description: "A cutting edge video generation application.", + id: "Pyramid-Flow/pyramid-flow", + }, + ], + summary: "Text-to-video models can be used in any application that requires generating consistent sequence of images from text. ", + widgetModels: ["Wan-AI/Wan2.2-TI2V-5B"], + youtubeId: undefined, +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c3791350c974ef6ec40fc61866deb614344b143 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts @@ -0,0 +1,58 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Video inference + */ +export interface TextToVideoInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Video + */ + parameters?: TextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Video + */ +export interface TextToVideoParameters { + /** + * A higher guidance scale value encourages the model to generate videos closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * One or several prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string[]; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Seed for the random number generator. + */ + seed?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Video task + */ +export interface TextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..420f50f10ede66c1dfc384c98c82e226bb0a2f14 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-video/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/text-to-video/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..be4523e103c5a787df5558ad8ae91a69cda08bb5 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/token-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAuFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..35308663b96f0600598a2092a9592e1c98f257d8 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/data.js @@ -0,0 +1,85 @@ +const taskData = { + datasets: [ + { + description: "A widely used dataset useful to benchmark named entity recognition models.", + id: "eriktks/conll2003", + }, + { + description: "A multilingual dataset of Wikipedia articles annotated for named entity recognition in over 150 different languages.", + id: "unimelb-nlp/wikiann", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + text: "My name is Omar and I live in Zürich.", + tokens: [ + { + type: "PERSON", + start: 11, + end: 15, + }, + { + type: "GPE", + start: 30, + end: 36, + }, + ], + type: "text-with-tokens", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "A robust performance model to identify people, locations, organizations and names of miscellaneous entities.", + id: "dslim/bert-base-NER", + }, + { + description: "A strong model to identify people, locations, organizations and names in multiple languages.", + id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english", + }, + { + description: "A token classification model specialized on medical entity recognition.", + id: "blaze999/Medical-NER", + }, + { + description: "Flair models are typically the state of the art in named entity recognition tasks.", + id: "flair/ner-english", + }, + ], + spaces: [ + { + description: "An application that can recognizes entities, extracts noun chunks and recognizes various linguistic features of each token.", + id: "spacy/gradio_pipeline_visualizer", + }, + ], + summary: "Token classification is a natural language understanding task in which a label is assigned to some tokens in a text. Some popular token classification subtasks are Named Entity Recognition (NER) and Part-of-Speech (PoS) tagging. NER models could be trained to identify specific entities in a text, such as dates, individuals and places; and PoS tagging would identify, for example, which words in a text are verbs, nouns, and punctuation marks.", + widgetModels: ["FacebookAI/xlm-roberta-large-finetuned-conll03-english"], + youtubeId: "wVHdVlPScxA", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eac5ea3f3006f8f8909e67692888a5290d2c766f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts @@ -0,0 +1,84 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Token Classification inference + */ +export interface TokenClassificationInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Token Classification + */ + parameters?: TokenClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Token Classification + */ +export interface TokenClassificationParameters { + /** + * The strategy used to fuse tokens based on model predictions + */ + aggregation_strategy?: TokenClassificationAggregationStrategy; + /** + * A list of labels to ignore + */ + ignore_labels?: string[]; + /** + * The number of overlapping tokens between chunks when splitting the input text. + */ + stride?: number; + [property: string]: unknown; +} +/** + * Do not aggregate tokens + * + * Group consecutive tokens with the same label in a single entity. + * + * Similar to "simple", also preserves word integrity (use the label predicted for the first + * token in a word). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest + * score, averaged across the word's tokens). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest score + * across the word's tokens). + */ +export type TokenClassificationAggregationStrategy = "none" | "simple" | "first" | "average" | "max"; +export type TokenClassificationOutput = TokenClassificationOutputElement[]; +/** + * Outputs of inference for the Token Classification task + */ +export interface TokenClassificationOutputElement { + /** + * The character position in the input where this group ends. + */ + end: number; + /** + * The predicted label for a single token + */ + entity?: string; + /** + * The predicted label for a group of one or more tokens + */ + entity_group?: string; + /** + * The associated score / probability + */ + score: number; + /** + * The character position in the input where this group begins. + */ + start: number; + /** + * The corresponding text + */ + word: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c8afeae4c523c21a681a7a3453d1df2ec382d7a3 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/token-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,oBAAoB,CAAC,EAAE,sCAAsC,CAAC;IAC9D;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sCAAsC,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;AACrG,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,EAAE,CAAC;AAC3E;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/token-classification/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2db6b74c8d7f7cb9ecc51018f83b40c1749d641f --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/translation/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAiEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.js new file mode 100644 index 0000000000000000000000000000000000000000..1c7e0afcaf4e3e97d16a23aed68479beea1f55f0 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/data.js @@ -0,0 +1,63 @@ +const taskData = { + canonicalId: "text-generation", + datasets: [ + { + description: "A dataset of copyright-free books translated into 16 different languages.", + id: "Helsinki-NLP/opus_books", + }, + { + description: "An example of translation between programming languages. This dataset consists of functions in Java and C#.", + id: "google/code_x_glue_cc_code_to_code_trans", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: "Mein Name ist Omar und ich wohne in Zürich.", + type: "text", + }, + ], + }, + metrics: [ + { + description: "BLEU score is calculated by counting the number of shared single or subsequent tokens between the generated sequence and the reference. Subsequent n tokens are called “n-grams”. Unigram refers to a single token while bi-gram refers to token pairs and n-grams refer to n subsequent tokens. The score ranges from 0 to 1, where 1 means the translation perfectly matched and 0 did not match at all", + id: "bleu", + }, + { + description: "", + id: "sacrebleu", + }, + ], + models: [ + { + description: "Very powerful model that can translate many languages between each other, especially low-resource languages.", + id: "facebook/nllb-200-1.3B", + }, + { + description: "A general-purpose Transformer that can be used to translate from English to German, French, or Romanian.", + id: "google-t5/t5-base", + }, + ], + spaces: [ + { + description: "An application that can translate between 100 languages.", + id: "Iker/Translate-100-languages", + }, + { + description: "An application that can translate between many languages.", + id: "Geonmo/nllb-translation-demo", + }, + ], + summary: "Translation is the task of converting text from one language to another.", + widgetModels: ["facebook/mbart-large-50-many-to-many-mmt"], + youtubeId: "1JvfrvZgi6c", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4df641a2cb758ae4ef24e0313e9dec7f9a4d8059 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts @@ -0,0 +1,64 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Translation inference + */ +export interface TranslationInput { + /** + * The text to translate. + */ + inputs: string; + /** + * Additional inference parameters for Translation + */ + parameters?: TranslationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Translation + */ +export interface TranslationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The source language of the text. Required for models that can translate from multiple + * languages. + */ + src_lang?: string; + /** + * Target language to translate to. Required for models that can translate to multiple + * languages. + */ + tgt_lang?: string; + /** + * The truncation strategy to use. + */ + truncation?: TranslationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type TranslationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Translation task + */ +export interface TranslationOutput { + /** + * The translated text. + */ + translation_text: string; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..03d7567511144732e069f733012ac65822b2e539 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/translation/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,mBAAmB,CAAC,EAAE;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,CAAC;AAC/G;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/translation/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7ae1ca65807d46bdc5161ad0d750274be15306cb --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/unconditional-image-generation/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAmEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.js new file mode 100644 index 0000000000000000000000000000000000000000..9e388e1a329274d8d0eae24827a45a2802df50be --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/unconditional-image-generation/data.js @@ -0,0 +1,63 @@ +const taskData = { + datasets: [ + { + description: "The CIFAR-100 dataset consists of 60000 32x32 colour images in 100 classes, with 600 images per class.", + id: "cifar100", + }, + { + description: "Multiple images of celebrities, used for facial expression translation.", + id: "CelebA", + }, + ], + demo: { + inputs: [ + { + label: "Seed", + content: "42", + type: "text", + }, + { + label: "Number of images to generate:", + content: "4", + type: "text", + }, + ], + outputs: [ + { + filename: "unconditional-image-generation-output.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: "The inception score (IS) evaluates the quality of generated images. It measures the diversity of the generated images (the model predictions are evenly distributed across all possible labels) and their 'distinction' or 'sharpness' (the model confidently predicts a single label for each image).", + id: "Inception score (IS)", + }, + { + description: "The Fréchet Inception Distance (FID) evaluates the quality of images created by a generative model by calculating the distance between feature vectors for real and generated images.", + id: "Frećhet Inception Distance (FID)", + }, + ], + models: [ + { + description: "High-quality image generation model trained on the CIFAR-10 dataset. It synthesizes images of the ten classes presented in the dataset using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-cifar10-32", + }, + { + description: "High-quality image generation model trained on the 256x256 CelebA-HQ dataset. It synthesizes images of faces using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-celebahq-256", + }, + ], + spaces: [ + { + description: "An application that can generate realistic faces.", + id: "CompVis/celeba-latent-diffusion", + }, + ], + summary: "Unconditional image generation is the task of generating images with no condition in any context (like a prompt text or another image). Once trained, the model will create images that resemble its training data distribution.", + widgetModels: [""], + // TODO: Add related video + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7ddd46629dd3f6fdc2e7bebd42b3cbe2cb701d6e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA+Ef,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..70fba6ea1c544dfbc3ed0cd730848c6344b39f56 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/data.js @@ -0,0 +1,80 @@ +const taskData = { + datasets: [ + { + // TODO write proper description + description: "Benchmark dataset used for video classification with videos that belong to 400 classes.", + id: "kinetics400", + }, + ], + demo: { + inputs: [ + { + filename: "video-classification-input.gif", + type: "img", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Playing Guitar", + score: 0.514, + }, + { + label: "Playing Tennis", + score: 0.193, + }, + { + label: "Cooking", + score: 0.068, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "google/vivit-b-16x2-kinetics400", + }, + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "microsoft/xclip-base-patch32", + }, + ], + spaces: [ + { + description: "An application that classifies video at different timestamps.", + id: "nateraw/lavila", + }, + { + description: "An application that classifies video.", + id: "fcakyon/video-classification", + }, + ], + summary: "Video classification is the task of assigning a label or class to an entire video. Videos are expected to have only one class for each video. Video classification models take a video as input and return a prediction about which class the video belongs to.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97499d022d9a2406ecf3ae55c64b7855f16fcb62 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts @@ -0,0 +1,61 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Video Classification inference + */ +export interface VideoClassificationInput { + /** + * The input video data + */ + inputs: unknown; + /** + * Additional inference parameters for Video Classification + */ + parameters?: VideoClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Video Classification + */ +export interface VideoClassificationParameters { + /** + * The sampling rate used to select frames from the video. + */ + frame_sampling_rate?: number; + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * The number of sampled frames to consider for classification. + */ + num_frames?: number; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type VideoClassificationOutput = VideoClassificationOutputElement[]; +/** + * Outputs of inference for the Video Classification task + */ +export interface VideoClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..becc24194891238147e7e67309e2d194a029bce1 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,EAAE,CAAC;AAC3E;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-classification/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9fd072183cf99733f8fa8c8d9917610b5984eca7 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-text-to-text/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAqEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.js new file mode 100644 index 0000000000000000000000000000000000000000..bf19fbd5b0642e9070c1430d2938b838e3301eb6 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-text-to-text/data.js @@ -0,0 +1,69 @@ +const taskData = { + datasets: [ + { + description: "Multiple-choice questions and answers about videos.", + id: "lmms-lab/Video-MME", + }, + { + description: "A dataset of instructions and question-answer pairs about videos.", + id: "lmms-lab/VideoChatGPT", + }, + { + description: "Large video understanding dataset.", + id: "HuggingFaceFV/finevideo", + }, + ], + demo: { + inputs: [ + { + filename: "video-text-to-text-input.gif", + type: "img", + }, + { + label: "Text Prompt", + content: "What is happening in this video?", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: "The video shows a series of images showing a fountain with water jets and a variety of colorful flowers and butterflies in the background.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust video-text-to-text model.", + id: "Vision-CAIR/LongVU_Qwen2_7B", + }, + { + description: "Strong video-text-to-text model with reasoning capabilities.", + id: "GoodiesHere/Apollo-LMMs-Apollo-7B-t32", + }, + { + description: "Strong video-text-to-text model.", + id: "HuggingFaceTB/SmolVLM2-2.2B-Instruct", + }, + ], + spaces: [ + { + description: "An application to chat with a video-text-to-text model.", + id: "llava-hf/video-llava", + }, + { + description: "A leaderboard for various video-text-to-text models.", + id: "opencompass/openvlm_video_leaderboard", + }, + { + description: "An application to generate highlights from a video.", + id: "HuggingFaceTB/SmolVLM2-HighlightGenerator", + }, + ], + summary: "Video-text-to-text models take in a video and a text prompt and output text. These models are also called video-language models.", + widgetModels: [""], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..69a3a40fc74e02b3eae44a8bc24cd05d4de41b61 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-to-video/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA8Df,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.js new file mode 100644 index 0000000000000000000000000000000000000000..7b73d0271d5e409b5b37eefd3030d5fe1b62a6c0 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/video-to-video/data.js @@ -0,0 +1,63 @@ +const taskData = { + datasets: [ + { + description: "Dataset with detailed annotations for training and benchmarking video instance editing.", + id: "suimu/VIRESET", + }, + { + description: "Dataset to evaluate models on long video generation and understanding.", + id: "zhangsh2001/LongV-EVAL", + }, + { + description: "Collection of 104 demo videos from the SeedVR/SeedVR2 series showcasing model outputs.", + id: "Iceclear/SeedVR_VideoDemos", + }, + ], + demo: { + inputs: [ + { + filename: "input.gif", + type: "img", + }, + ], + outputs: [ + { + filename: "output.gif", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "Model for editing outfits, character, and scenery in videos.", + id: "decart-ai/Lucy-Edit-Dev", + }, + { + description: "Framework that uses 3D mesh proxies for precise, consistent video editing.", + id: "LeoLau/Shape-for-Motion", + }, + { + description: "Model for generating physics-aware videos from input videos and control conditions.", + id: "nvidia/Cosmos-Transfer2.5-2B", + }, + { + description: "A model to upscale videos at input, designed for seamless use with ComfyUI.", + id: "numz/SeedVR2_comfyUI", + }, + ], + spaces: [ + { + description: "Interactive demo space for Lucy-Edit-Dev video editing.", + id: "decart-ai/lucy-edit-dev", + }, + { + description: "Demo space for SeedVR2-3B showcasing video upscaling and restoration.", + id: "ByteDance-Seed/SeedVR2-3B", + }, + ], + summary: "Video-to-video models take one or more videos as input and generate new videos as output. They can enhance quality, interpolate frames, modify styles, or create new motion dynamics, enabling creative applications, video production, and research.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..186ad37def7b38501f210bec15304d1c534ebdd4 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/visual-document-retrieval/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAuEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.js new file mode 100644 index 0000000000000000000000000000000000000000..d13d117acbc5ede912f623d62bebf3f623d927c2 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-document-retrieval/data.js @@ -0,0 +1,71 @@ +const taskData = { + datasets: [ + { + description: "A large dataset used to train visual document retrieval models.", + id: "vidore/colpali_train_set", + }, + ], + demo: { + inputs: [ + { + filename: "input.png", + type: "img", + }, + { + label: "Question", + content: "Is the model in this paper the fastest for inference?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Page 10", + score: 0.7, + }, + { + label: "Page 11", + score: 0.06, + }, + { + label: "Page 9", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "NDCG@k scores ranked recommendation lists for top-k results. 0 is the worst, 1 is the best.", + id: "Normalized Discounted Cumulative Gain at K", + }, + ], + models: [ + { + description: "Very accurate visual document retrieval model for multilingual queries and documents.", + id: "vidore/colqwen2-v1.0", + }, + { + description: "Very fast and efficient visual document retrieval model that can also take in other modalities like audio.", + id: "Tevatron/OmniEmbed-v0.1", + }, + ], + spaces: [ + { + description: "A leaderboard of visual document retrieval models.", + id: "vidore/vidore-leaderboard", + }, + { + description: "Visual retrieval augmented generation demo based on ColQwen2 model.", + id: "vidore/visual-rag-tool", + }, + ], + summary: "Visual document retrieval is the task of searching for relevant image-based documents, such as PDFs. These models take a text query and multiple documents as input and return the top-most relevant documents and relevancy scores as output.", + widgetModels: [""], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a5bb4ed58442694fd0d8a32ae92012c6083a496c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/visual-question-answering/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA4Ff,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.js new file mode 100644 index 0000000000000000000000000000000000000000..2482cfd2a35a51534d185c4963e4c14fcf8a2512 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/data.js @@ -0,0 +1,91 @@ +const taskData = { + datasets: [ + { + description: "A widely used dataset containing questions (with answers) about images.", + id: "Graphcore/vqa", + }, + { + description: "A dataset to benchmark visual reasoning based on text in images.", + id: "facebook/textvqa", + }, + ], + demo: { + inputs: [ + { + filename: "elephant.jpeg", + type: "img", + }, + { + label: "Question", + content: "What is in this image?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "elephant", + score: 0.97, + }, + { + label: "elephants", + score: 0.06, + }, + { + label: "animal", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "Measures how much a predicted answer differs from the ground truth based on the difference in their semantic meaning.", + id: "wu-palmer similarity", + }, + ], + models: [ + { + description: "A visual question answering model trained to convert charts and plots to text.", + id: "google/deplot", + }, + { + description: "A visual question answering model trained for mathematical reasoning and chart derendering from images.", + id: "google/matcha-base", + }, + { + description: "A strong visual question answering that answers questions from book covers.", + id: "google/pix2struct-ocrvqa-large", + }, + ], + spaces: [ + { + description: "An application that compares visual question answering models across different tasks.", + id: "merve/pix2struct", + }, + { + description: "An application that can answer questions based on images.", + id: "nielsr/vilt-vqa", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "Salesforce/BLIP", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "vumichien/Img2Prompt", + }, + ], + summary: "Visual Question Answering is the task of answering open-ended questions based on an image. They output natural language responses to natural language questions.", + widgetModels: ["dandelin/vilt-b32-finetuned-vqa"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4736a2d592969c569d706924af56da6583ee0891 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts @@ -0,0 +1,61 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Visual Question Answering inference + */ +export interface VisualQuestionAnsweringInput { + /** + * One (image, question) pair to answer + */ + inputs: VisualQuestionAnsweringInputData; + /** + * Additional inference parameters for Visual Question Answering + */ + parameters?: VisualQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (image, question) pair to answer + */ +export interface VisualQuestionAnsweringInputData { + /** + * The image. + */ + image: unknown; + /** + * The question to answer based on the image. + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Visual Question Answering + */ +export interface VisualQuestionAnsweringParameters { + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type VisualQuestionAnsweringOutput = VisualQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Visual Question Answering task + */ +export interface VisualQuestionAnsweringOutputElement { + /** + * The answer to the question + */ + answer?: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a0f2508331d6046894c38d3b358c1ff70aef4bb5 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/visual-question-answering/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,MAAM,EAAE,gCAAgC,CAAC;IACzC;;OAEG;IACH,UAAU,CAAC,EAAE,iCAAiC,CAAC;IAC/C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,6BAA6B,GAAG,oCAAoC,EAAE,CAAC;AACnF;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACpD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/visual-question-answering/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8ae7284ee6e360d3a874ce894594cd62659f2cf9 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAqEf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..539edc5c2c588358bd971031628012c0720fd416 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/data.js @@ -0,0 +1,68 @@ +const taskData = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: "The Multi-Genre Natural Language Inference (MultiNLI) corpus is a crowd-sourced collection of 433k sentence pairs annotated with textual entailment information.", + id: "nyu-mll/multi_nli", + }, + { + description: "FEVER is a publicly available dataset for fact extraction and verification against textual sources.", + id: "fever/fever", + }, + ], + demo: { + inputs: [ + { + label: "Text Input", + content: "Dune is the best movie ever.", + type: "text", + }, + { + label: "Candidate Labels", + content: "CINEMA, ART, MUSIC", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "CINEMA", + score: 0.9, + }, + { + label: "ART", + score: 0.1, + }, + { + label: "MUSIC", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [], + models: [ + { + description: "Powerful zero-shot text classification model.", + id: "facebook/bart-large-mnli", + }, + { + description: "Cutting-edge zero-shot multilingual text classification model.", + id: "MoritzLaurer/ModernBERT-large-zeroshot-v2.0", + }, + { + description: "Zero-shot text classification model that can be used for topic and sentiment classification.", + id: "knowledgator/gliclass-modern-base-v2.0-init", + }, + ], + spaces: [], + summary: "Zero-shot text classification is a task in natural language processing where a model is trained on a set of labeled examples but is then able to classify new examples from previously unseen classes.", + widgetModels: ["facebook/bart-large-mnli"], +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d9281733c9a213395c423d02a1e1e11b3ebf8d2 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts @@ -0,0 +1,56 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Classification inference + */ +export interface ZeroShotClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Zero Shot Classification + */ + parameters: ZeroShotClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Classification + */ +export interface ZeroShotClassificationParameters { + /** + * The set of possible class labels to classify the text into. + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the text + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + /** + * Whether multiple candidate labels can be true. If false, the scores are normalized such + * that the sum of the label likelihoods for each sequence is 1. If true, the labels are + * considered independent and probabilities are normalized for each candidate. + */ + multi_label?: boolean; + [property: string]: unknown; +} +export type ZeroShotClassificationOutput = ZeroShotClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Classification task + */ +export interface ZeroShotClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..1a132031034157cd5ba0a7b20a870ef33c337044 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,EAAE,gCAAgC,CAAC;IAC7C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,EAAE,CAAC;AACjF;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-classification/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..18ffbbd656c7012e0d48ef08fb8065a700213622 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-image-classification/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAmFf,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.js new file mode 100644 index 0000000000000000000000000000000000000000..340ee53ccde9a7ca4299dda737355f9a37d06431 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/data.js @@ -0,0 +1,83 @@ +const taskData = { + datasets: [ + { + // TODO write proper description + description: "", + id: "", + }, + ], + demo: { + inputs: [ + { + filename: "image-classification-input.jpeg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Cat", + score: 0.664, + }, + { + label: "Dog", + score: 0.329, + }, + { + label: "Bird", + score: 0.008, + }, + ], + }, + ], + }, + metrics: [ + { + description: "Computes the number of times the correct label appears in top K labels predicted", + id: "top-K accuracy", + }, + ], + models: [ + { + description: "Multilingual image classification model for 80 languages.", + id: "visheratin/mexma-siglip", + }, + { + description: "Strong zero-shot image classification model.", + id: "google/siglip2-base-patch16-224", + }, + { + description: "Robust zero-shot image classification model.", + id: "intfloat/mmE5-mllama-11b-instruct", + }, + { + description: "Powerful zero-shot image classification model supporting 94 languages.", + id: "jinaai/jina-clip-v2", + }, + { + description: "Strong image classification model for biomedical domain.", + id: "microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224", + }, + ], + spaces: [ + { + description: "An application that leverages zero-shot image classification to find best captions to generate an image. ", + id: "pharma/CLIP-Interrogator", + }, + { + description: "An application to compare different zero-shot image classification models. ", + id: "merve/compare_clip_siglip", + }, + ], + summary: "Zero-shot image classification is the task of classifying previously unseen classes during training of a model.", + widgetModels: ["google/siglip-so400m-patch14-224"], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e80503ecf772e75dbaa641b0533c1f7d61ed22c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts @@ -0,0 +1,50 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Image Classification inference + */ +export interface ZeroShotImageClassificationInput { + /** + * The input image data to classify as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Image Classification + */ + parameters: ZeroShotImageClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Image Classification + */ +export interface ZeroShotImageClassificationParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the image + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + [property: string]: unknown; +} +export type ZeroShotImageClassificationOutput = ZeroShotImageClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Image Classification task + */ +export interface ZeroShotImageClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..6c9de1ceb345e5457fd3755db377e73e3ac9b836 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-image-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,qCAAqC,CAAC;IAClD,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,qCAAqC;IACrD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,iCAAiC,GAAG,wCAAwC,EAAE,CAAC;AAC3F;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-image-classification/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc8794d0d9385cdff0fd88a7c158222897e8ea50 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts @@ -0,0 +1,4 @@ +import type { TaskDataCustom } from "../index.js"; +declare const taskData: TaskDataCustom; +export default taskData; +//# sourceMappingURL=data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d3836f53f66b8db2c829bfe01d8fe3505d975832 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-object-detection/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cA8Df,CAAC;AAEF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.js new file mode 100644 index 0000000000000000000000000000000000000000..3c4601325d9991ba356865903eb1b8b3e2858602 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/data.js @@ -0,0 +1,60 @@ +const taskData = { + datasets: [], + demo: { + inputs: [ + { + filename: "zero-shot-object-detection-input.jpg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + filename: "zero-shot-object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid zero-shot object detection model.", + id: "openmmlab-community/mm_grounding_dino_large_all", + }, + { + description: "Cutting-edge zero-shot object detection model.", + id: "fushh7/LLMDet", + }, + ], + spaces: [ + { + description: "A demo to compare different zero-shot object detection models per output and latency.", + id: "ariG23498/zero-shot-od", + }, + { + description: "A demo that combines a zero-shot object detection and mask generation model for zero-shot segmentation.", + id: "merve/OWLSAM", + }, + ], + summary: "Zero-shot object detection is a computer vision task to detect objects and their classes in images, without any prior training or knowledge of the classes. Zero-shot object detection models receive an image as input, as well as a list of candidate classes, and output the bounding boxes and labels where the objects have been detected.", + widgetModels: [], + youtubeId: "", +}; +export default taskData; diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..00bfad1dfb69b256e202c541e3c00d200be46ca6 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts @@ -0,0 +1,61 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Object Detection inference + */ +export interface ZeroShotObjectDetectionInput { + /** + * The input image data as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Object Detection + */ + parameters: ZeroShotObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Object Detection + */ +export interface ZeroShotObjectDetectionParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + xmax: number; + xmin: number; + ymax: number; + ymin: number; + [property: string]: unknown; +} +export type ZeroShotObjectDetectionOutput = ZeroShotObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Zero Shot Object Detection task + */ +export interface ZeroShotObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * A candidate label + */ + label: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} +//# sourceMappingURL=inference.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d31807a4e74fc4e9f381f911e9838ca83df9e351 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-object-detection/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,iCAAiC,CAAC;IAC9C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,6BAA6B,GAAG,oCAAoC,EAAE,CAAC;AACnF;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACpD;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.js b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tasks/zero-shot-object-detection/inference.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5863744080832186bd5f7482bd3f55c446872e84 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts @@ -0,0 +1,26 @@ +export declare const SPECIAL_TOKENS_ATTRIBUTES: readonly ["bos_token", "eos_token", "unk_token", "sep_token", "pad_token", "cls_token", "mask_token"]; +/** + * Public interface for a tokenizer's special tokens mapping + */ +export interface AddedToken { + __type: "AddedToken"; + content?: string; + lstrip?: boolean; + normalized?: boolean; + rstrip?: boolean; + single_word?: boolean; +} +export type SpecialTokensMap = { + [key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken | null; +}; +/** + * Public interface for tokenizer config + */ +export interface TokenizerConfig extends SpecialTokensMap { + use_default_system_prompt?: boolean; + chat_template?: string | Array<{ + name: string; + template: string; + }>; +} +//# sourceMappingURL=tokenizer-data.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8f5b0a57b829b2f6c0060ac3f36d00e093d8195c --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"tokenizer-data.d.ts","sourceRoot":"","sources":["../../src/tokenizer-data.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,uGAS5B,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,gBAAgB,GAAG;KAC7B,GAAG,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;CAChF,CAAC;AACF;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACxD,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.js b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.js new file mode 100644 index 0000000000000000000000000000000000000000..c77687634546d37b3467e5721eed57bf45a52644 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/tokenizer-data.js @@ -0,0 +1,10 @@ +export const SPECIAL_TOKENS_ATTRIBUTES = [ + "bos_token", + "eos_token", + "unk_token", + "sep_token", + "pad_token", + "cls_token", + "mask_token", + // additional_special_tokens (TODO) +]; diff --git a/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts b/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e99fa12e050a01ce6c7e167346e18184dde2f96 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts @@ -0,0 +1,83 @@ +/** + * See default-widget-inputs.ts for the default widget inputs, this files only contains the types + */ +import type { ChatCompletionInputMessage } from "./tasks/index.js"; +type TableData = Record; +export type WidgetExampleOutputLabels = Array<{ + label: string; + score: number; +}>; +export interface WidgetExampleOutputAnswerScore { + answer: string; + score: number; +} +export interface WidgetExampleOutputText { + text: string; +} +export interface WidgetExampleOutputUrl { + url: string; +} +export type WidgetExampleOutput = WidgetExampleOutputLabels | WidgetExampleOutputAnswerScore | WidgetExampleOutputText | WidgetExampleOutputUrl; +export interface WidgetExampleBase { + example_title?: string; + group?: string; + /** + * Potential overrides to API parameters for this specific example + * (takes precedences over the model card metadata's inference.parameters) + */ + parameters?: { + aggregation_strategy?: string; + top_k?: number; + top_p?: number; + temperature?: number; + max_new_tokens?: number; + do_sample?: boolean; + negative_prompt?: string; + guidance_scale?: number; + num_inference_steps?: number; + }; + /** + * Optional output + */ + output?: TOutput; +} +export interface WidgetExampleChatInput extends WidgetExampleBase { + messages: ChatCompletionInputMessage[]; +} +export interface WidgetExampleTextInput extends WidgetExampleBase { + text: string; +} +export interface WidgetExampleTextAndContextInput extends WidgetExampleTextInput { + context: string; +} +export interface WidgetExampleTextAndTableInput extends WidgetExampleTextInput { + table: TableData; +} +export interface WidgetExampleAssetInput extends WidgetExampleBase { + src: string; +} +export interface WidgetExampleAssetAndPromptInput extends WidgetExampleAssetInput { + prompt: string; +} +export type WidgetExampleAssetAndTextInput = WidgetExampleAssetInput & WidgetExampleTextInput; +export type WidgetExampleAssetAndZeroShotInput = WidgetExampleAssetInput & WidgetExampleZeroShotTextInput; +export interface WidgetExampleStructuredDataInput extends WidgetExampleBase { + structured_data: TableData; +} +export interface WidgetExampleTableDataInput extends WidgetExampleBase { + table: TableData; +} +export interface WidgetExampleZeroShotTextInput extends WidgetExampleTextInput { + text: string; + candidate_labels: string; + multi_class: boolean; +} +export interface WidgetExampleSentenceSimilarityInput extends WidgetExampleBase { + source_sentence: string; + sentences: string[]; +} +export type WidgetExample = WidgetExampleChatInput | WidgetExampleTextInput | WidgetExampleTextAndContextInput | WidgetExampleTextAndTableInput | WidgetExampleAssetInput | WidgetExampleAssetAndPromptInput | WidgetExampleAssetAndTextInput | WidgetExampleAssetAndZeroShotInput | WidgetExampleStructuredDataInput | WidgetExampleTableDataInput | WidgetExampleZeroShotTextInput | WidgetExampleSentenceSimilarityInput; +type KeysOfUnion = T extends unknown ? keyof T : never; +export type WidgetExampleAttribute = KeysOfUnion; +export {}; +//# sourceMappingURL=widget-example.d.ts.map \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts.map b/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2a7075f6b0bbf8789a174607be1ffbb685c86987 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/widget-example.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"widget-example.d.ts","sourceRoot":"","sources":["../../src/widget-example.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEnE,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,M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CAAC;CACrB;AAED,MAAM,WAAW,oCAAoC,CACpD,OAAO,GAAG,mBAAmB,CAC5B,SAAQ,iBAAiB,CAAC,OAAO,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,MAAM,MAAM,aAAa,CAAC,OAAO,GAAG,mBAAmB,IACpD,sBAAsB,CAAC,OAAO,CAAC,GAC/B,sBAAsB,CAAC,OAAO,CAAC,GAC/B,gCAAgC,CAAC,OAAO,CAAC,GACzC,8BAA8B,CAAC,OAAO,CAAC,GACvC,uBAAuB,CAAC,OAAO,CAAC,GAChC,gCAAgC,CAAC,OAAO,CAAC,GACzC,8BAA8B,CAAC,OAAO,CAAC,GACvC,kCAAkC,CAAC,OAAO,CAAC,GAC3C,gCAAgC,CAAC,OAAO,CAAC,GACzC,2BAA2B,CAAC,OAAO,CAAC,GACpC,8BAA8B,CAAC,OAAO,CAAC,GACvC,oCAAoC,CAAC,OAAO,CAAC,CAAC;AAEjD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/dist/esm/widget-example.js b/node_modules/@huggingface/tasks/dist/esm/widget-example.js new file mode 100644 index 0000000000000000000000000000000000000000..7cb6cbe5c996656d6eea133f9dc21f6a2899f607 --- /dev/null +++ b/node_modules/@huggingface/tasks/dist/esm/widget-example.js @@ -0,0 +1,4 @@ +/** + * See default-widget-inputs.ts for the default widget inputs, this files only contains the types + */ +export {}; diff --git a/node_modules/@huggingface/tasks/package.json b/node_modules/@huggingface/tasks/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6378aa6f225da632378e7d86519e1966f6130d31 --- /dev/null +++ b/node_modules/@huggingface/tasks/package.json @@ -0,0 +1,57 @@ +{ + "name": "@huggingface/tasks", + "version": "0.19.85", + "description": "List of ML tasks for huggingface.co/tasks", + "keywords": [ + "hub", + "huggingface", + "languages" + ], + "license": "MIT", + "author": "Hugging Face", + "repository": "https://github.com/huggingface/huggingface.js.git", + "source": "./src/index.ts", + "files": [ + "dist", + "src", + "tsconfig.json" + ], + "type": "module", + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/commonjs/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "tshy": { + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + } + }, + "scripts": { + "lint": "eslint --quiet --fix --ext .cjs,.ts .", + "lint:check": "eslint --ext .cjs,.ts .", + "format": "oxfmt .", + "format:check": "oxfmt --check .", + "build": "tshy", + "watch:cjs": "tsc --declaration --outdir dist/commonjs --module commonjs --watch", + "watch:esm": "tsc --declaration --outdir dist/esm --watch", + "watch": "npm-run-all --parallel watch:esm watch:cjs", + "check": "tsc", + "test": "vitest run" + } +} \ No newline at end of file diff --git a/node_modules/@huggingface/tasks/src/dataset-libraries.ts b/node_modules/@huggingface/tasks/src/dataset-libraries.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbe85fdb3b94c5e5d4b0bad837d08e5817d45096 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/dataset-libraries.ts @@ -0,0 +1,101 @@ +/** + * Elements configurable by a dataset library. + */ +export interface DatasetLibraryUiElement { + /** + * Pretty name of the library. + * displayed (in tags?, and) on the main + * call-to-action button on the dataset page. + */ + prettyLabel: string; + /** + * Repo name of the library's (usually on GitHub) code repo + */ + repoName: string; + /** + * URL to library's (usually on GitHub) code repo + */ + repoUrl: string; + /** + * URL to library's docs + */ + docsUrl?: string; +} + +export const DATASET_LIBRARIES_UI_ELEMENTS = { + mlcroissant: { + prettyLabel: "Croissant", + repoName: "croissant", + repoUrl: "https://github.com/mlcommons/croissant/tree/main/python/mlcroissant", + docsUrl: "https://huggingface.co/docs/dataset-viewer/mlcroissant", + }, + webdataset: { + prettyLabel: "WebDataset", + repoName: "webdataset", + repoUrl: "https://github.com/webdataset/webdataset", + docsUrl: "https://huggingface.co/docs/hub/datasets-webdataset", + }, + datasets: { + prettyLabel: "Datasets", + repoName: "datasets", + repoUrl: "https://github.com/huggingface/datasets", + docsUrl: "https://huggingface.co/docs/hub/datasets-usage", + }, + pandas: { + prettyLabel: "pandas", + repoName: "pandas", + repoUrl: "https://github.com/pandas-dev/pandas", + docsUrl: "https://huggingface.co/docs/hub/datasets-pandas", + }, + dask: { + prettyLabel: "Dask", + repoName: "dask", + repoUrl: "https://github.com/dask/dask", + docsUrl: "https://huggingface.co/docs/hub/datasets-dask", + }, + distilabel: { + prettyLabel: "Distilabel", + repoName: "distilabel", + repoUrl: "https://github.com/argilla-io/distilabel", + docsUrl: "https://huggingface.co/docs/hub/datasets-distilabel", + }, + fiftyone: { + prettyLabel: "FiftyOne", + repoName: "fiftyone", + repoUrl: "https://github.com/voxel51/fiftyone", + docsUrl: "https://huggingface.co/docs/hub/datasets-fiftyone", + }, + lance: { + prettyLabel: "Lance", + repoName: "lance", + repoUrl: "https://github.com/lance-format/lance", + docsUrl: "https://huggingface.co/docs/hub/datasets-lance", + }, + argilla: { + prettyLabel: "Argilla", + repoName: "argilla", + repoUrl: "https://github.com/argilla-io/argilla", + docsUrl: "https://huggingface.co/docs/hub/datasets-argilla", + }, + polars: { + prettyLabel: "Polars", + repoName: "polars", + repoUrl: "https://github.com/pola-rs/polars", + docsUrl: "https://huggingface.co/docs/hub/datasets-polars", + }, + duckdb: { + prettyLabel: "DuckDB", + repoName: "duckdb", + repoUrl: "https://github.com/duckdb/duckdb", + docsUrl: "https://huggingface.co/docs/hub/datasets-duckdb", + }, + datadesigner: { + prettyLabel: "NeMo Data Designer", + repoName: "datadesigner", + repoUrl: "https://github.com/NVIDIA-NeMo/DataDesigner", + docsUrl: "https://nvidia-nemo.github.io/DataDesigner/", + }, +} satisfies Record; + +/// List of the dataset libraries supported by the Hub +export type DatasetLibraryKey = keyof typeof DATASET_LIBRARIES_UI_ELEMENTS; diff --git a/node_modules/@huggingface/tasks/src/default-widget-inputs.ts b/node_modules/@huggingface/tasks/src/default-widget-inputs.ts new file mode 100644 index 0000000000000000000000000000000000000000..7185abe6daa6fdfb50aa562f50585fdcee6aed5d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/default-widget-inputs.ts @@ -0,0 +1,697 @@ +import type { WidgetExample } from "./widget-example.js"; +import type { WidgetType } from "./pipelines.js"; + +type LanguageCode = string; + +type PerLanguageMapping = Map; + +/// NOTE TO CONTRIBUTORS: +/// +/// When adding sample inputs for a new language, you don't +/// necessarily have to translate the inputs from existing languages. +/// (which were quite random to begin with) +/// +/// i.e. Feel free to be creative and provide better samples. +// + +/// The placeholder will be replaced by the correct mask token +/// in the following examples, depending on the model type +/// +/// see [INTERNAL] github.com/huggingface/moon-landing/blob/c5c3d45fe0ab27347b3ab27bdad646ef20732351/server/lib/App.ts#L254 +// + +const MAPPING_EN: PerLanguageMapping = new Map([ + ["text-classification", [`I like you. I love you`]], + [ + "token-classification", + [ + `My name is Wolfgang and I live in Berlin`, + `My name is Sarah and I live in London`, + `My name is Clara and I live in Berkeley, California.`, + ], + ], + [ + "table-question-answering", + [ + { + text: `How many stars does the transformers repository have?`, + table: { + Repository: ["Transformers", "Datasets", "Tokenizers"], + Stars: [36542, 4512, 3934], + Contributors: [651, 77, 34], + "Programming language": ["Python", "Python", "Rust, Python and NodeJS"], + }, + }, + ], + ], + [ + "question-answering", + [ + { + text: `Where do I live?`, + context: `My name is Wolfgang and I live in Berlin`, + }, + { + text: `Where do I live?`, + context: `My name is Sarah and I live in London`, + }, + { + text: `What's my name?`, + context: `My name is Clara and I live in Berkeley.`, + }, + { + text: `Which name is also used to describe the Amazon rainforest in English?`, + context: `The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. States or departments in four nations contain "Amazonas" in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species.`, + }, + ], + ], + [ + "zero-shot-classification", + [ + { + text: "I have a problem with my iphone that needs to be resolved asap!", + candidate_labels: "urgent, not urgent, phone, tablet, computer", + multi_class: true, + }, + { + text: "Last week I upgraded my iOS version and ever since then my phone has been overheating whenever I use your app.", + candidate_labels: "mobile, website, billing, account access", + multi_class: false, + }, + { + text: "A new model offers an explanation for how the Galilean satellites formed around the solar system’s largest world. Konstantin Batygin did not set out to solve one of the solar system’s most puzzling mysteries when he went for a run up a hill in Nice, France. Dr. Batygin, a Caltech researcher, best known for his contributions to the search for the solar system’s missing “Planet Nine,” spotted a beer bottle. At a steep, 20 degree grade, he wondered why it wasn’t rolling down the hill. He realized there was a breeze at his back holding the bottle in place. Then he had a thought that would only pop into the mind of a theoretical astrophysicist: “Oh! This is how Europa formed.” Europa is one of Jupiter’s four large Galilean moons. And in a paper published Monday in the Astrophysical Journal, Dr. Batygin and a co-author, Alessandro Morbidelli, a planetary scientist at the Côte d’Azur Observatory in France, present a theory explaining how some moons form around gas giants like Jupiter and Saturn, suggesting that millimeter-sized grains of hail produced during the solar system’s formation became trapped around these massive worlds, taking shape one at a time into the potentially habitable moons we know today.", + candidate_labels: "space & cosmos, scientific discovery, microbiology, robots, archeology", + multi_class: true, + }, + ], + ], + ["translation", [`My name is Wolfgang and I live in Berlin`, `My name is Sarah and I live in London`]], + [ + "summarization", + [ + `The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.`, + ], + ], + [ + "conversational", + [ + `Hi, what can you help me with?`, + `What is 84 * 3 / 2?`, + `Tell me an interesting fact about the universe!`, + `Explain quantum computing in simple terms.`, + ], + ], + [ + "text-generation", + [ + `My name is Julien and I like to`, + `I like traveling by train because`, + `Paris is an amazing place to visit,`, + `Once upon a time,`, + ], + ], + ["fill-mask", [`Paris is the of France.`, `The goal of life is .`]], + [ + "sentence-similarity", + [ + { + source_sentence: "That is a happy person", + sentences: ["That is a happy dog", "That is a very happy person", "Today is a sunny day"], + }, + ], + ], +]); + +const MAPPING_ZH: PerLanguageMapping = new Map([ + ["text-classification", [`我喜欢你。 我爱你`]], + ["token-classification", [`我叫沃尔夫冈,我住在柏林。`, `我叫萨拉,我住在伦敦。`, `我叫克拉拉,我住在加州伯克利。`]], + [ + "question-answering", + [ + { + text: `我住在哪里?`, + context: `我叫沃尔夫冈,我住在柏林。`, + }, + { + text: `我住在哪里?`, + context: `我叫萨拉,我住在伦敦。`, + }, + { + text: `我的名字是什么?`, + context: `我叫克拉拉,我住在伯克利。`, + }, + ], + ], + ["translation", [`我叫沃尔夫冈,我住在柏林。`, `我叫萨拉,我住在伦敦。`]], + [ + "zero-shot-classification", + [ + { + text: "房间干净明亮,非常不错", + candidate_labels: "这是一条差评, 这是一条好评", + }, + ], + ], + [ + "summarization", + [ + `该塔高324米(1063英尺),与一幢81层的建筑物一样高,是巴黎最高的建筑物。 它的底座是方形的,每边长125米(410英尺)。 在建造过程中,艾菲尔铁塔超过了华盛顿纪念碑,成为世界上最高的人造结构,它保持了41年的头衔,直到1930年纽约市的克莱斯勒大楼竣工。这是第一个到达300米高度的结构。 由于1957年在塔顶增加了广播天线,因此它现在比克莱斯勒大厦高5.2米(17英尺)。 除发射器外,艾菲尔铁塔是法国第二高的独立式建筑,仅次于米劳高架桥。`, + ], + ], + [ + "text-generation", + [`我叫朱利安,我喜欢`, `我叫托马斯,我的主要`, `我叫玛丽亚,我最喜欢的`, `我叫克拉拉,我是`, `从前,`], + ], + ["fill-mask", [`巴黎是国的首都。`, `生活的真谛是。`]], + [ + "sentence-similarity", + [ + { + source_sentence: "那是 個快樂的人", + sentences: ["那是 條快樂的狗", "那是 個非常幸福的人", "今天是晴天"], + }, + ], + ], +]); + +const MAPPING_FR: PerLanguageMapping = new Map([ + ["text-classification", [`Je t'apprécie beaucoup. Je t'aime.`]], + ["token-classification", [`Mon nom est Wolfgang et je vis à Berlin`]], + [ + "question-answering", + [ + { + text: `Où est-ce que je vis?`, + context: `Mon nom est Wolfgang et je vis à Berlin`, + }, + ], + ], + ["translation", [`Mon nom est Wolfgang et je vis à Berlin`]], + [ + "summarization", + [ + `La tour fait 324 mètres (1,063 pieds) de haut, environ la même hauteur qu'un immeuble de 81 étages, et est la plus haute structure de Paris. Sa base est carrée, mesurant 125 mètres (410 pieds) sur chaque côté. Durant sa construction, la tour Eiffel surpassa le Washington Monument pour devenir la plus haute structure construite par l'homme dans le monde, un titre qu'elle conserva pendant 41 ans jusqu'à l'achèvement du Chrysler Building à New-York City en 1930. Ce fut la première structure à atteindre une hauteur de 300 mètres. Avec l'ajout d'une antenne de radiodiffusion au sommet de la tour Eiffel en 1957, celle-ci redevint plus haute que le Chrysler Building de 5,2 mètres (17 pieds). En excluant les transmetteurs, elle est la seconde plus haute structure autoportante de France après le viaduc de Millau.`, + ], + ], + ["text-generation", [`Mon nom est Julien et j'aime`, `Mon nom est Thomas et mon principal`, `Il était une fois`]], + ["fill-mask", [`Paris est la de la France.`]], + [ + "sentence-similarity", + [ + { + source_sentence: "C'est une personne heureuse", + sentences: [ + "C'est un chien heureux", + "C'est une personne très heureuse", + "Aujourd'hui est une journée ensoleillée", + ], + }, + ], + ], +]); + +const MAPPING_ES: PerLanguageMapping = new Map([ + ["text-classification", [`Te quiero. Te amo.`]], + ["token-classification", [`Me llamo Wolfgang y vivo en Berlin`]], + [ + "question-answering", + [ + { + text: `¿Dónde vivo?`, + context: `Me llamo Wolfgang y vivo en Berlin`, + }, + { + text: `¿Quién inventó el submarino?`, + context: `Isaac Peral fue un murciano que inventó el submarino`, + }, + { + text: `¿Cuántas personas hablan español?`, + context: `El español es el segundo idioma más hablado del mundo con más de 442 millones de hablantes`, + }, + ], + ], + [ + "translation", + [ + `Me llamo Wolfgang y vivo en Berlin`, + `Los ingredientes de una tortilla de patatas son: huevos, patatas y cebolla`, + ], + ], + [ + "summarization", + [ + `La torre tiene 324 metros (1.063 pies) de altura, aproximadamente la misma altura que un edificio de 81 pisos y la estructura más alta de París. Su base es cuadrada, mide 125 metros (410 pies) a cada lado. Durante su construcción, la Torre Eiffel superó al Washington Monument para convertirse en la estructura artificial más alta del mundo, un título que mantuvo durante 41 años hasta que el Chrysler Building en la ciudad de Nueva York se terminó en 1930. Fue la primera estructura en llegar Una altura de 300 metros. Debido a la adición de una antena de transmisión en la parte superior de la torre en 1957, ahora es más alta que el Chrysler Building en 5,2 metros (17 pies). Excluyendo los transmisores, la Torre Eiffel es la segunda estructura independiente más alta de Francia después del Viaducto de Millau.`, + ], + ], + [ + "text-generation", + [ + `Me llamo Julien y me gusta`, + `Me llamo Thomas y mi principal`, + `Me llamo Manuel y trabajo en`, + `Érase una vez,`, + `Si tú me dices ven, `, + ], + ], + ["fill-mask", [`Mi nombre es y vivo en Nueva York.`, `El español es un idioma muy en el mundo.`]], + [ + "sentence-similarity", + [ + { + source_sentence: "Esa es una persona feliz", + sentences: ["Ese es un perro feliz", "Esa es una persona muy feliz", "Hoy es un día soleado"], + }, + ], + ], +]); + +const MAPPING_RU: PerLanguageMapping = new Map([ + ["text-classification", [`Ты мне нравишься. Я тебя люблю`]], + ["token-classification", [`Меня зовут Вольфганг и я живу в Берлине`]], + [ + "question-answering", + [ + { + text: `Где живу?`, + context: `Меня зовут Вольфганг и я живу в Берлине`, + }, + ], + ], + ["translation", [`Меня зовут Вольфганг и я живу в Берлине`]], + [ + "summarization", + [ + `Высота башни составляет 324 метра (1063 фута), примерно такая же высота, как у 81-этажного здания, и самое высокое сооружение в Париже. Его основание квадратно, размером 125 метров (410 футов) с любой стороны. Во время строительства Эйфелева башня превзошла монумент Вашингтона, став самым высоким искусственным сооружением в мире, и этот титул она удерживала в течение 41 года до завершения строительство здания Крайслер в Нью-Йорке в 1930 году. Это первое сооружение которое достигло высоты 300 метров. Из-за добавления вещательной антенны на вершине башни в 1957 году она сейчас выше здания Крайслер на 5,2 метра (17 футов). За исключением передатчиков, Эйфелева башня является второй самой высокой отдельно стоящей структурой во Франции после виадука Мийо.`, + ], + ], + ["text-generation", [`Меня зовут Жюльен и`, `Меня зовут Томас и мой основной`, `Однажды`]], + ["fill-mask", [`Меня зовут и я инженер живущий в Нью-Йорке.`]], + [ + "sentence-similarity", + [ + { + source_sentence: "Это счастливый человек", + sentences: ["Это счастливая собака", "Это очень счастливый человек", "Сегодня солнечный день"], + }, + ], + ], +]); + +const MAPPING_UK: PerLanguageMapping = new Map([ + ["translation", [`Мене звати Вольфґанґ і я живу в Берліні.`]], + ["fill-mask", [`Мене звати .`]], +]); + +const MAPPING_IT: PerLanguageMapping = new Map([ + ["text-classification", [`Mi piaci. Ti amo`]], + [ + "token-classification", + [ + `Mi chiamo Wolfgang e vivo a Berlino`, + `Mi chiamo Sarah e vivo a Londra`, + `Mi chiamo Clara e vivo a Berkeley in California.`, + ], + ], + [ + "question-answering", + [ + { + text: `Dove vivo?`, + context: `Mi chiamo Wolfgang e vivo a Berlino`, + }, + { + text: `Dove vivo?`, + context: `Mi chiamo Sarah e vivo a Londra`, + }, + { + text: `Come mio chiamo?`, + context: `Mi chiamo Clara e vivo a Berkeley.`, + }, + ], + ], + ["translation", [`Mi chiamo Wolfgang e vivo a Berlino`, `Mi chiamo Sarah e vivo a Londra`]], + [ + "summarization", + [ + `La torre degli Asinelli è una delle cosiddette due torri di Bologna, simbolo della città, situate in piazza di porta Ravegnana, all'incrocio tra le antiche strade San Donato (ora via Zamboni), San Vitale, Maggiore e Castiglione. Eretta, secondo la tradizione, fra il 1109 e il 1119 dal nobile Gherardo Asinelli, la torre è alta 97,20 metri, pende verso ovest per 2,23 metri e presenta all'interno una scalinata composta da 498 gradini. Ancora non si può dire con certezza quando e da chi fu costruita la torre degli Asinelli. Si presume che la torre debba il proprio nome a Gherardo Asinelli, il nobile cavaliere di fazione ghibellina al quale se ne attribuisce la costruzione, iniziata secondo una consolidata tradizione l'11 ottobre 1109 e terminata dieci anni dopo, nel 1119.`, + ], + ], + [ + "text-generation", + [ + `Mi chiamo Loreto e mi piace`, + `Mi chiamo Thomas e il mio principale`, + `Mi chiamo Marianna, la mia cosa preferita`, + `Mi chiamo Clara e sono`, + `C'era una volta`, + ], + ], + ["fill-mask", [`Roma è la d'Italia.`, `Lo scopo della vita è .`]], + [ + "sentence-similarity", + [ + { + source_sentence: "Questa è una persona felice", + sentences: ["Questo è un cane felice", "Questa è una persona molto felice", "Oggi è una giornata di sole"], + }, + ], + ], +]); + +const MAPPING_FA: PerLanguageMapping = new Map([ + [ + "text-classification", + [`پروژه به موقع تحویل شد و همه چیز خوب بود.`, `سیب‌زمینی بی‌کیفیت بود.`, `قیمت و کیفیت عالی`, `خوب نبود اصلا`], + ], + [ + "token-classification", + [ + `این سریال به صورت رسمی در تاریخ دهم می ۲۰۱۱ توسط شبکه فاکس برای پخش رزرو شد.`, + `دفتر مرکزی شرکت پارس‌مینو در شهر اراک در استان مرکزی قرار دارد.`, + `وی در سال ۲۰۱۳ درگذشت و مسئول خاکسپاری و اقوامش برای او مراسم یادبود گرفتند.`, + ], + ], + [ + "question-answering", + [ + { + text: `من کجا زندگی میکنم؟`, + context: `نام من پژمان است و در گرگان زندگی میکنم.`, + }, + { + text: `نامم چیست و کجا زندگی می‌کنم؟`, + context: `اسمم سارا است و در آفریقای جنوبی زندگی میکنم.`, + }, + { + text: `نام من چیست؟`, + context: `من مریم هستم و در تبریز زندگی می‌کنم.`, + }, + { + text: `بیشترین مساحت جنگل آمازون در کدام کشور است؟`, + context: [ + "آمازون نام بزرگ‌ترین جنگل بارانی جهان است که در شمال آمریکای جنوبی قرار گرفته و بیشتر آن در خاک برزیل و پرو", + "جای دارد. بیش از نیمی از همه جنگل‌های بارانی باقی‌مانده در جهان در آمازون قرار دارد.", + "مساحت جنگل‌های آمازون ۵٫۵ میلیون کیلومتر مربع است که بین ۹ کشور تقسیم شده‌است.", + ].join("\n"), + }, + ], + ], + [ + "translation", + [ + "بیشتر مساحت جنگل‌های آمازون در حوضه آبریز رود آمازون و ۱۱۰۰ شاخه آن واقع شده‌است.", + "مردمان نَبَطی از هزاره‌های یکم و دوم پیش از میلاد در این منطقه زندگی می‌کردند.", + ], + ], + [ + "summarization", + [ + [ + "شاهنامه اثر حکیم ابوالقاسم فردوسی توسی، حماسه‌ای منظوم، بر حسب دست نوشته‌های ", + "موجود دربرگیرنده نزدیک به ۵۰٬۰۰۰ بیت تا نزدیک به ۶۱٬۰۰۰ بیت و یکی از ", + "بزرگ‌ترین و برجسته‌ترین سروده‌های حماسی جهان است که سرایش آن دست‌آوردِ ", + "دست‌کم سی سال کارِ پیوستهٔ این سخن‌سرای نامدار ایرانی است. موضوع این شاهکار ادبی،", + " افسانه‌ها و تاریخ ایران از آغاز تا حملهٔ عرب‌ها به ایران در سدهٔ هفتم میلادی است", + " (شاهنامه از سه بخش اسطوره، پهلوانی و تاریخی تشکیل شده‌است) که در چهار", + " دودمان پادشاهیِ پیشدادیان، کیانیان، اشکانیان و ساسانیان گنجانده می‌شود.", + " شاهنامه بر وزن «فَعولُن فعولن فعولن فَعَلْ»، در بحرِ مُتَقارِبِ مثمَّنِ محذوف نگاشته شده‌است.", + "هنگامی که زبان دانش و ادبیات در ایران زبان عربی بود، فردوسی، با سرودن شاهنامه", + " با ویژگی‌های هدف‌مندی که داشت، زبان پارسی را زنده و پایدار کرد. یکی از ", + " بن‌مایه‌های مهمی که فردوسی برای سرودن شاهنامه از آن استفاده کرد،", + " شاهنامهٔ ابومنصوری بود. شاهنامه نفوذ بسیاری در جهت‌گیری ", + " فرهنگ فارسی و نیز بازتاب‌های شکوه‌مندی در ادبیات جهان داشته‌است و شاعران ", + " بزرگی مانند گوته و ویکتور هوگو از آن به نیکی یاد کرده‌اند.", + ].join("\n"), + ], + ], + ["text-generation", ["اسم من نازنین است و من", "روزی روزگاری"]], + [ + "fill-mask", + [ + `زندگی یک سوال است و این که چگونه کنیم پاسخ این سوال!`, + `زندگی از مرگ پرسید: چرا همه من را دارند اما از تو متنفرند؟`, + ], + ], +]); + +const MAPPING_AR: PerLanguageMapping = new Map([ + ["text-classification", [`أحبك. أهواك`]], + [ + "token-classification", + [`إسمي محمد وأسكن في برلين`, `إسمي ساره وأسكن في لندن`, `إسمي سامي وأسكن في القدس في فلسطين.`], + ], + [ + "question-answering", + [ + { + text: `أين أسكن؟`, + context: `إسمي محمد وأسكن في بيروت`, + }, + { + text: `أين أسكن؟`, + context: `إسمي ساره وأسكن في لندن`, + }, + { + text: `ما اسمي؟`, + context: `اسمي سعيد وأسكن في حيفا.`, + }, + { + text: `ما لقب خالد بن الوليد بالعربية؟`, + context: `خالد بن الوليد من أبطال وقادة الفتح الإسلامي وقد تحدثت عنه اللغات الإنجليزية والفرنسية والإسبانية ولقب بسيف الله المسلول.`, + }, + ], + ], + ["translation", [`إسمي محمد وأسكن في برلين`, `إسمي ساره وأسكن في لندن`]], + [ + "summarization", + [ + `تقع الأهرامات في الجيزة قرب القاهرة في مصر وقد بنيت منذ عدة قرون، وقيل إنها كانت قبورا للفراعنة وتم بناؤها بعملية هندسية رائعة واستقدمت حجارتها من جبل المقطم وتم نقلها بالسفن أو على الرمل، وما تزال شامخة ويقصدها السياح من كافة أرجاء المعمورة.`, + ], + ], + [ + "text-generation", + [ + `إسمي محمد وأحب أن`, + `دع المكارم لا ترحل لبغيتها - واقعد فإنك أنت الطاعم الكاسي.`, + `لماذا نحن هنا؟`, + `القدس مدينة تاريخية، بناها الكنعانيون في`, + `كان يا ما كان في قديم الزمان`, + ], + ], + ["fill-mask", [`باريس فرنسا.`, `فلسفة الحياة هي .`]], + [ + "sentence-similarity", + [ + { + source_sentence: "هذا شخص سعيد", + sentences: ["هذا كلب سعيد", "هذا شخص سعيد جدا", "اليوم هو يوم مشمس"], + }, + ], + ], +]); + +const MAPPING_BN: PerLanguageMapping = new Map([ + ["text-classification", [`বাঙালির ঘরে ঘরে আজ নবান্ন উৎসব।`]], + [ + "token-classification", + [`আমার নাম জাহিদ এবং আমি ঢাকায় বাস করি।`, `তিনি গুগলে চাকরী করেন।`, `আমার নাম সুস্মিতা এবং আমি কলকাতায় বাস করি।`], + ], + ["translation", [`আমার নাম জাহিদ, আমি রংপুরে বাস করি।`, `আপনি কী আজকে বাসায় আসবেন?`]], + [ + "summarization", + [ + `‘ইকোনমিস্ট’ লিখেছে, অ্যান্টিবডির চার মাস স্থায়ী হওয়ার খবরটি দুই কারণে আনন্দের। অ্যান্টিবডি যত দিন পর্যন্ত শরীরে টিকবে, তত দিন সংক্রমণ থেকে সুরক্ষিত থাকা সম্ভব। অর্থাৎ, এমন এক টিকার প্রয়োজন হবে, যা অ্যান্টিবডির উত্পাদনকে প্ররোচিত করতে পারে এবং দীর্ঘস্থায়ী সুরক্ষা দিতে পারে। এগুলো খুঁজে বের করাও সহজ। এটি আভাস দেয়, ব্যাপক হারে অ্যান্টিবডি শনাক্তকরণ ফলাফল মোটামুটি নির্ভুল হওয়া উচিত। দ্বিতীয় আরেকটি গবেষণার নেতৃত্ব দিয়েছেন যুক্তরাজ্যের মেডিকেল রিসার্চ কাউন্সিলের (এমআরসি) ইমিউনোলজিস্ট তাও দং। তিনি টি-সেল শনাক্তকরণে কাজ করেছেন। টি-সেল শনাক্তকরণের প্রক্রিয়া অবশ্য অ্যান্টিবডির মতো এত আলোচিত নয়। তবে সংক্রমণের বিরুদ্ধে লড়াই এবং দীর্ঘমেয়াদি সুরক্ষায় সমান গুরুত্বপূর্ণ ভূমিকা পালন করে। গবেষণাসংক্রান্ত নিবন্ধ প্রকাশিত হয়েছে ‘নেচার ইমিউনোলজি’ সাময়িকীতে। তাঁরা বলছেন, গবেষণার ক্ষেত্রে কোভিড-১৯ মৃদু সংক্রমণের শিকার ২৮ ব্যক্তির রক্তের নমুনা, ১৪ জন গুরুতর অসুস্থ ও ১৬ জন সুস্থ ব্যক্তির রক্তের নমুনা পরীক্ষা করেছেন। গবেষণা নিবন্ধে বলা হয়, সংক্রমিত ব্যক্তিদের ক্ষেত্রে টি-সেলের তীব্র প্রতিক্রিয়া তাঁরা দেখেছেন। এ ক্ষেত্রে মৃদু ও গুরুতর অসুস্থ ব্যক্তিদের ক্ষেত্রে প্রতিক্রিয়ার ভিন্নতা পাওয়া গেছে।`, + ], + ], + ["text-generation", [`আমি রতন এবং আমি`, `তুমি যদি চাও তবে`, `মিথিলা আজকে বড্ড`]], + ["fill-mask", [`আমি বাংলায় গাই।`, `আমি খুব ভালোবাসি। `]], + [ + "question-answering", + [ + { + text: `প্রথম এশিয়া কাপ ক্রিকেট টুর্নামেন্ট কোথায় অনুষ্ঠিত হয় ?`, + context: `প্রথম টুর্নামেন্ট অনুষ্ঠিত হয় ১৯৮৪ সালে সংযুক্ত আরব আমিরাত এর শারজাহ তে যেখানে কাউন্সিলের মূল অফিস ছিল (১৯৯৫ পর্যন্ত)। ভারত শ্রীলঙ্কার সাথে আন্তরিকতাহীন ক্রিকেট সম্পর্কের কারণে ১৯৮৬ সালের টুর্নামেন্ট বর্জন করে। ১৯৯৩ সালে ভারত ও পাকিস্তান এর মধ্যে রাজনৈতিক অস্থিরতার কারণে এটি বাতিল হয়ে যায়। শ্রীলঙ্কা এশিয়া কাপ শুরু থেকে অংশ গ্রহণ করে আসছে। আন্তর্জাতিক ক্রিকেট কাউন্সিল নিয়ম করে দিয়েছে যে এশিয়া কাপের সকল খেলা অনুষ্ঠিত হবে অফিসিয়াল একদিনের আন্তর্জাতিক ক্রিকেট হিসেবে। এসিসি ঘোষনা অনুযায়ী প্রতি দুই বছর পর পর টুর্নামেন্ট অনুষ্ঠিত হয় ২০০৮ সাল থেকে।`, + }, + { + text: `ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর মৃত্যু কবে হয় ?`, + context: `২০১৬ সালের ২৩ জুলাই হৃদরোগে আক্রান্ত হয়ে মহাশ্বেতা দেবী কলকাতার বেল ভিউ ক্লিনিকে ভর্তি হন। সেই বছরই ২৮ জুলাই একাধিক অঙ্গ বিকল হয়ে তাঁর মৃত্যু ঘটে। তিনি মধুমেহ, সেপ্টিসেমিয়া ও মূত্র সংক্রমণ রোগেও ভুগছিলেন।`, + }, + { + text: `মাস্টারদা সূর্যকুমার সেনের বাবার নাম কী ছিল ?`, + context: `সূর্য সেন ১৮৯৪ সালের ২২ মার্চ চট্টগ্রামের রাউজান থানার নোয়াপাড়ায় অর্থনৈতিক ভাবে অস্বচ্ছল পরিবারে জন্মগ্রহণ করেন। তাঁর পিতার নাম রাজমনি সেন এবং মাতার নাম শশী বালা সেন। রাজমনি সেনের দুই ছেলে আর চার মেয়ে। সূর্য সেন তাঁদের পরিবারের চতুর্থ সন্তান। দুই ছেলের নাম সূর্য ও কমল। চার মেয়ের নাম বরদাসুন্দরী, সাবিত্রী, ভানুমতী ও প্রমিলা। শৈশবে পিতা মাতাকে হারানো সূর্য সেন কাকা গৌরমনি সেনের কাছে মানুষ হয়েছেন। সূর্য সেন ছেলেবেলা থেকেই খুব মনোযোগী ভাল ছাত্র ছিলেন এবং ধর্মভাবাপন্ন গম্ভীর প্রকৃতির ছিলেন।`, + }, + ], + ], + [ + "sentence-similarity", + [ + { + source_sentence: "সে একজন সুখী ব্যক্তি", + sentences: ["সে হ্যাপি কুকুর", "সে খুব সুখী মানুষ", "আজ একটি রৌদ্রোজ্জ্বল দিন"], + }, + ], + ], +]); + +const MAPPING_MN: PerLanguageMapping = new Map([ + ["text-classification", [`Би чамд хайртай`]], + [ + "token-classification", + [ + `Намайг Дорж гэдэг. Би Улаанбаатарт амьдардаг.`, + `Намайг Ганбат гэдэг. Би Увс аймагт төрсөн.`, + `Манай улс таван хошуу малтай.`, + ], + ], + [ + "question-answering", + [ + { + text: `Та хаана амьдардаг вэ?`, + context: `Намайг Дорж гэдэг. Би Улаанбаатарт амьдардаг.`, + }, + { + text: `Таныг хэн гэдэг вэ?`, + context: `Намайг Дорж гэдэг. Би Улаанбаатарт амьдардаг.`, + }, + { + text: `Миний нэрийг хэн гэдэг вэ?`, + context: `Намайг Ганбат гэдэг. Би Увс аймагт төрсөн.`, + }, + ], + ], + ["translation", [`Намайг Дорж гэдэг. Би Улаанбаатарт амьдардаг.`, `Намайг Ганбат гэдэг. Би Увс аймагт төрсөн.`]], + [ + "summarization", + [ + `Монгол Улс (1992 оноос хойш) — дорно болон төв Азид оршдог бүрэн эрхт улс. Хойд талаараа Орос, бусад талаараа Хятад улстай хиллэдэг далайд гарцгүй орон. Нийслэл — Улаанбаатар хот. Алтайн нуруунаас Хянган, Соёноос Говь хүрсэн 1 сая 566 мянган км2 уудам нутагтай, дэлхийд нутаг дэвсгэрийн хэмжээгээр 19-рт жагсдаг. 2015 оны эхэнд Монгол Улсын хүн ам 3 сая хүрсэн (135-р олон). Үндсэндээ монгол үндэстэн (95 хувь), мөн хасаг, тува хүн байна. 16-р зуунаас хойш буддын шашин, 20-р зуунаас шашингүй байдал дэлгэрсэн ба албан хэрэгт монгол хэлээр харилцана.`, + ], + ], + [ + "text-generation", + [`Намайг Дорж гэдэг. Би`, `Хамгийн сайн дуучин бол`, `Миний дуртай хамтлаг бол`, `Эрт урьдын цагт`], + ], + ["fill-mask", [`Монгол улсын Улаанбаатар хотоос ярьж байна.`, `Миний амьдралын зорилго бол .`]], + [ + "automatic-speech-recognition", + [ + { + label: `Common Voice Train Example`, + src: `https://cdn-media.huggingface.co/common_voice/train/common_voice_mn_18577472.wav`, + }, + { + label: `Common Voice Test Example`, + src: `https://cdn-media.huggingface.co/common_voice/test/common_voice_mn_18577346.wav`, + }, + ], + ], + [ + "text-to-speech", + [ + `Би Монгол улсын иргэн.`, + `Энэхүү жишээ нь цаанаа ямар ч утга агуулаагүй болно`, + `Сар шинэдээ сайхан шинэлэж байна уу?`, + ], + ], + [ + "sentence-similarity", + [ + { + source_sentence: "Энэ бол аз жаргалтай хүн юм", + sentences: ["Энэ бол аз жаргалтай нохой юм", "Энэ бол маш их аз жаргалтай хүн юм", "Өнөөдөр нарлаг өдөр байна"], + }, + ], + ], +]); + +const MAPPING_SI: PerLanguageMapping = new Map([ + ["translation", [`සිංහල ඉතා අලංකාර භාෂාවකි.`, `මෙම තාක්ෂණය භාවිතා කරන ඔබට ස්තූතියි.`]], + ["fill-mask", [`මම ගෙදර .`, ` ඉගෙනීමට ගියාය.`]], +]); + +const MAPPING_DE: PerLanguageMapping = new Map([ + [ + "question-answering", + [ + { + text: `Wo wohne ich?`, + context: `Mein Name ist Wolfgang und ich lebe in Berlin`, + }, + { + text: `Welcher Name wird auch verwendet, um den Amazonas-Regenwald auf Englisch zu beschreiben?`, + context: `Der Amazonas-Regenwald, auf Englisch auch als Amazonien oder Amazonas-Dschungel bekannt, ist ein feuchter Laubwald, der den größten Teil des Amazonas-Beckens Südamerikas bedeckt. Dieses Becken umfasst 7.000.000 Quadratkilometer (2.700.000 Quadratmeilen), von denen 5.500.000 Quadratkilometer (2.100.000 Quadratmeilen) vom Regenwald bedeckt sind. Diese Region umfasst Gebiete von neun Nationen. Der größte Teil des Waldes befindet sich in Brasilien mit 60% des Regenwaldes, gefolgt von Peru mit 13%, Kolumbien mit 10% und geringen Mengen in Venezuela, Ecuador, Bolivien, Guyana, Suriname und Französisch-Guayana. Staaten oder Abteilungen in vier Nationen enthalten "Amazonas" in ihren Namen. Der Amazonas repräsentiert mehr als die Hälfte der verbleibenden Regenwälder des Planeten und umfasst den größten und artenreichsten tropischen Regenwald der Welt mit geschätzten 390 Milliarden Einzelbäumen, die in 16.000 Arten unterteilt sind.`, + }, + ], + ], + [ + "sentence-similarity", + [ + { + source_sentence: "Das ist eine glückliche Person", + sentences: [ + "Das ist ein glücklicher Hund", + "Das ist eine sehr glückliche Person", + "Heute ist ein sonniger Tag", + ], + }, + ], + ], +]); + +const MAPPING_DV: PerLanguageMapping = new Map([ + ["text-classification", [`އަހަރެން ގަޔާވޭ. އަހަރެން ލޯބިވޭ`]], + [ + "token-classification", + [`އަހަރެންގެ ނަމަކީ އަހުމަދު އަދި އަހަރެން ދިރިއުޅެނީ މާލޭގަ`, `އަހަރެންގެ ނަމަކީ ސާރާ އަދި އަހަރެން ދިރިއުޅެނީ އުތީމުގަ`, `އަހަރެންގެ ނަމަކީ އައިޝާ އަދި އަހަރެން ދިރިއުޅެނީ ފޭދޫ، އައްޑޫގަ`], + ], + [ + "question-answering", + [ + { + text: `އަހަރެން ދިރިއުޅެނީ ކޮންތާކު؟`, + context: `އަހަރެންގެ ނަމަކީ އަހުމަދު އަދި އަހަރެން ދިރިއުޅެނީ މާލޭގަ`, + }, + { + text: `އަހަރެން ދިރިއުޅެނީ ކޮންތާކު؟`, + context: `އަހަރެންގެ ނަމަކީ ސާރާ އަދި އަހަރެން ދިރިއުޅެނީ އުތީމުގަ`, + }, + { + text: `އަހަރެންގެ ނަމަކީ ކޮބާ؟`, + context: `އަހަރެންގެ ނަމަކީ އައިޝާ އަދި އަހަރެން ދިރިއުޅެނީ ފޭދޫގަ`, + }, + { + text: `އެމޭޒަން ރެއިންފޮރެސްޓް ސިފަކޮށްދިނުމަށް އިނގިރޭސި ބަހުން ބޭނުންކުރާނީ ކޮންނަމެއް؟`, + context: `އެމޭޒަން ރެއިންފޮރެސްޓް (ޕޯޗުޖީޒް: ފްލޮރެސްޓާ އެމަސޮނިކާ ނުވަތަ އެމަސޮނިއާ؛ ސްޕެނިޝް: ސެލްވާ އެމަސޮނިކާ, އެމަސޮނިއާ ނޫނީ އާންމުކޮށް އެމަޒޯނިއާ؛ ފްރެންޗް: ފޮރޭ އެމެޒޮނިއެން؛ ޑަޗް: އެމެޒޯންރޭގެވައުޑް)، އިގިރޭސި ބަހުން ބުނާ އެމެޒޯނިއާ ނުވަތަ ދަ އެމޭޒަން ޖަންގަލް އަކީ, ސައުތު އެމެރިކާގެ އެމޭޒަން ބޭސިން ސަރަހައްދުގެ ބޮޑުބައެއްގައި ހިމެނޭ މޮއިސްޓް ބޮރޯޑްލީފް ފޮރެސްޓެއެކެވެ. އެމޭޒަން ބޭސިން ސަރަހައްދުގެ ބޮޑު މިނަކީ 7 މިލިއަން އަކަ ކިލޯމީޓަރ (2.7 މިލިއަން އަކަ މައިލް(. މީގެ ތެރެއިން 5.5 މިލިއަން އަކަ ކިލޯމީޓަރ (2.1 މިލިއަން އަކަ މައިލް) އަކީ މި ފޮރެސްޓެވެ. މި ސަރަހައްދުގައި 9 ގައުމަކަށް ނިސްބަތްވާ ޓެރިޓަރީ ހިމެނެއެވެ. 60% އާއިއެކެ އެންމެ ބޮޑު ބައެއް ނިސްބަތްވަނީ ބްރެޒިލްއަށެވެ. އޭގެ ފަހުތުން 13% އާއެކު ޕެރޫ އާއި 10% އާއެކު ކޮލަމްބިއާ އަދި ކުޑަ ބައެއް ހިމެނޭ ގޮތުން ވެނެޒުއެލާ, އެކްއަޑޯ, ބޮލިވިއާ, ގުޔާނާ, ސުރިނާމް އަދި ފްރެންޗް ގްއާނާ އަށް ވެސް ނިސްބަތްވެއެވެ. މީގެ ތެރެއިން 4 ގައުމެއްގައި "އެމެޒޮނާސް" ހިމަނައިގެން ސްޓޭޓް ނުވަތަ ޑިޕާޓްމަންޓް އަކަށް ނަންދީފައިވެއެވެ. މުޅި ދުނިޔޭގައި ބާކީ ހުރި ރެއިންފޮރެސްޓްގެ ތެރެއިން ދެބައިކުޅަ އެއްބަޔަށްވުރެބޮޑުވަރެއް އެމޭޒޮން ރެއިންފޮރެސްޓް ހިއްސާކުރެއެވެ. މިއީ މުޅި ދުނިޔެއިން އެންމޮ ބޮޑު އަދި އެންމެ ބައޮޑައިވަރސް ރެއިންފޮރެސްޓް ޓްރެކްޓެވެ. ލަފާކުރެވޭ ގޮތުން 16 ހާސް ސްޕީޝީސްއަށް ބެހިގެންވާ 390 މިލިއަން ވައްތަރުގެ ގަސް މިތާގައި ހިމެނެއެވެ`, + }, + ], + ], + ["translation", [`އަހަރެންގެ ނަމަކީ އަހުމަދު އަދި އަހަރެން ދިރިއުޅެނީ މާލޭގަ`, `އަހަރެންގެ ނަމަކީ ސާރާ އަދި އަހަރެން ދިރިއުޅެނީ އުތީމުގަ`]], + [ + "summarization", + [ + `ޓަވަރުގެ އުސްމިނަކީ 324 މީޓަރު، އެއީ ގާތްގަނޑަކަށް 81 ބުރީގެ އިމާރާތަކާއި އެއްވަރެވެ. އެއީ ޕެރިސްގައި ހުރި އެންމެ އުސް އިމާރާތެވެ. އޭގެ ހަތަރެސްކަނަށް ހުރި ބުޑުގެ ދިގުމިނަކީ ކޮންމެ ފަރާތަކުން 125 މީޓަރެވެ. (410 ފޫޓު) އައިފިލް ޓަވަރު ބިނާކުރި އިރު، ވޮޝިންގްޓަން މޮނިއުމެންޓްގެ އުސްމިން ފަހަނައަޅާ ގޮސް، ދުނިޔޭގައި މީހުން އުފެއްދި ތަންތަނުގެ ތެރެއިން އެންމެ އުސް ތަނުގެ ލަގަބު ލިބުނެވެ. އަދި 1930 ގައި ނިއު ޔޯކްގެ ކްރައިސްލަރ ބިލްޑިންގް ބިނާކުރުމާއި ހަމައަށް 41 އަހަރު ވަންދެން މިލަގަބު ހިފެހެއްޓިއެވެ. މިއީ 300 މީޓަރަށް ވުރެ އުސްކޮށް އިމާރާތްކުރެވުނު ފުރަތަމަ ތަނެވެ. 1957 ގައި ޓަވަރުގެ އެންމެ މަތީގައި ހަރުކުރެވުނު ބްރޯޑްކާސްޓިންގ އޭރިއަލްގެ ސަބަބުން މިހާރު މި ޓަވަރު ކްރައިސްލަރ ބިލްޑިންގއަށް ވުރެ 5.2 މީޓަރ (17 ފޫޓު) އުހެވެ. މި ޓްރާންސްމިޓަރު ނުލާ، އައިފިލް ޓަވަރަކީ، މިލާއު ވިއާޑަކްޓަށް ފަހު ފްރާންސްގައި ހުރި 2 ވަނައަށް އެންމެ އުސް ފްރީސްޓޭންޑިންގ އިމާރާތެވެ`, + ], + ], + [ + "text-generation", + [`އަހަރެންގެ ނަމަކީ ޔޫސުފް އަދި އަހަރެންގެ މައިގަނޑު`, `އަހަރެންގެ ނަމަކީ މަރިއަމް، އަހަރެން އެންމެ ގަޔާވާ`, `އަހަރެންގެ ނަމަކީ ފާތުމަތު އަދި އަހަރެން`, `،އެއް ޒަމާނެއްގައި`], + ], + ["fill-mask", [`. މާލެ އަކީ ދިވެހިރާއްޖޭގެ`, `ގަރުދިޔައަކީ ދިވެހިންގެ މެދުގައި ކެއުމެއް.`]], +]); + +export const MAPPING_DEFAULT_WIDGET = new Map([ + ["en", MAPPING_EN], + ["zh", MAPPING_ZH], + ["fr", MAPPING_FR], + ["es", MAPPING_ES], + ["ru", MAPPING_RU], + ["uk", MAPPING_UK], + ["it", MAPPING_IT], + ["fa", MAPPING_FA], + ["ar", MAPPING_AR], + ["bn", MAPPING_BN], + ["mn", MAPPING_MN], + ["si", MAPPING_SI], + ["de", MAPPING_DE], + ["dv", MAPPING_DV], +]); diff --git a/node_modules/@huggingface/tasks/src/gguf.ts b/node_modules/@huggingface/tasks/src/gguf.ts new file mode 100644 index 0000000000000000000000000000000000000000..11df0c1c5ce7967917f750bf7cecc9266e23be95 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/gguf.ts @@ -0,0 +1,205 @@ +// This list is copied from gguf/types.ts, but will all types available (for backward compatibility) +// NOT to be confused with GGMLQuantizationType, a FileQuantization can contain multiple GGMLQuantizationType +// For example, Q4_K_M model can contains Q4_K and Q6_K tensors +export enum GGMLFileQuantizationType { + F32 = 0, + F16 = 1, + Q4_0 = 2, + Q4_1 = 3, + Q4_1_SOME_F16 = 4, + Q4_2 = 5, + Q4_3 = 6, + Q8_0 = 7, + Q5_0 = 8, + Q5_1 = 9, + Q2_K = 10, + Q3_K_S = 11, + Q3_K_M = 12, + Q3_K_L = 13, + Q4_K_S = 14, + Q4_K_M = 15, + Q5_K_S = 16, + Q5_K_M = 17, + Q6_K = 18, + IQ2_XXS = 19, + IQ2_XS = 20, + Q2_K_S = 21, + IQ3_XS = 22, + IQ3_XXS = 23, + IQ1_S = 24, + IQ4_NL = 25, + IQ3_S = 26, + IQ3_M = 27, + IQ2_S = 28, + IQ2_M = 29, + IQ4_XS = 30, + IQ1_M = 31, + BF16 = 32, + Q4_0_4_4 = 33, + Q4_0_4_8 = 34, + Q4_0_8_8 = 35, + TQ1_0 = 36, + TQ2_0 = 37, + MXFP4_MOE = 38, + + // custom quants used by unsloth + // they are not officially a scheme enum value in GGUF, but only here for naming + Q2_K_XL = 1000, + Q3_K_XL = 1001, + Q4_K_XL = 1002, + Q5_K_XL = 1003, + Q6_K_XL = 1004, + Q8_K_XL = 1005, +} + +const ggufQuants = Object.values(GGMLFileQuantizationType).filter((v): v is string => typeof v === "string"); +export const GGUF_QUANT_RE = new RegExp( + "(?UD-)?" + `(?${ggufQuants.join("|")})` + "(_(?[A-Z]+))?", +); +export const GGUF_QUANT_RE_GLOBAL = new RegExp(GGUF_QUANT_RE, "g"); + +export function parseGGUFQuantLabel(fname: string): string | undefined { + const quantLabel = fname.toUpperCase().match(GGUF_QUANT_RE_GLOBAL)?.at(-1); // if there is multiple quant substrings in a name, we prefer the last one + return quantLabel; +} + +// order of quantization, from biggest to smallest +// this list must be in sync with the order in GGMLFileQuantizationType +// the gguf.spec.ts tests are using verify if the order is correct +export const GGUF_QUANT_ORDER: GGMLFileQuantizationType[] = [ + GGMLFileQuantizationType.F32, + GGMLFileQuantizationType.BF16, + GGMLFileQuantizationType.F16, + GGMLFileQuantizationType.Q8_K_XL, + GGMLFileQuantizationType.Q8_0, + + // 6-bit quantizations + GGMLFileQuantizationType.Q6_K_XL, + GGMLFileQuantizationType.Q6_K, + + // 5-bit quantizations + GGMLFileQuantizationType.Q5_K_XL, + GGMLFileQuantizationType.Q5_K_M, + GGMLFileQuantizationType.Q5_K_S, + GGMLFileQuantizationType.Q5_0, + GGMLFileQuantizationType.Q5_1, + + // 4-bit quantizations + GGMLFileQuantizationType.Q4_K_XL, + GGMLFileQuantizationType.Q4_K_M, + GGMLFileQuantizationType.Q4_K_S, + GGMLFileQuantizationType.IQ4_NL, + GGMLFileQuantizationType.IQ4_XS, + GGMLFileQuantizationType.Q4_0_4_4, + GGMLFileQuantizationType.Q4_0_4_8, + GGMLFileQuantizationType.Q4_0_8_8, + GGMLFileQuantizationType.Q4_1_SOME_F16, + GGMLFileQuantizationType.Q4_0, + GGMLFileQuantizationType.Q4_1, + GGMLFileQuantizationType.Q4_2, + GGMLFileQuantizationType.Q4_3, + GGMLFileQuantizationType.MXFP4_MOE, + + // 3-bit quantizations + GGMLFileQuantizationType.Q3_K_XL, + GGMLFileQuantizationType.Q3_K_L, + GGMLFileQuantizationType.Q3_K_M, + GGMLFileQuantizationType.Q3_K_S, + GGMLFileQuantizationType.IQ3_M, + GGMLFileQuantizationType.IQ3_S, + GGMLFileQuantizationType.IQ3_XS, + GGMLFileQuantizationType.IQ3_XXS, + + // 2-bit quantizations + GGMLFileQuantizationType.Q2_K_XL, + GGMLFileQuantizationType.Q2_K, + GGMLFileQuantizationType.Q2_K_S, + GGMLFileQuantizationType.IQ2_M, + GGMLFileQuantizationType.IQ2_S, + GGMLFileQuantizationType.IQ2_XS, + GGMLFileQuantizationType.IQ2_XXS, + + // 1-bit quantizations + GGMLFileQuantizationType.IQ1_S, + GGMLFileQuantizationType.IQ1_M, + GGMLFileQuantizationType.TQ1_0, + GGMLFileQuantizationType.TQ2_0, +]; + +// This function finds the nearest quantization type that is less than or equal to the given quantization type. +// It returns undefined if no such quantization type is found. +export function findNearestQuantType( + quant: GGMLFileQuantizationType, + availableQuants: GGMLFileQuantizationType[], +): GGMLFileQuantizationType | undefined { + // Create a map for quick index lookup from the defined order + const orderMap = new Map(); + GGUF_QUANT_ORDER.forEach((q, index) => { + orderMap.set(q, index); + }); + + const targetIndex = orderMap.get(quant) ?? 0; // the 0 case should never happen + + // Filter the available quantizations to include only those defined in the order map, + // then sort them according to the GGUF_QUANT_ORDER (from largest/index 0 to smallest/highest index). + const sortedAvailable = availableQuants + .filter((q) => orderMap.has(q)) + .sort((a, b) => (orderMap.get(a) ?? Infinity) - (orderMap.get(b) ?? Infinity)); + + // If no valid quantizations are available after filtering + if (sortedAvailable.length === 0) { + return undefined; + } + + // Iterate through the sorted available quantizations (largest to smallest). + // Find the first one whose order index is >= the target index. + // This means finding the largest quantization that is smaller than or equal to the target. + for (const availableQuant of sortedAvailable) { + // We know the key exists due to the filter above. + const availableIndex = orderMap.get(availableQuant) ?? 0; + if (availableIndex >= targetIndex) { + return availableQuant; + } + } + + // If the loop completes, it means all available quantizations are larger (have a smaller index) + // than the target quantization. In this case, return the "smallest" available quantization, + // which is the last element in the sorted list (highest index among available). + return sortedAvailable[sortedAvailable.length - 1]; +} + +// This list is only used to calculate the size of the model, NOT to be confused with the quantization FILE type +export enum GGMLQuantizationType { + F32 = 0, + F16 = 1, + Q4_0 = 2, + Q4_1 = 3, + Q5_0 = 6, + Q5_1 = 7, + Q8_0 = 8, + Q8_1 = 9, + Q2_K = 10, + Q3_K = 11, + Q4_K = 12, + Q5_K = 13, + Q6_K = 14, + Q8_K = 15, + IQ2_XXS = 16, + IQ2_XS = 17, + IQ3_XXS = 18, + IQ1_S = 19, + IQ4_NL = 20, + IQ3_S = 21, + IQ2_S = 22, + IQ4_XS = 23, + I8 = 24, + I16 = 25, + I32 = 26, + I64 = 27, + F64 = 28, + IQ1_M = 29, + BF16 = 30, + TQ1_0 = 34, + TQ2_0 = 35, + MXFP4 = 39, +} diff --git a/node_modules/@huggingface/tasks/src/hardware.ts b/node_modules/@huggingface/tasks/src/hardware.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a1fa987d3290d778f46780ffc33b5eb6ef04583 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/hardware.ts @@ -0,0 +1,813 @@ +/** + * Biden AI Executive Order (since revoked by President Trump): + * https://web.archive.org/web/20250105222429/https://www.whitehouse.gov/briefing-room/presidential-actions/2023/10/30/executive-order-on-the-safe-secure-and-trustworthy-development-and-use-of-artificial-intelligence/ + */ +export const TFLOPS_THRESHOLD_WHITE_HOUSE_MODEL_TRAINING_TOTAL = 10 ** 14; +export const TFLOPS_THRESHOLD_WHITE_HOUSE_MODEL_TRAINING_TOTAL_BIOLOGY = 10 ** 11; +export const TFLOPS_THRESHOLD_WHITE_HOUSE_CLUSTER = 10 ** 8; + +/** + * EU AI Act + * https://ec.europa.eu/commission/presscorner/detail/en/qanda_21_1683 + */ +export const TFLOPS_THRESHOLD_EU_AI_ACT_MODEL_TRAINING_TOTAL = 10 ** 13; + +export interface HardwareSpec { + /** + * Approximate value, in FP16 whenever possible for GPUs and FP32 for CPUs. + * This is only approximate/theoretical and shouldn't be taken too seriously. + * Currently the CPU values are from cpu-monkey.com + * while the GPU values are from techpowerup.com + * + * Note to reviewers: I got fed up with data entry, + * and HuggingChat running Llama3 with Web search was failing a bit, + * so some of those values might be slightly inaccurate. Forgive me and please feel free to improve. + */ + tflops: number; + /** + * If an array is specified, options of memory size (can be VRAM, unified RAM) + * e.g. an A100 exists in 40 or 80 GB. + */ + memory?: number[]; +} + +export const DEFAULT_MEMORY_OPTIONS = [ + 8, 16, 24, 32, 40, 48, 64, 80, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, +]; + +export const SKUS = { + GPU: { + NVIDIA: { + B200: { + tflops: 496.6, + memory: [192], + }, + H200: { + tflops: 241.3, + memory: [141], + }, + H100: { + tflops: 267.6, + memory: [80], + }, + L40s: { + tflops: 91.61, + memory: [48], + }, + L40: { + tflops: 90.52, + memory: [48], + }, + L20: { + tflops: 59.35, + memory: [48], + }, + L4: { + tflops: 30.29, + memory: [24], + }, + GB10: { + tflops: 29.71, + memory: [128], + }, + "RTX PRO 6000 WS": { + tflops: 126, + memory: [96], + }, + "RTX PRO 6000 Max-Q": { + tflops: 116, + memory: [96], + }, + "RTX 6000 Ada": { + tflops: 91.1, + memory: [48], + }, + "RTX 5880 Ada": { + tflops: 69.3, + memory: [48], + }, + "RTX 5000 Ada": { + tflops: 65.3, + memory: [32], + }, + "RTX 4500 Ada": { + tflops: 39.6, + memory: [24], + }, + "RTX 4000 Ada": { + tflops: 26.7, + memory: [20], + }, + "RTX 4000 SFF Ada": { + tflops: 19.2, + memory: [20], + }, + "RTX 2000 Ada": { + tflops: 12.0, + memory: [16], + }, + "RTX A6000": { + tflops: 38.7, + memory: [48], + }, + "RTX A5000": { + tflops: 27.77, + memory: [8, 12, 24], + }, + "RTX A5000 Max-Q": { + tflops: 16.59, + memory: [16], + }, + "RTX A5000 Mobile": { + tflops: 19.35, + memory: [16], + }, + "RTX A4000": { + tflops: 19.17, + memory: [16], + }, + "RTX A4000 Max-Q": { + tflops: 14.28, + memory: [8], + }, + "RTX A4000 Mobile": { + tflops: 17.2, + memory: [8], + }, + "RTX A3000 Mobile": { + tflops: 10.9, + memory: [6, 12], + }, + "RTX A2000": { + tflops: 7.987, + memory: [6, 12], + }, + "RTX A2000 Embedded": { + tflops: 6.026, + memory: [4], + }, + "RTX A2000 Max-Q": { + tflops: 6.1, + memory: [4, 8], + }, + "RTX A2000 Mobile": { + tflops: 8.4, + memory: [4, 8], + }, + A100: { + tflops: 77.97, + memory: [80, 40], + }, + A40: { + tflops: 37.42, + memory: [48], + }, + A30: { + tflops: 10.32, + memory: [24], + }, + A10: { + tflops: 31.24, + memory: [24], + }, + A2: { + tflops: 4.531, // source: https://www.techpowerup.com/gpu-specs/a2.c3848 + memory: [16], + }, + "RTX 5090": { + tflops: 104.8, + memory: [32], + }, + "RTX 5090 D": { + tflops: 104.8, + memory: [32], + }, + "RTX 5080": { + tflops: 56.28, + memory: [16], + }, + "RTX 5080 Mobile": { + tflops: 24.58, + memory: [16], + }, + "RTX 5070": { + tflops: 30.84, + memory: [12], + }, + "RTX 5070 Mobile": { + tflops: 23.22, + memory: [8], + }, + "RTX 5070 Ti": { + tflops: 43.94, + memory: [16], + }, + "RTX 5060 Ti": { + tflops: 23.7, // source https://www.techpowerup.com/gpu-specs/geforce-rtx-5060-ti.c4246 + memory: [16, 8], + }, + "RTX 5060": { + tflops: 19.18, // source https://www.techpowerup.com/gpu-specs/geforce-rtx-5060.c4219 + memory: [8], + }, + "RTX 4090": { + tflops: 82.58, + memory: [24], + }, + "RTX 4090D": { + tflops: 79.49, + memory: [24, 48], + }, + "RTX 4090 Mobile": { + tflops: 32.98, + memory: [16], + }, + "RTX 4080 SUPER": { + tflops: 52.2, + memory: [16], + }, + "RTX 4080": { + tflops: 48.7, + memory: [16], + }, + "RTX 4080 Mobile": { + tflops: 24.72, + memory: [12], + }, + "RTX 4070": { + tflops: 29.15, + memory: [12], + }, + "RTX 4070 Mobile": { + tflops: 15.62, + memory: [8], + }, + "RTX 4070 Ti": { + tflops: 40.09, + memory: [12], + }, + "RTX 4070 Super": { + tflops: 35.48, + memory: [12], + }, + "RTX 4070 Ti Super": { + tflops: 44.1, + memory: [16], + }, + "RTX 4060": { + tflops: 15.11, + memory: [8], + }, + "RTX 4060 Ti": { + tflops: 22.06, + memory: [8, 16], + }, + "RTX 4090 Laptop": { + tflops: 32.98, + memory: [16], + }, + "RTX 4080 Laptop": { + tflops: 24.72, + memory: [12], + }, + "RTX 4070 Laptop": { + tflops: 15.62, + memory: [8], + }, + "RTX 4060 Laptop": { + tflops: 11.61, + memory: [8], + }, + "RTX 4050 Laptop": { + tflops: 8.9, + memory: [6], + }, + "RTX 3090": { + tflops: 35.58, + memory: [24], + }, + "RTX 3090 Ti": { + tflops: 40, + memory: [24], + }, + "RTX 3080": { + tflops: 30.6, + memory: [12, 10], + }, + "RTX 3080 Ti": { + tflops: 34.1, + memory: [12], + }, + "RTX 3080 Mobile": { + tflops: 18.98, + memory: [8], + }, + "RTX 3070": { + tflops: 20.31, + memory: [8], + }, + "RTX 3070 Ti": { + tflops: 21.75, + memory: [8], + }, + "RTX 3070 Ti Mobile": { + tflops: 16.6, + memory: [8], + }, + "RTX 3060 Ti": { + tflops: 16.2, + memory: [8], + }, + "RTX 3060": { + tflops: 12.74, + memory: [12, 8], + }, + "RTX 2080 Ti": { + tflops: 26.9, + memory: [11, 22], // 22GB: modded 2080ti + }, + "RTX 2080": { + tflops: 20.14, + memory: [8], + }, + "RTX 2070": { + tflops: 14.93, + memory: [8], + }, + "RTX 2070 SUPER Mobile": { + tflops: 14.13, + memory: [8], + }, + "RTX 2070 SUPER": { + tflops: 18.12, + memory: [8], + }, + "RTX 3060 Mobile": { + tflops: 10.94, + memory: [6], + }, + "RTX 3050 Mobile": { + tflops: 7.639, + memory: [4, 6], + }, + "RTX 2060": { + tflops: 12.9, + memory: [6], + }, + "RTX 2060 12GB": { + tflops: 14.36, + memory: [12], + }, + "RTX 2060 Mobile": { + tflops: 9.22, + memory: [6], + }, + "GTX 1080 Ti": { + tflops: 11.34, // float32 (GPU does not support native float16) + memory: [11], + }, + "GTX 1070 Ti": { + tflops: 8.2, // float32 (GPU does not support native float16) + memory: [8], + }, + "GTX 1060": { + tflops: 3.9, // float32 (GPU does not support native float16) + memory: [3, 6], + }, + "GTX 1050 Ti": { + tflops: 2.1, // float32 (GPU does not support native float16) + memory: [4], + }, + "RTX Titan": { + tflops: 32.62, + memory: [24], + }, + "GTX 1660": { + tflops: 10.05, + memory: [6], + }, + "GTX 1650 Mobile": { + tflops: 6.39, + memory: [4], + }, + T4: { + tflops: 65.13, + memory: [16], + }, + T10: { + tflops: 20.0, + memory: [16], + }, + V100: { + tflops: 28.26, + memory: [32, 16], + }, + "Quadro P6000": { + tflops: 12.63, // float32 (GPU does not support native float16) + memory: [24], + }, + P40: { + tflops: 11.76, // float32 (GPU does not support native float16) + memory: [24], + }, + P100: { + tflops: 19.05, + memory: [16], + }, + "Jetson AGX Orin 64GB": { + tflops: 10.65, + memory: [64], + }, + "Jetson AGX Orin 32GB": { + tflops: 6.66, + memory: [32], + }, + "Jetson Orin NX 16GB": { + tflops: 3.76, + memory: [16], + }, + "Jetson Orin NX 8GB": { + tflops: 3.13, + memory: [8], + }, + "Jetson Orin Nano 8GB": { + tflops: 2.56, + memory: [8], + }, + "Jetson Orin Nano 4GB": { + tflops: 1.28, + memory: [4], + }, + "Jetson AGX Xavier": { + tflops: 2.82, + memory: [32, 64], + }, + "Jetson Xavier NX": { + tflops: 1.69, + memory: [8, 16], + }, + "Jetson TX2": { + tflops: 1.33, + memory: [4, 8], + }, + "Jetson Nano": { + tflops: 0.47, + memory: [4], + }, + }, + AMD: { + MI300: { + tflops: 383.0, + memory: [192], + }, + MI250: { + tflops: 362.1, + memory: [128], + }, + MI210: { + tflops: 181.0, + memory: [64], + }, + MI100: { + tflops: 184.6, + memory: [32], + }, + MI60: { + tflops: 29.5, + memory: [32], + }, + MI50: { + tflops: 26.5, + memory: [16, 32], + }, + "R9700 PRO": { + tflops: 95.7, + memory: [32], + }, + "RX 9070 XT": { + tflops: 97.32, + memory: [16], + }, + "RX 9070": { + tflops: 72.25, + memory: [16], + }, + "RX 7900 XTX": { + tflops: 122.8, + memory: [24], + }, + "RX 7900 XT": { + tflops: 103.0, + memory: [20], + }, + "RX 7900 GRE": { + tflops: 91.96, + memory: [16], + }, + "RX 7800 XT": { + tflops: 74.65, + memory: [16], + }, + "RX 7700 XT": { + tflops: 70.34, + memory: [12], + }, + "RX 7600 XT": { + tflops: 45.14, + memory: [16, 8], + }, + "RX 6950 XT": { + tflops: 47.31, + memory: [16], + }, + "RX 6800": { + tflops: 32.33, + memory: [16], + }, + "RX 6700 XT": { + tflops: 26.43, + memory: [12], + }, + "RX 6700": { + tflops: 22.58, + memory: [10], + }, + "RX 6650 XT": { + tflops: 21.59, + memory: [8], + }, + "RX 6600 XT": { + tflops: 21.21, + memory: [8], + }, + "RX 6600": { + tflops: 17.86, + memory: [8], + }, + "Radeon Pro VII": { + tflops: 26.11, + memory: [16, 32], + }, + }, + INTEL: { + "Arc A750": { + tflops: 34.41, + memory: [8], + }, + "Arc A770": { + tflops: 39.32, + memory: [8, 16], + }, + "Arc B570": { + tflops: 23.04, + memory: [10], + }, + "Arc B580": { + tflops: 27.34, + memory: [12], + }, + "Arc B50": { + tflops: 21.3, + memory: [16], + }, + "Arc B60": { + tflops: 24.58, + memory: [24, 48], + }, + }, + QUALCOMM: { + "Snapdragon X Elite X1E-00-1DE": { + tflops: 4.6, + }, + "Snapdragon X Elite X1E-84-100": { + tflops: 4.6, + }, + "Snapdragon X Elite X1E-80-100": { + tflops: 3.8, + }, + "Snapdragon X Elite X1E-78-100": { + tflops: 3.8, + }, + "Snapdragon X Plus X1P-64-100": { + tflops: 3.8, + }, + }, + }, + CPU: { + Intel: { + "Xeon 4th Generation (Sapphire Rapids)": { + tflops: 1.3, + }, + "Xeon 3th Generation (Ice Lake)": { + tflops: 0.8, + }, + "Xeon 2th Generation (Cascade Lake)": { + tflops: 0.55, + }, + "Xeon E5v4 (Broadwell)": { + tflops: 0.25, + }, + "Xeon E5v3 (Haswell)": { + tflops: 0.2, + }, + "Xeon E5v2 (Ivy Bridge)": { + tflops: 0.15, + }, + "Intel Core Ultra 7 265KF": { + tflops: 1.53, + }, + "Intel Core 14th Generation (i7)": { + tflops: 0.8, + }, + "Intel Core 13th Generation (i9)": { + tflops: 0.85, + }, + "Intel Core 13th Generation (i7)": { + tflops: 0.82, + }, + "Intel Core 13th Generation (i5)": { + tflops: 0.68, + }, + "Intel Core 13th Generation (i3)": { + tflops: 0.57, + }, + "Intel Core 12th Generation (i9)": { + tflops: 0.79, + }, + "Intel Core 12th Generation (i7)": { + tflops: 0.77, + }, + "Intel Core 12th Generation (i5)": { + tflops: 0.65, + }, + "Intel Core 12th Generation (i3)": { + tflops: 0.53, + }, + "Intel Core 11th Generation (i9)": { + tflops: 0.7, + }, + "Intel Core 11th Generation (i7)": { + tflops: 0.6, + }, + "Intel Core 11th Generation (i5)": { + tflops: 0.5, + }, + "Intel Core 11th Generation (i3)": { + tflops: 0.35, + }, + "Intel Core 10th Generation (i9)": { + tflops: 0.46, + }, + "Intel Core 10th Generation (i7)": { + tflops: 0.46, + }, + "Intel Core 10th Generation (i5)": { + tflops: 0.46, + }, + "Intel Core 10th Generation (i3)": { + tflops: 0.44, + }, + }, + AMD: { + "EPYC 5th Generation Zen 5 (Turin)": { + tflops: 13.8, + }, + "EPYC 4th Generation Zen 4 (Genoa)": { + tflops: 5, + }, + "EPYC 3th Generation Zen 3 (Milan)": { + tflops: 2.4, + }, + "EPYC 2th Generation Zen 2 (Rome)": { + tflops: 0.6, + }, + "EPYC 1st Generation Zen (Naples)": { + tflops: 0.6, + }, + "Ryzen Threadripper Zen 5 9000 (Shimada Peak)": { + tflops: 14.0, + }, + "Ryzen Threadripper Zen 4 7000 (Storm Peak)": { + tflops: 10.0, + }, + "Ryzen Threadripper Zen 3 5000 (Chagall)": { + tflops: 4.6, + }, + "Ryzen Threadripper Zen 2 3000 (Castle Peak)": { + tflops: 3.2, + }, + "Ryzen Threadripper Zen 1000 (Whitehaven)": { + tflops: 0.6, + }, + "Ryzen Zen 5 9000 (Ryzen 9)": { + tflops: 0.56, + }, + "Ryzen Zen 5 9000 (Ryzen 7)": { + tflops: 0.56, + }, + "Ryzen Zen 5 9000 (Ryzen 5)": { + tflops: 0.56, + }, + "Ryzen Zen 4 7000 (Ryzen 9)": { + tflops: 0.56, + }, + "Ryzen Zen 4 7000 (Ryzen 7)": { + tflops: 0.56, + }, + "Ryzen Zen 4 7000 (Ryzen 5)": { + tflops: 0.56, + }, + "Ryzen Zen 3 5000 (Ryzen 9)": { + tflops: 1.33, + }, + "Ryzen Zen 3 5000 (Ryzen 7)": { + tflops: 1.33, + }, + "Ryzen Zen 3 5000 (Ryzen 5)": { + tflops: 0.72, + }, + "Ryzen Zen 2 3000 (Ryzen 9)": { + tflops: 0.72, + }, + "Ryzen Zen 2 3000 (Ryzen 7)": { + tflops: 0.72, + }, + "Ryzen Zen 2 3000 (Ryzen 5)": { + tflops: 0.72, + }, + "Ryzen Zen 2 3000 (Ryzen 3)": { + tflops: 0.72, + }, + }, + }, + "Apple Silicon": { + "-": { + "Apple M1": { + tflops: 2.6, + memory: [8, 16], + }, + "Apple M1 Pro": { + tflops: 5.2, + memory: [16, 24, 32], + }, + "Apple M1 Max": { + tflops: 10.4, + memory: [16, 24, 32, 64], + }, + "Apple M1 Ultra": { + tflops: 21, + memory: [16, 24, 32, 64, 96, 128], + }, + "Apple M2": { + tflops: 3.6, + memory: [8, 16, 24], + }, + "Apple M2 Pro": { + tflops: 6.8, + memory: [16, 24, 32], + }, + "Apple M2 Max": { + tflops: 13.49, + memory: [32, 64, 96], + }, + "Apple M2 Ultra": { + tflops: 27.2, + memory: [64, 96, 128, 192], + }, + "Apple M3": { + tflops: 4.1, + memory: [8, 16, 24], + }, + "Apple M3 Pro": { + tflops: 7.4, + memory: [18, 36], + }, + "Apple M3 Max": { + tflops: 14.2, + memory: [36, 48, 64, 96, 128], + }, + "Apple M3 Ultra": { + tflops: 28.4, + memory: [96, 256, 512], + }, + "Apple M4": { + tflops: 4.6, + memory: [16, 24, 32], + }, + "Apple M4 Pro": { + tflops: 9.2, + memory: [24, 48, 64], + }, + "Apple M4 Max": { + tflops: 18.4, + memory: [36, 48, 64, 96, 128, 256, 512], + }, + "Apple M5": { + tflops: 5.7, + memory: [16, 24, 32], + }, + }, + }, +} satisfies Record>>; + +export type SkuType = keyof typeof SKUS; diff --git a/node_modules/@huggingface/tasks/src/index.ts b/node_modules/@huggingface/tasks/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..302e1f4664d90afd11572578a436cf52aba292d5 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/index.ts @@ -0,0 +1,68 @@ +export { LIBRARY_TASK_MAPPING } from "./library-to-tasks.js"; +export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs.js"; +export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks/index.js"; +export * from "./tasks/index.js"; +export { + PIPELINE_DATA, + PIPELINE_TYPES, + type WidgetType, + type PipelineType, + type PipelineData, + type Modality, + MODALITIES, + MODALITY_LABELS, + SUBTASK_TYPES, + PIPELINE_TYPES_SET, +} from "./pipelines.js"; +export { + ALL_DISPLAY_MODEL_LIBRARY_KEYS, + ALL_MODEL_LIBRARY_KEYS, + MODEL_LIBRARIES_UI_ELEMENTS, +} from "./model-libraries.js"; +export type { LibraryUiElement, ModelLibraryKey } from "./model-libraries.js"; +export type { ModelData, TransformersInfo } from "./model-data.js"; +export type { AddedToken, SpecialTokensMap, TokenizerConfig } from "./tokenizer-data.js"; +export type { + WidgetExample, + WidgetExampleAttribute, + WidgetExampleAssetAndPromptInput, + WidgetExampleAssetAndTextInput, + WidgetExampleAssetAndZeroShotInput, + WidgetExampleAssetInput, + WidgetExampleChatInput, + WidgetExampleSentenceSimilarityInput, + WidgetExampleStructuredDataInput, + WidgetExampleTableDataInput, + WidgetExampleTextAndContextInput, + WidgetExampleTextAndTableInput, + WidgetExampleTextInput, + WidgetExampleZeroShotTextInput, + WidgetExampleOutput, + WidgetExampleOutputUrl, + WidgetExampleOutputLabels, + WidgetExampleOutputAnswerScore, + WidgetExampleOutputText, +} from "./widget-example.js"; +export { SPECIAL_TOKENS_ATTRIBUTES } from "./tokenizer-data.js"; + +export * from "./gguf.js"; + +export { + type InferenceSnippet, + type InferenceSnippetLanguage, + type ModelDataMinimal, + inferenceSnippetLanguages, + stringifyGenerationConfig, + stringifyMessages, + getModelInputSnippet, +} from "./snippets/index.js"; + +export { SKUS, DEFAULT_MEMORY_OPTIONS } from "./hardware.js"; +export type { HardwareSpec, SkuType } from "./hardware.js"; +export { LOCAL_APPS } from "./local-apps.js"; +export type { LocalApp, LocalAppKey, LocalAppSnippet } from "./local-apps.js"; + +export { DATASET_LIBRARIES_UI_ELEMENTS } from "./dataset-libraries.js"; +export type { DatasetLibraryUiElement, DatasetLibraryKey } from "./dataset-libraries.js"; + +export * from "./inference-providers.js"; diff --git a/node_modules/@huggingface/tasks/src/inference-providers.ts b/node_modules/@huggingface/tasks/src/inference-providers.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee08d12943c9d9aa189c7036178ce94b06c5d752 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/inference-providers.ts @@ -0,0 +1,28 @@ +/// This list is for illustration purposes only. +/// in the `tasks` sub-package, we do not need actual strong typing of the inference providers. +const INFERENCE_PROVIDERS = [ + "cerebras", + "cohere", + "fal-ai", + "fireworks-ai", + "hf-inference", + "hyperbolic", + "ovhcloud", + "replicate", + "sambanova", + "together", +] as const; + +export type SnippetInferenceProvider = (typeof INFERENCE_PROVIDERS)[number] | string; + +export const HF_HUB_INFERENCE_PROXY_TEMPLATE = `https://router.huggingface.co/{{PROVIDER}}`; + +/** + * URL to set as baseUrl in the OpenAI SDK. + * + * TODO(Expose this from InferenceClient in the future?) + */ +export function openAIbaseUrl(provider: SnippetInferenceProvider): string { + const url = HF_HUB_INFERENCE_PROXY_TEMPLATE.replace("{{PROVIDER}}", provider); + return provider === "hf-inference" ? `${url}/v1` : url; +} diff --git a/node_modules/@huggingface/tasks/src/library-to-tasks.ts b/node_modules/@huggingface/tasks/src/library-to-tasks.ts new file mode 100644 index 0000000000000000000000000000000000000000..af2d6894ba0edc272193377325da478c5545d601 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/library-to-tasks.ts @@ -0,0 +1,75 @@ +import type { ModelLibraryKey } from "./model-libraries.js"; +import type { PipelineType } from "./pipelines.js"; + +/** + * Mapping from library name to its supported tasks. + * HF-Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping. + * This mapping is partially generated automatically by "python-api-export-tasks" action in + * huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually + * based on api-inference (hf_types.rs). + */ +export const LIBRARY_TASK_MAPPING: Partial> = { + "adapter-transformers": ["question-answering", "text-classification", "token-classification"], + allennlp: ["question-answering"], + asteroid: [ + // "audio-source-separation", + "audio-to-audio", + ], + bertopic: ["text-classification"], + diffusers: ["image-to-image", "text-to-image"], + doctr: ["object-detection"], + espnet: ["text-to-speech", "automatic-speech-recognition"], + fairseq: ["text-to-speech", "audio-to-audio"], + fastai: ["image-classification"], + fasttext: ["feature-extraction", "text-classification"], + flair: ["token-classification"], + k2: ["automatic-speech-recognition"], + keras: ["image-classification"], + nemo: ["automatic-speech-recognition"], + open_clip: ["zero-shot-classification", "zero-shot-image-classification"], + paddlenlp: ["fill-mask", "summarization", "zero-shot-classification"], + peft: ["text-generation"], + "pyannote-audio": ["automatic-speech-recognition"], + "sentence-transformers": ["feature-extraction", "sentence-similarity"], + setfit: ["text-classification"], + sklearn: ["tabular-classification", "tabular-regression", "text-classification"], + spacy: ["token-classification", "text-classification", "sentence-similarity"], + "span-marker": ["token-classification"], + speechbrain: ["audio-classification", "audio-to-audio", "automatic-speech-recognition", "text-to-speech"], + stanza: ["token-classification"], + timm: ["image-classification", "image-feature-extraction"], + transformers: [ + "audio-classification", + "automatic-speech-recognition", + "depth-estimation", + "document-question-answering", + "feature-extraction", + "fill-mask", + "image-classification", + "image-feature-extraction", + "image-segmentation", + "image-to-image", + "image-to-text", + "image-text-to-text", + "mask-generation", + "object-detection", + "question-answering", + "summarization", + "table-question-answering", + "text-classification", + "text-generation", + "text-to-audio", + "text-to-speech", + "token-classification", + "translation", + "video-classification", + "visual-question-answering", + "zero-shot-classification", + "zero-shot-image-classification", + "zero-shot-object-detection", + ], + mindspore: ["image-classification"], +}; + +// Pipeline types that were supported in legacy transformers versions (<5.0.0) +export const REMOVED_IN_V5_TRANSFORMERS_PIPELINES: PipelineType[] = ["image-to-text", "summarization", "translation"]; diff --git a/node_modules/@huggingface/tasks/src/local-apps.spec.ts b/node_modules/@huggingface/tasks/src/local-apps.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f3a02cf03b7430d4a72f11a3a2266d9e2050d14 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/local-apps.spec.ts @@ -0,0 +1,137 @@ +import { describe, expect, it } from "vitest"; +import { LOCAL_APPS } from "./local-apps.js"; +import type { ModelData } from "./model-data.js"; + +describe("local-apps", () => { + it("llama.cpp conversational", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["llama.cpp"]; + const model: ModelData = { + id: "bartowski/Llama-3.2-3B-Instruct-GGUF", + tags: ["conversational"], + inference: "", + }; + const snippet = snippetFunc(model); + + expect(snippet[0].content).toEqual([ + `# Start a local OpenAI-compatible server with a web UI: +llama-server -hf bartowski/Llama-3.2-3B-Instruct-GGUF:{{QUANT_TAG}}`, + `# Run inference directly in the terminal: +llama-cli -hf bartowski/Llama-3.2-3B-Instruct-GGUF:{{QUANT_TAG}}`, + ]); + }); + + it("llama.cpp non-conversational", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["llama.cpp"]; + const model: ModelData = { + id: "mlabonne/gemma-2b-GGUF", + tags: [], + inference: "", + }; + const snippet = snippetFunc(model); + + expect(snippet[0].content).toEqual([ + `# Start a local OpenAI-compatible server with a web UI: +llama-server -hf mlabonne/gemma-2b-GGUF:{{QUANT_TAG}}`, + `# Run inference directly in the terminal: +llama-cli -hf mlabonne/gemma-2b-GGUF:{{QUANT_TAG}}`, + ]); + }); + + it("vLLM conversational llm", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["vllm"]; + const model: ModelData = { + id: "meta-llama/Llama-3.2-3B-Instruct", + pipeline_tag: "text-generation", + tags: ["conversational"], + inference: "", + }; + const snippet = snippetFunc(model); + + expect((snippet[0].content as string[]).join("\n")).toEqual(`# Start the vLLM server: +vllm serve "meta-llama/Llama-3.2-3B-Instruct" +# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:8000/v1/chat/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "meta-llama/Llama-3.2-3B-Instruct", + "messages": [ + { + "role": "user", + "content": "What is the capital of France?" + } + ] + }'`); + }); + + it("vLLM non-conversational llm", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["vllm"]; + const model: ModelData = { + id: "meta-llama/Llama-3.2-3B", + tags: [""], + inference: "", + }; + const snippet = snippetFunc(model); + + expect((snippet[0].content as string[]).join("\n")).toEqual(`# Start the vLLM server: +vllm serve "meta-llama/Llama-3.2-3B" +# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:8000/v1/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "meta-llama/Llama-3.2-3B", + "prompt": "Once upon a time,", + "max_tokens": 512, + "temperature": 0.5 + }'`); + }); + + it("vLLM conversational vlm", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["vllm"]; + const model: ModelData = { + id: "meta-llama/Llama-3.2-11B-Vision-Instruct", + pipeline_tag: "image-text-to-text", + tags: ["conversational"], + inference: "", + }; + const snippet = snippetFunc(model); + + expect((snippet[0].content as string[]).join("\n")).toEqual(`# Start the vLLM server: +vllm serve "meta-llama/Llama-3.2-11B-Vision-Instruct" +# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:8000/v1/chat/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "meta-llama/Llama-3.2-11B-Vision-Instruct", + "messages": [ + { + "role": "user", + "content": [ + { + "type": "text", + "text": "Describe this image in one sentence." + }, + { + "type": "image_url", + "image_url": { + "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" + } + } + ] + } + ] + }'`); + }); + + it("docker model runner", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["docker-model-runner"]; + const model: ModelData = { + id: "bartowski/Llama-3.2-3B-Instruct-GGUF", + tags: ["conversational"], + gguf: { total: 1, context_length: 4096 }, + inference: "", + }; + const snippet = snippetFunc(model); + + expect(snippet).toEqual(`docker model run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:{{QUANT_TAG}}`); + }); +}); diff --git a/node_modules/@huggingface/tasks/src/local-apps.ts b/node_modules/@huggingface/tasks/src/local-apps.ts new file mode 100644 index 0000000000000000000000000000000000000000..11843bd0624c36fab4ea3dacbe4d264b63d3f77e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/local-apps.ts @@ -0,0 +1,625 @@ +import { parseGGUFQuantLabel } from "./gguf.js"; +import type { ModelData } from "./model-data.js"; +import type { PipelineType } from "./pipelines.js"; +import { stringifyMessages } from "./snippets/common.js"; +import { getModelInputSnippet } from "./snippets/inputs.js"; +import type { ChatCompletionInputMessage } from "./tasks/index.js"; + +export interface LocalAppSnippet { + /** + * Title of the snippet + */ + title: string; + /** + * Optional setup guide + */ + setup?: string; + /** + * Content (or command) to be run + */ + content: string | string[]; +} + +/** + * Elements configurable by a local app. + */ +export type LocalApp = { + /** + * Name that appears in buttons + */ + prettyLabel: string; + /** + * Link to get more info about a local app (website etc) + */ + docsUrl: string; + /** + * main category of app + */ + mainTask: PipelineType; + /** + * Whether to display a pill "macOS-only" + */ + macOSOnly?: boolean; + + comingSoon?: boolean; + /** + * IMPORTANT: function to figure out whether to display the button on a model page's main "Use this model" dropdown. + */ + displayOnModelPage: (model: ModelData) => boolean; +} & ( + | { + /** + * If the app supports deeplink, URL to open. + */ + deeplink: (model: ModelData, filepath?: string) => URL; + } + | { + /** + * And if not (mostly llama.cpp), snippet to copy/paste in your terminal + * Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files. + * Support the placeholder {{QUANT_TAG}} that will be replaced by the list of available quant tags or will be removed if there are no multiple quant files in a same repo. + */ + snippet: (model: ModelData, filepath?: string) => string | string[] | LocalAppSnippet | LocalAppSnippet[]; + } +); + +function isAwqModel(model: ModelData): boolean { + return model.config?.quantization_config?.quant_method === "awq"; +} + +function isGptqModel(model: ModelData): boolean { + return model.config?.quantization_config?.quant_method === "gptq"; +} + +function isAqlmModel(model: ModelData): boolean { + return model.config?.quantization_config?.quant_method === "aqlm"; +} + +function isMarlinModel(model: ModelData): boolean { + return model.config?.quantization_config?.quant_method === "marlin"; +} + +function isTransformersModel(model: ModelData): boolean { + return model.tags.includes("transformers"); +} + +function isTgiModel(model: ModelData): boolean { + return model.tags.includes("text-generation-inference"); +} + +function isLlamaCppGgufModel(model: ModelData) { + return !!model.gguf?.context_length; +} + +function isVllmModel(model: ModelData): boolean { + return ( + (isAwqModel(model) || + isGptqModel(model) || + isAqlmModel(model) || + isMarlinModel(model) || + isLlamaCppGgufModel(model) || + isTransformersModel(model)) && + (model.pipeline_tag === "text-generation" || model.pipeline_tag === "image-text-to-text") + ); +} + +function isDockerModelRunnerModel(model: ModelData): boolean { + return isLlamaCppGgufModel(model) || isVllmModel(model); +} + +function isAmdRyzenModel(model: ModelData) { + return model.tags.includes("ryzenai-hybrid") || model.tags.includes("ryzenai-npu"); +} + +function isMlxModel(model: ModelData) { + return model.tags.includes("mlx"); +} + +function getQuantTag(filepath?: string): string { + const defaultTag = ":{{QUANT_TAG}}"; + + if (!filepath) { + return defaultTag; + } + + const quantLabel = parseGGUFQuantLabel(filepath); + return quantLabel ? `:${quantLabel}` : defaultTag; +} + +const snippetLlamacpp = (model: ModelData, filepath?: string): LocalAppSnippet[] => { + const serverCommand = (binary: string) => { + const snippet = [ + "# Start a local OpenAI-compatible server with a web UI:", + `${binary} -hf ${model.id}${getQuantTag(filepath)}`, + ]; + return snippet.join("\n"); + }; + const cliCommand = (binary: string) => { + const snippet = ["# Run inference directly in the terminal:", `${binary} -hf ${model.id}${getQuantTag(filepath)}`]; + return snippet.join("\n"); + }; + return [ + { + title: "Install from brew", + setup: "brew install llama.cpp", + content: [serverCommand("llama-server"), cliCommand("llama-cli")], + }, + { + title: "Install from WinGet (Windows)", + setup: "winget install llama.cpp", + content: [serverCommand("llama-server"), cliCommand("llama-cli")], + }, + { + title: "Use pre-built binary", + setup: [ + // prettier-ignore + "# Download pre-built binary from:", + "# https://github.com/ggerganov/llama.cpp/releases", + ].join("\n"), + content: [serverCommand("./llama-server"), cliCommand("./llama-cli")], + }, + { + title: "Build from source code", + setup: [ + "git clone https://github.com/ggerganov/llama.cpp.git", + "cd llama.cpp", + "cmake -B build", + "cmake --build build -j --target llama-server llama-cli", + ].join("\n"), + content: [serverCommand("./build/bin/llama-server"), cliCommand("./build/bin/llama-cli")], + }, + { + title: "Use Docker", + content: snippetDockerModelRunner(model, filepath), + }, + ]; +}; + +const snippetNodeLlamaCppCli = (model: ModelData, filepath?: string): LocalAppSnippet[] => { + const tagName = getQuantTag(filepath); + return [ + { + title: "Chat with the model", + content: `npx -y node-llama-cpp chat hf:${model.id}${tagName}`, + }, + { + title: "Estimate the model compatibility with your hardware", + content: `npx -y node-llama-cpp inspect estimate hf:${model.id}${tagName}`, + }, + ]; +}; + +const snippetOllama = (model: ModelData, filepath?: string): string => { + return `ollama run hf.co/${model.id}${getQuantTag(filepath)}`; +}; + +const snippetLocalAI = (model: ModelData, filepath?: string): LocalAppSnippet[] => { + const command = (binary: string) => + ["# Load and run the model:", `${binary} huggingface://${model.id}/${filepath ?? "{{GGUF_FILE}}"}`].join("\n"); + return [ + { + title: "Install from binary", + setup: "curl https://localai.io/install.sh | sh", + content: command("local-ai run"), + }, + { + title: "Use Docker images", + setup: [ + // prettier-ignore + "# Pull the image:", + "docker pull localai/localai:latest-cpu", + ].join("\n"), + content: command( + "docker run -p 8080:8080 --name localai -v $PWD/models:/build/models localai/localai:latest-cpu", + ), + }, + ]; +}; + +const snippetVllm = (model: ModelData): LocalAppSnippet[] => { + const messages = getModelInputSnippet(model) as ChatCompletionInputMessage[]; + + const isMistral = model.tags.includes("mistral-common"); + const mistralFlags = isMistral + ? " --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice" + : ""; + + const setup = isMistral + ? [ + "# Install vLLM from pip:", + "pip install vllm", + "# Install mistral-common:", + "pip install --upgrade mistral-common", + ].join("\n") + : ["# Install vLLM from pip:", "pip install vllm"].join("\n"); + + const serverCommand = `# Start the vLLM server: +vllm serve "${model.id}"${mistralFlags}`; + + const runCommandInstruct = `# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:8000/v1/chat/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "${model.id}", + "messages": ${stringifyMessages(messages, { + indent: "\t\t", + attributeKeyQuotes: true, + customContentEscaper: (str) => str.replace(/'/g, "'\\''"), + })} + }'`; + const runCommandNonInstruct = `# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:8000/v1/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "${model.id}", + "prompt": "Once upon a time,", + "max_tokens": 512, + "temperature": 0.5 + }'`; + const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct; + + return [ + { + title: "Install from pip and serve model", + setup: setup, + content: [serverCommand, runCommand], + }, + { + title: "Use Docker", + content: snippetDockerModelRunner(model), + }, + ]; +}; +const snippetSglang = (model: ModelData): LocalAppSnippet[] => { + const messages = getModelInputSnippet(model) as ChatCompletionInputMessage[]; + + const setup = ["# Install SGLang from pip:", "pip install sglang"].join("\n"); + const serverCommand = `# Start the SGLang server: +python3 -m sglang.launch_server \\ + --model-path "${model.id}" \\ + --host 0.0.0.0 \\ + --port 30000`; + const dockerCommand = `docker run --gpus all \\ + --shm-size 32g \\ + -p 30000:30000 \\ + -v ~/.cache/huggingface:/root/.cache/huggingface \\ + --env "HF_TOKEN=" \\ + --ipc=host \\ + lmsysorg/sglang:latest \\ + python3 -m sglang.launch_server \\ + --model-path "${model.id}" \\ + --host 0.0.0.0 \\ + --port 30000`; + const runCommandInstruct = `# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:30000/v1/chat/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "${model.id}", + "messages": ${stringifyMessages(messages, { + indent: "\t\t", + attributeKeyQuotes: true, + customContentEscaper: (str) => str.replace(/'/g, "'\\''"), + })} + }'`; + const runCommandNonInstruct = `# Call the server using curl (OpenAI-compatible API): +curl -X POST "http://localhost:30000/v1/completions" \\ + -H "Content-Type: application/json" \\ + --data '{ + "model": "${model.id}", + "prompt": "Once upon a time,", + "max_tokens": 512, + "temperature": 0.5 + }'`; + const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct; + + return [ + { + title: "Install from pip and serve model", + setup: setup, + content: [serverCommand, runCommand], + }, + { + title: "Use Docker images", + setup: dockerCommand, + content: [runCommand], + }, + ]; +}; +const snippetTgi = (model: ModelData): LocalAppSnippet[] => { + const runCommand = [ + "# Call the server using curl:", + `curl -X POST "http://localhost:8000/v1/chat/completions" \\`, + ` -H "Content-Type: application/json" \\`, + ` --data '{`, + ` "model": "${model.id}",`, + ` "messages": [`, + ` {"role": "user", "content": "What is the capital of France?"}`, + ` ]`, + ` }'`, + ]; + return [ + { + title: "Use Docker images", + setup: [ + "# Deploy with docker on Linux:", + `docker run --gpus all \\`, + ` -v ~/.cache/huggingface:/root/.cache/huggingface \\`, + ` -e HF_TOKEN="" \\`, + ` -p 8000:80 \\`, + ` ghcr.io/huggingface/text-generation-inference:latest \\`, + ` --model-id ${model.id}`, + ].join("\n"), + content: [runCommand.join("\n")], + }, + ]; +}; + +const snippetMlxLm = (model: ModelData): LocalAppSnippet[] => { + const openaiCurl = [ + "# Calling the OpenAI-compatible server with curl", + `curl -X POST "http://localhost:8000/v1/chat/completions" \\`, + ` -H "Content-Type: application/json" \\`, + ` --data '{`, + ` "model": "${model.id}",`, + ` "messages": [`, + ` {"role": "user", "content": "Hello"}`, + ` ]`, + ` }'`, + ]; + + return [ + { + title: "Generate or start a chat session", + setup: ["# Install MLX LM", "uv tool install mlx-lm"].join("\n"), + content: [ + ...(model.tags.includes("conversational") + ? ["# Interactive chat REPL", `mlx_lm.chat --model "${model.id}"`] + : ["# Generate some text", `mlx_lm.generate --model "${model.id}" --prompt "Once upon a time"`]), + ].join("\n"), + }, + ...(model.tags.includes("conversational") + ? [ + { + title: "Run an OpenAI-compatible server", + setup: ["# Install MLX LM", "uv tool install mlx-lm"].join("\n"), + content: ["# Start the server", `mlx_lm.server --model "${model.id}"`, ...openaiCurl].join("\n"), + }, + ] + : []), + ]; +}; + +const snippetDockerModelRunner = (model: ModelData, filepath?: string): string => { + // Only add quant tag for GGUF models, not safetensors + const quantTag = isLlamaCppGgufModel(model) ? getQuantTag(filepath) : ""; + return `docker model run hf.co/${model.id}${quantTag}`; +}; + +const snippetLemonade = (model: ModelData, filepath?: string): LocalAppSnippet[] => { + const tagName = getQuantTag(filepath); + const modelName = model.id.includes("/") ? model.id.split("/")[1] : model.id; + + // Get recipe according to model type + let simplifiedModelName: string; + let recipe: string; + let checkpoint: string; + let requirements: string; + if (model.tags.some((tag) => ["ryzenai-npu", "ryzenai-hybrid"].includes(tag))) { + recipe = model.tags.includes("ryzenai-npu") ? "oga-npu" : "oga-hybrid"; + checkpoint = model.id; + requirements = " (requires RyzenAI 300 series)"; + simplifiedModelName = modelName.split("-awq-")[0]; + simplifiedModelName += recipe === "oga-npu" ? "-NPU" : "-Hybrid"; + } else { + recipe = "llamacpp"; + checkpoint = `${model.id}${tagName}`; + requirements = ""; + simplifiedModelName = modelName; + } + + return [ + { + title: "Pull the model", + setup: "# Download Lemonade from https://lemonade-server.ai/", + content: [ + `lemonade-server pull user.${simplifiedModelName} --checkpoint ${checkpoint} --recipe ${recipe}`, + "# Note: If you installed from source, use the lemonade-server-dev command instead.", + ].join("\n"), + }, + { + title: `Run and chat with the model${requirements}`, + content: `lemonade-server run user.${simplifiedModelName}`, + }, + { + title: "List all available models", + content: "lemonade-server list", + }, + ]; +}; + +/** + * Add your new local app here. + * + * This is open to new suggestions and awesome upcoming apps. + * + * /!\ IMPORTANT + * + * If possible, you need to support deeplinks and be as cross-platform as possible. + * + * Ping the HF team if we can help with anything! + */ +export const LOCAL_APPS = { + "llama.cpp": { + prettyLabel: "llama.cpp", + docsUrl: "https://github.com/ggerganov/llama.cpp", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + snippet: snippetLlamacpp, + }, + "node-llama-cpp": { + prettyLabel: "node-llama-cpp", + docsUrl: "https://node-llama-cpp.withcat.ai", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + snippet: snippetNodeLlamaCppCli, + }, + vllm: { + prettyLabel: "vLLM", + docsUrl: "https://docs.vllm.ai", + mainTask: "text-generation", + displayOnModelPage: isVllmModel, + snippet: snippetVllm, + }, + sglang: { + prettyLabel: "SGLang", + docsUrl: "https://docs.sglang.io", + mainTask: "text-generation", + displayOnModelPage: (model: ModelData) => + (isAwqModel(model) || + isGptqModel(model) || + isAqlmModel(model) || + isMarlinModel(model) || + isTransformersModel(model)) && + (model.pipeline_tag === "text-generation" || model.pipeline_tag === "image-text-to-text"), + snippet: snippetSglang, + }, + "mlx-lm": { + prettyLabel: "MLX LM", + docsUrl: "https://github.com/ml-explore/mlx-lm", + mainTask: "text-generation", + displayOnModelPage: (model) => model.pipeline_tag === "text-generation" && isMlxModel(model), + snippet: snippetMlxLm, + }, + tgi: { + prettyLabel: "TGI", + docsUrl: "https://huggingface.co/docs/text-generation-inference/", + mainTask: "text-generation", + displayOnModelPage: isTgiModel, + snippet: snippetTgi, + }, + lmstudio: { + prettyLabel: "LM Studio", + docsUrl: "https://lmstudio.ai", + mainTask: "text-generation", + displayOnModelPage: (model) => isLlamaCppGgufModel(model) || isMlxModel(model), + deeplink: (model, filepath) => + new URL(`lmstudio://open_from_hf?model=${model.id}${filepath ? `&file=${filepath}` : ""}`), + }, + localai: { + prettyLabel: "LocalAI", + docsUrl: "https://github.com/mudler/LocalAI", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + snippet: snippetLocalAI, + }, + jan: { + prettyLabel: "Jan", + docsUrl: "https://jan.ai", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + deeplink: (model) => new URL(`jan://models/huggingface/${model.id}`), + }, + backyard: { + prettyLabel: "Backyard AI", + docsUrl: "https://backyard.ai", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + deeplink: (model) => new URL(`https://backyard.ai/hf/model/${model.id}`), + }, + sanctum: { + prettyLabel: "Sanctum", + docsUrl: "https://sanctum.ai", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + deeplink: (model) => new URL(`sanctum://open_from_hf?model=${model.id}`), + }, + jellybox: { + prettyLabel: "Jellybox", + docsUrl: "https://jellybox.com", + mainTask: "text-generation", + displayOnModelPage: (model) => + isLlamaCppGgufModel(model) || + (model.library_name === "diffusers" && + model.tags.includes("safetensors") && + (model.pipeline_tag === "text-to-image" || model.tags.includes("lora"))), + deeplink: (model) => { + if (isLlamaCppGgufModel(model)) { + return new URL(`jellybox://llm/models/huggingface/LLM/${model.id}`); + } else if (model.tags.includes("lora")) { + return new URL(`jellybox://image/models/huggingface/ImageLora/${model.id}`); + } else { + return new URL(`jellybox://image/models/huggingface/Image/${model.id}`); + } + }, + }, + msty: { + prettyLabel: "Msty", + docsUrl: "https://msty.app", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + deeplink: (model) => new URL(`msty://models/search/hf/${model.id}`), + }, + recursechat: { + prettyLabel: "RecurseChat", + docsUrl: "https://recurse.chat", + mainTask: "text-generation", + macOSOnly: true, + displayOnModelPage: isLlamaCppGgufModel, + deeplink: (model) => new URL(`recursechat://new-hf-gguf-model?hf-model-id=${model.id}`), + }, + drawthings: { + prettyLabel: "Draw Things", + docsUrl: "https://drawthings.ai", + mainTask: "text-to-image", + macOSOnly: true, + displayOnModelPage: (model) => + model.library_name === "diffusers" && (model.pipeline_tag === "text-to-image" || model.tags.includes("lora")), + deeplink: (model) => { + if (model.tags.includes("lora")) { + return new URL(`https://drawthings.ai/import/diffusers/pipeline.load_lora_weights?repo_id=${model.id}`); + } else { + return new URL(`https://drawthings.ai/import/diffusers/pipeline.from_pretrained?repo_id=${model.id}`); + } + }, + }, + diffusionbee: { + prettyLabel: "DiffusionBee", + docsUrl: "https://diffusionbee.com", + mainTask: "text-to-image", + macOSOnly: true, + displayOnModelPage: (model) => model.library_name === "diffusers" && model.pipeline_tag === "text-to-image", + deeplink: (model) => new URL(`https://diffusionbee.com/huggingface_import?model_id=${model.id}`), + }, + joyfusion: { + prettyLabel: "JoyFusion", + docsUrl: "https://joyfusion.app", + mainTask: "text-to-image", + macOSOnly: true, + displayOnModelPage: (model) => + model.tags.includes("coreml") && model.tags.includes("joyfusion") && model.pipeline_tag === "text-to-image", + deeplink: (model) => new URL(`https://joyfusion.app/import_from_hf?repo_id=${model.id}`), + }, + ollama: { + prettyLabel: "Ollama", + docsUrl: "https://ollama.com", + mainTask: "text-generation", + displayOnModelPage: isLlamaCppGgufModel, + snippet: snippetOllama, + }, + "docker-model-runner": { + prettyLabel: "Docker Model Runner", + docsUrl: "https://docs.docker.com/ai/model-runner/", + mainTask: "text-generation", + displayOnModelPage: isDockerModelRunnerModel, + snippet: snippetDockerModelRunner, + }, + lemonade: { + prettyLabel: "Lemonade", + docsUrl: "https://lemonade-server.ai", + mainTask: "text-generation", + displayOnModelPage: (model) => isLlamaCppGgufModel(model) || isAmdRyzenModel(model), + snippet: snippetLemonade, + }, +} satisfies Record; + +export type LocalAppKey = keyof typeof LOCAL_APPS; diff --git a/node_modules/@huggingface/tasks/src/model-data.ts b/node_modules/@huggingface/tasks/src/model-data.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd5b88f1906a9ee899e213ab0e3bf7cc567e7d77 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/model-data.ts @@ -0,0 +1,156 @@ +import type { PipelineType } from "./pipelines.js"; +import type { WidgetExample } from "./widget-example.js"; +import type { TokenizerConfig } from "./tokenizer-data.js"; + +/** + * Public interface for model metadata + */ +export interface ModelData { + /** + * id of model (e.g. 'user/repo_name') + */ + id: string; + /** + * Whether or not to enable inference widget for this model + * TODO(type it) + */ + inference: string; + /** + * is this model private? + */ + private?: boolean; + /** + * this dictionary has useful information about the model configuration + */ + config?: { + architectures?: string[]; + /** + * Dict of AutoModel or Auto… class name to local import path in the repo + */ + auto_map?: { + /** + * String Property + */ + [x: string]: string; + }; + model_type?: string; + quantization_config?: { + bits?: number; + load_in_4bit?: boolean; + load_in_8bit?: boolean; + /** + * awq, gptq, aqlm, marlin, … Used by vLLM + */ + quant_method?: string; + }; + tokenizer_config?: TokenizerConfig; + processor_config?: { + chat_template?: string; + }; + chat_template_jinja?: string; + adapter_transformers?: { + model_name?: string; + model_class?: string; + }; + diffusers?: { + _class_name?: string; + }; + sklearn?: { + model?: { + file?: string; + }; + model_format?: string; + }; + speechbrain?: { + speechbrain_interface?: string; + vocoder_interface?: string; + vocoder_model_id?: string; + }; + peft?: { + base_model_name_or_path?: string; + task_type?: string; + }; + keras_hub?: { + tasks?: string[]; + }; + }; + /** + * all the model tags + */ + tags: string[]; + /** + * transformers-specific info to display in the code sample. + */ + transformersInfo?: TransformersInfo; + /** + * Pipeline type + */ + pipeline_tag?: PipelineType | undefined; + /** + * for relevant models, get mask token + */ + mask_token?: string | undefined; + /** + * Example data that will be fed into the widget. + * + * can be set in the model card metadata (under `widget`), + * or by default in `DefaultWidget.ts` + */ + widgetData?: WidgetExample[] | undefined; + /** + * Parameters that will be used by the widget when calling Inference API (serverless) + * https://huggingface.co/docs/api-inference/detailed_parameters + * + * can be set in the model card metadata (under `inference/parameters`) + * Example: + * inference: + * parameters: + * key: val + */ + cardData?: { + inference?: + | boolean + | { + parameters?: Record; + }; + base_model?: string | string[]; + instance_prompt?: string | null; + }; + /** + * Library name + * Example: transformers, SpeechBrain, Stanza, etc. + */ + library_name?: string; + safetensors?: { + parameters: Record; + total: number; + sharded: boolean; + }; + gguf?: { + total: number; + architecture?: string; + context_length?: number; + }; +} + +/** + * transformers-specific info to display in the code sample. + */ +export interface TransformersInfo { + /** + * e.g. AutoModelForSequenceClassification + */ + auto_model: string; + /** + * if set in config.json's auto_map + */ + custom_class?: string; + /** + * e.g. text-classification + */ + pipeline_tag?: PipelineType; + /** + * e.g. "AutoTokenizer" | "AutoFeatureExtractor" | "AutoProcessor" + */ + processor?: string; +} diff --git a/node_modules/@huggingface/tasks/src/model-libraries-downloads.ts b/node_modules/@huggingface/tasks/src/model-libraries-downloads.ts new file mode 100644 index 0000000000000000000000000000000000000000..70fc3bface26cdf0ad939623921435724deb8ced --- /dev/null +++ b/node_modules/@huggingface/tasks/src/model-libraries-downloads.ts @@ -0,0 +1,18 @@ +/** + * This file contains the (simplified) types used + * to represent queries that are made to Elastic + * in order to count number of model downloads + * + * Read this doc about download stats on the Hub: + * + * https://huggingface.co/docs/hub/models-download-stats + * Available fields: + * - path: the complete file path (relative) (e.g: "prefix/file.extension") + * - path_prefix: the prefix of the file path (e.g: "prefix/", empty if no prefix) + * - path_extension: the extension of the file path (e.g: "extension") + * - path_filename: the name of the file path (e.g: "file") + * see also: + * https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html + */ + +export type ElasticSearchQuery = string; diff --git a/node_modules/@huggingface/tasks/src/model-libraries-snippets.spec.ts b/node_modules/@huggingface/tasks/src/model-libraries-snippets.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..81d28f5540d51715b640248e46681ed19358f715 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/model-libraries-snippets.spec.ts @@ -0,0 +1,58 @@ +import { describe, expect, it } from "vitest"; +import type { ModelData } from "./model-data.js"; +import { llama_cpp_python } from "./model-libraries-snippets.js"; + +describe("model-libraries-snippets", () => { + it("llama_cpp_python conversational", async () => { + const model: ModelData = { + id: "bartowski/Llama-3.2-3B-Instruct-GGUF", + pipeline_tag: "text-generation", + tags: ["conversational"], + inference: "", + }; + const snippet = llama_cpp_python(model); + + expect(snippet.join("\n")).toEqual(`# !pip install llama-cpp-python + +from llama_cpp import Llama + +llm = Llama.from_pretrained( + repo_id="bartowski/Llama-3.2-3B-Instruct-GGUF", + filename="{{GGUF_FILE}}", +) + +llm.create_chat_completion( + messages = [ + { + "role": "user", + "content": "What is the capital of France?" + } + ] +)`); + }); + + it("llama_cpp_python non-conversational", async () => { + const model: ModelData = { + id: "mlabonne/gemma-2b-GGUF", + tags: [""], + inference: "", + }; + const snippet = llama_cpp_python(model); + + expect(snippet.join("\n")).toEqual(`# !pip install llama-cpp-python + +from llama_cpp import Llama + +llm = Llama.from_pretrained( + repo_id="mlabonne/gemma-2b-GGUF", + filename="{{GGUF_FILE}}", +) + +output = llm( + "Once upon a time,", + max_tokens=512, + echo=True +) +print(output)`); + }); +}); diff --git a/node_modules/@huggingface/tasks/src/model-libraries-snippets.ts b/node_modules/@huggingface/tasks/src/model-libraries-snippets.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b2dd07a27569633882b07efc8f2d2026f058590 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/model-libraries-snippets.ts @@ -0,0 +1,2446 @@ +import type { ModelData } from "./model-data.js"; +import type { WidgetExampleTextInput, WidgetExampleSentenceSimilarityInput } from "./widget-example.js"; +import { LIBRARY_TASK_MAPPING, REMOVED_IN_V5_TRANSFORMERS_PIPELINES } from "./library-to-tasks.js"; +import { getModelInputSnippet } from "./snippets/inputs.js"; +import type { ChatCompletionInputMessage } from "./tasks/index.js"; +import { stringifyMessages } from "./snippets/common.js"; + +const TAG_CUSTOM_CODE = "custom_code"; + +function nameWithoutNamespace(modelId: string): string { + const splitted = modelId.split("/"); + return splitted.length === 1 ? splitted[0] : splitted[1]; +} + +const escapeStringForJson = (str: string): string => JSON.stringify(str).slice(1, -1); // slice is needed to remove surrounding quotes added by JSON.stringify + +//#region snippets + +export const adapters = (model: ModelData): string[] => [ + `from adapters import AutoAdapterModel + +model = AutoAdapterModel.from_pretrained("${model.config?.adapter_transformers?.model_name}") +model.load_adapter("${model.id}", set_active=True)`, +]; + +const allennlpUnknown = (model: ModelData) => [ + `import allennlp_models +from allennlp.predictors.predictor import Predictor + +predictor = Predictor.from_path("hf://${model.id}")`, +]; + +const allennlpQuestionAnswering = (model: ModelData) => [ + `import allennlp_models +from allennlp.predictors.predictor import Predictor + +predictor = Predictor.from_path("hf://${model.id}") +predictor_input = {"passage": "My name is Wolfgang and I live in Berlin", "question": "Where do I live?"} +predictions = predictor.predict_json(predictor_input)`, +]; + +export const allennlp = (model: ModelData): string[] => { + if (model.tags.includes("question-answering")) { + return allennlpQuestionAnswering(model); + } + return allennlpUnknown(model); +}; + +export const araclip = (model: ModelData): string[] => [ + `from araclip import AraClip + +model = AraClip.from_pretrained("${model.id}")`, +]; + +export const asteroid = (model: ModelData): string[] => [ + `from asteroid.models import BaseModel + +model = BaseModel.from_pretrained("${model.id}")`, +]; + +export const audioseal = (model: ModelData): string[] => { + const watermarkSnippet = `# Watermark Generator +from audioseal import AudioSeal + +model = AudioSeal.load_generator("${model.id}") +# pass a tensor (tensor_wav) of shape (batch, channels, samples) and a sample rate +wav, sr = tensor_wav, 16000 + +watermark = model.get_watermark(wav, sr) +watermarked_audio = wav + watermark`; + + const detectorSnippet = `# Watermark Detector +from audioseal import AudioSeal + +detector = AudioSeal.load_detector("${model.id}") + +result, message = detector.detect_watermark(watermarked_audio, sr)`; + return [watermarkSnippet, detectorSnippet]; +}; + +function get_base_diffusers_model(model: ModelData): string { + return model.cardData?.base_model?.toString() ?? "fill-in-base-model"; +} + +function get_prompt_from_diffusers_model(model: ModelData): string | undefined { + const prompt = (model.widgetData?.[0] as WidgetExampleTextInput | undefined)?.text ?? model.cardData?.instance_prompt; + if (prompt) { + return escapeStringForJson(prompt); + } +} + +export const ben2 = (model: ModelData): string[] => [ + `import requests +from PIL import Image +from ben2 import AutoModel + +url = "https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg" +image = Image.open(requests.get(url, stream=True).raw) + +model = AutoModel.from_pretrained("${model.id}") +model.to("cuda").eval() +foreground = model.inference(image) +`, +]; + +export const bertopic = (model: ModelData): string[] => [ + `from bertopic import BERTopic + +model = BERTopic.load("${model.id}")`, +]; + +export const bm25s = (model: ModelData): string[] => [ + `from bm25s.hf import BM25HF + +retriever = BM25HF.load_from_hub("${model.id}")`, +]; + +export const chatterbox = (): string[] => [ + `# pip install chatterbox-tts +import torchaudio as ta +from chatterbox.tts import ChatterboxTTS + +model = ChatterboxTTS.from_pretrained(device="cuda") + +text = "Ezreal and Jinx teamed up with Ahri, Yasuo, and Teemo to take down the enemy's Nexus in an epic late-game pentakill." +wav = model.generate(text) +ta.save("test-1.wav", wav, model.sr) + +# If you want to synthesize with a different voice, specify the audio prompt +AUDIO_PROMPT_PATH="YOUR_FILE.wav" +wav = model.generate(text, audio_prompt_path=AUDIO_PROMPT_PATH) +ta.save("test-2.wav", wav, model.sr)`, +]; + +export const chronos_forecasting = (model: ModelData): string[] => { + const installSnippet = `pip install chronos-forecasting`; + + const exampleSnippet = `import pandas as pd +from chronos import BaseChronosPipeline + +pipeline = BaseChronosPipeline.from_pretrained("${model.id}", device_map="cuda") + +# Load historical data +context_df = pd.read_csv("https://autogluon.s3.us-west-2.amazonaws.com/datasets/timeseries/misc/AirPassengers.csv") + +# Generate predictions +pred_df = pipeline.predict_df( + context_df, + prediction_length=36, # Number of steps to forecast + quantile_levels=[0.1, 0.5, 0.9], # Quantiles for probabilistic forecast + id_column="item_id", # Column identifying different time series + timestamp_column="Month", # Column with datetime information + target="#Passengers", # Column(s) with time series values to predict +)`; + + return [installSnippet, exampleSnippet]; +}; + +export const colipri = (model: ModelData): string[] => { + const installSnippet = `pip install colipri`; + + const exampleSnippet = `from colipri import get_model +from colipri import get_processor +from colipri import load_sample_ct +from colipri import ZeroShotImageClassificationPipeline + +model = get_model().cuda() +processor = get_processor() +pipeline = ZeroShotImageClassificationPipeline("${model.id}", processor) + +image = load_sample_ct() + +pipeline(image, ["No lung nodules", "Lung nodules"]) +`; + + return [installSnippet, exampleSnippet]; +}; + +export const sap_rpt_one_oss = (): string[] => { + const installSnippet = `pip install git+https://github.com/SAP-samples/sap-rpt-1-oss`; + + const classificationSnippet = `# Run a classification task +from sklearn.datasets import load_breast_cancer +from sklearn.metrics import accuracy_score +from sklearn.model_selection import train_test_split + +from sap_rpt_oss import SAP_RPT_OSS_Classifier + +# Load sample data +X, y = load_breast_cancer(return_X_y=True) +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=42) + +# Initialize a classifier, 8k context and 8-fold bagging gives best performance, reduce if running out of memory +clf = SAP_RPT_OSS_Classifier(max_context_size=8192, bagging=8) + +clf.fit(X_train, y_train) + +# Predict probabilities +prediction_probabilities = clf.predict_proba(X_test) +# Predict labels +predictions = clf.predict(X_test) +print("Accuracy", accuracy_score(y_test, predictions))`; + + const regressionsSnippet = `# Run a regression task +from sklearn.datasets import fetch_openml +from sklearn.metrics import r2_score +from sklearn.model_selection import train_test_split + +from sap_rpt_oss import SAP_RPT_OSS_Regressor + +# Load sample data +df = fetch_openml(data_id=531, as_frame=True) +X = df.data +y = df.target.astype(float) + +# Train-test split +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=42) + +# Initialize the regressor, 8k context and 8-fold bagging gives best performance, reduce if running out of memory +regressor = SAP_RPT_OSS_Regressor(max_context_size=8192, bagging=8) + +regressor.fit(X_train, y_train) + +# Predict on the test set +predictions = regressor.predict(X_test) + +r2 = r2_score(y_test, predictions) +print("R² Score:", r2)`; + return [installSnippet, classificationSnippet, regressionsSnippet]; +}; + +export const cxr_foundation = (): string[] => [ + `# pip install git+https://github.com/Google-Health/cxr-foundation.git#subdirectory=python + +# Load image as grayscale (Stillwaterising, CC0, via Wikimedia Commons) +import requests +from PIL import Image +from io import BytesIO +image_url = "https://upload.wikimedia.org/wikipedia/commons/c/c8/Chest_Xray_PA_3-8-2010.png" +img = Image.open(requests.get(image_url, headers={'User-Agent': 'Demo'}, stream=True).raw).convert('L') + +# Run inference +from clientside.clients import make_hugging_face_client +cxr_client = make_hugging_face_client('cxr_model') +print(cxr_client.get_image_embeddings_from_images([img]))`, +]; + +export const depth_anything_v2 = (model: ModelData): string[] => { + let encoder: string; + let features: string; + let out_channels: string; + + encoder = ""; + features = ""; + out_channels = ""; + + if (model.id === "depth-anything/Depth-Anything-V2-Small") { + encoder = "vits"; + features = "64"; + out_channels = "[48, 96, 192, 384]"; + } else if (model.id === "depth-anything/Depth-Anything-V2-Base") { + encoder = "vitb"; + features = "128"; + out_channels = "[96, 192, 384, 768]"; + } else if (model.id === "depth-anything/Depth-Anything-V2-Large") { + encoder = "vitl"; + features = "256"; + out_channels = "[256, 512, 1024, 1024"; + } + + return [ + ` +# Install from https://github.com/DepthAnything/Depth-Anything-V2 + +# Load the model and infer depth from an image +import cv2 +import torch + +from depth_anything_v2.dpt import DepthAnythingV2 + +# instantiate the model +model = DepthAnythingV2(encoder="${encoder}", features=${features}, out_channels=${out_channels}) + +# load the weights +filepath = hf_hub_download(repo_id="${model.id}", filename="depth_anything_v2_${encoder}.pth", repo_type="model") +state_dict = torch.load(filepath, map_location="cpu") +model.load_state_dict(state_dict).eval() + +raw_img = cv2.imread("your/image/path") +depth = model.infer_image(raw_img) # HxW raw depth map in numpy + `, + ]; +}; + +export const depth_pro = (model: ModelData): string[] => { + const installSnippet = `# Download checkpoint +pip install huggingface-hub +huggingface-cli download --local-dir checkpoints ${model.id}`; + + const inferenceSnippet = `import depth_pro + +# Load model and preprocessing transform +model, transform = depth_pro.create_model_and_transforms() +model.eval() + +# Load and preprocess an image. +image, _, f_px = depth_pro.load_rgb("example.png") +image = transform(image) + +# Run inference. +prediction = model.infer(image, f_px=f_px) + +# Results: 1. Depth in meters +depth = prediction["depth"] +# Results: 2. Focal length in pixels +focallength_px = prediction["focallength_px"]`; + + return [installSnippet, inferenceSnippet]; +}; + +export const derm_foundation = (): string[] => [ + `from huggingface_hub import from_pretrained_keras +import tensorflow as tf, requests + +# Load and format input +IMAGE_URL = "https://storage.googleapis.com/dx-scin-public-data/dataset/images/3445096909671059178.png" +input_tensor = tf.train.Example( + features=tf.train.Features( + feature={ + "image/encoded": tf.train.Feature( + bytes_list=tf.train.BytesList(value=[requests.get(IMAGE_URL, stream=True).content]) + ) + } + ) +).SerializeToString() + +# Load model and run inference +loaded_model = from_pretrained_keras("google/derm-foundation") +infer = loaded_model.signatures["serving_default"] +print(infer(inputs=tf.constant([input_tensor])))`, +]; + +export const dia = (model: ModelData): string[] => [ + `import soundfile as sf +from dia.model import Dia + +model = Dia.from_pretrained("${model.id}") +text = "[S1] Dia is an open weights text to dialogue model. [S2] You get full control over scripts and voices. [S1] Wow. Amazing. (laughs) [S2] Try it now on Git hub or Hugging Face." +output = model.generate(text) + +sf.write("simple.mp3", output, 44100)`, +]; + +export const dia2 = (model: ModelData): string[] => [ + `from dia2 import Dia2, GenerationConfig, SamplingConfig + +dia = Dia2.from_repo("${model.id}", device="cuda", dtype="bfloat16") +config = GenerationConfig( + cfg_scale=2.0, + audio=SamplingConfig(temperature=0.8, top_k=50), + use_cuda_graph=True, +) +result = dia.generate("[S1] Hello Dia2!", config=config, output_wav="hello.wav", verbose=True) +`, +]; + +export const describe_anything = (model: ModelData): string[] => [ + `# pip install git+https://github.com/NVlabs/describe-anything +from huggingface_hub import snapshot_download +from dam import DescribeAnythingModel + +snapshot_download(${model.id}, local_dir="checkpoints") + +dam = DescribeAnythingModel( + model_path="checkpoints", + conv_mode="v1", + prompt_mode="focal_prompt", +)`, +]; + +const diffusers_install = "pip install -U diffusers transformers accelerate"; + +const diffusersDefaultPrompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"; + +const diffusersImg2ImgDefaultPrompt = "Turn this cat into a dog"; + +const diffusersVideoDefaultPrompt = "A man with short gray hair plays a red electric guitar."; + +const diffusers_default = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${model.id}", dtype=torch.bfloat16, device_map="cuda") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersDefaultPrompt}" +image = pipe(prompt).images[0]`, +]; + +const diffusers_image_to_image = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline +from diffusers.utils import load_image + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${model.id}", dtype=torch.bfloat16, device_map="cuda") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersImg2ImgDefaultPrompt}" +input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") + +image = pipe(image=input_image, prompt=prompt).images[0]`, +]; + +const diffusers_image_to_video = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline +from diffusers.utils import load_image, export_to_video + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${model.id}", dtype=torch.bfloat16, device_map="cuda") +pipe.to("cuda") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersVideoDefaultPrompt}" +image = load_image( + "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png" +) + +output = pipe(image=image, prompt=prompt).frames[0] +export_to_video(output, "output.mp4")`, +]; + +const diffusers_controlnet = (model: ModelData) => [ + `from diffusers import ControlNetModel, StableDiffusionControlNetPipeline + +controlnet = ControlNetModel.from_pretrained("${model.id}") +pipe = StableDiffusionControlNetPipeline.from_pretrained( + "${get_base_diffusers_model(model)}", controlnet=controlnet +)`, +]; + +const diffusers_lora = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}", dtype=torch.bfloat16, device_map="cuda") +pipe.load_lora_weights("${model.id}") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersDefaultPrompt}" +image = pipe(prompt).images[0]`, +]; + +const diffusers_lora_image_to_image = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline +from diffusers.utils import load_image + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}", dtype=torch.bfloat16, device_map="cuda") +pipe.load_lora_weights("${model.id}") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersImg2ImgDefaultPrompt}" +input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") + +image = pipe(image=input_image, prompt=prompt).images[0]`, +]; + +const diffusers_lora_text_to_video = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline +from diffusers.utils import export_to_video + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}", dtype=torch.bfloat16, device_map="cuda") +pipe.load_lora_weights("${model.id}") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersVideoDefaultPrompt}" + +output = pipe(prompt=prompt).frames[0] +export_to_video(output, "output.mp4")`, +]; + +const diffusers_lora_image_to_video = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline +from diffusers.utils import load_image, export_to_video + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}", dtype=torch.bfloat16, device_map="cuda") +pipe.load_lora_weights("${model.id}") + +prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersVideoDefaultPrompt}" +input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png") + +image = pipe(image=input_image, prompt=prompt).frames[0] +export_to_video(output, "output.mp4")`, +]; + +const diffusers_textual_inversion = (model: ModelData) => [ + `import torch +from diffusers import DiffusionPipeline + +# switch to "mps" for apple devices +pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}", dtype=torch.bfloat16, device_map="cuda") +pipe.load_textual_inversion("${model.id}")`, +]; + +const diffusers_flux_fill = (model: ModelData) => [ + `import torch +from diffusers import FluxFillPipeline +from diffusers.utils import load_image + +image = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cup.png") +mask = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cup_mask.png") + +# switch to "mps" for apple devices +pipe = FluxFillPipeline.from_pretrained("${model.id}", dtype=torch.bfloat16, device_map="cuda") +image = pipe( + prompt="a white paper cup", + image=image, + mask_image=mask, + height=1632, + width=1232, + guidance_scale=30, + num_inference_steps=50, + max_sequence_length=512, + generator=torch.Generator("cpu").manual_seed(0) +).images[0] +image.save(f"flux-fill-dev.png")`, +]; + +const diffusers_inpainting = (model: ModelData) => [ + `import torch +from diffusers import AutoPipelineForInpainting +from diffusers.utils import load_image + +# switch to "mps" for apple devices +pipe = AutoPipelineForInpainting.from_pretrained("${model.id}", dtype=torch.float16, variant="fp16", device_map="cuda") + +img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png" +mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png" + +image = load_image(img_url).resize((1024, 1024)) +mask_image = load_image(mask_url).resize((1024, 1024)) + +prompt = "a tiger sitting on a park bench" +generator = torch.Generator(device="cuda").manual_seed(0) + +image = pipe( + prompt=prompt, + image=image, + mask_image=mask_image, + guidance_scale=8.0, + num_inference_steps=20, # steps between 15 and 30 work well for us + strength=0.99, # make sure to use \`strength\` below 1.0 + generator=generator, +).images[0]`, +]; + +export const diffusers = (model: ModelData): string[] => { + let codeSnippets: string[]; + if ( + model.tags.includes("StableDiffusionInpaintPipeline") || + model.tags.includes("StableDiffusionXLInpaintPipeline") + ) { + codeSnippets = diffusers_inpainting(model); + } else if (model.tags.includes("controlnet")) { + codeSnippets = diffusers_controlnet(model); + } else if (model.tags.includes("lora")) { + if (model.pipeline_tag === "image-to-image") { + codeSnippets = diffusers_lora_image_to_image(model); + } else if (model.pipeline_tag === "image-to-video") { + codeSnippets = diffusers_lora_image_to_video(model); + } else if (model.pipeline_tag === "text-to-video") { + codeSnippets = diffusers_lora_text_to_video(model); + } else { + codeSnippets = diffusers_lora(model); + } + } else if (model.tags.includes("textual_inversion")) { + codeSnippets = diffusers_textual_inversion(model); + } else if (model.tags.includes("FluxFillPipeline")) { + codeSnippets = diffusers_flux_fill(model); + } else if (model.pipeline_tag === "image-to-video") { + codeSnippets = diffusers_image_to_video(model); + } else if (model.pipeline_tag === "image-to-image") { + codeSnippets = diffusers_image_to_image(model); + } else { + codeSnippets = diffusers_default(model); + } + + return [diffusers_install, ...codeSnippets]; +}; + +export const diffusionkit = (model: ModelData): string[] => { + const sd3Snippet = `# Pipeline for Stable Diffusion 3 +from diffusionkit.mlx import DiffusionPipeline + +pipeline = DiffusionPipeline( + shift=3.0, + use_t5=False, + model_version=${model.id}, + low_memory_mode=True, + a16=True, + w16=True, +)`; + + const fluxSnippet = `# Pipeline for Flux +from diffusionkit.mlx import FluxPipeline + +pipeline = FluxPipeline( + shift=1.0, + model_version=${model.id}, + low_memory_mode=True, + a16=True, + w16=True, +)`; + + const generateSnippet = `# Image Generation +HEIGHT = 512 +WIDTH = 512 +NUM_STEPS = ${model.tags.includes("flux") ? 4 : 50} +CFG_WEIGHT = ${model.tags.includes("flux") ? 0 : 5} + +image, _ = pipeline.generate_image( + "a photo of a cat", + cfg_weight=CFG_WEIGHT, + num_steps=NUM_STEPS, + latent_size=(HEIGHT // 8, WIDTH // 8), +)`; + + const pipelineSnippet = model.tags.includes("flux") ? fluxSnippet : sd3Snippet; + + return [pipelineSnippet, generateSnippet]; +}; + +export const cartesia_pytorch = (model: ModelData): string[] => [ + `# pip install --no-binary :all: cartesia-pytorch +from cartesia_pytorch import ReneLMHeadModel +from transformers import AutoTokenizer + +model = ReneLMHeadModel.from_pretrained("${model.id}") +tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-1B-hf") + +in_message = ["Rene Descartes was"] +inputs = tokenizer(in_message, return_tensors="pt") + +outputs = model.generate(inputs.input_ids, max_length=50, top_k=100, top_p=0.99) +out_message = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0] + +print(out_message) +)`, +]; + +export const cartesia_mlx = (model: ModelData): string[] => [ + `import mlx.core as mx +import cartesia_mlx as cmx + +model = cmx.from_pretrained("${model.id}") +model.set_dtype(mx.float32) + +prompt = "Rene Descartes was" + +for text in model.generate( + prompt, + max_tokens=500, + eval_every_n=5, + verbose=True, + top_p=0.99, + temperature=0.85, +): + print(text, end="", flush=True) +`, +]; + +export const edsnlp = (model: ModelData): string[] => { + const packageName = nameWithoutNamespace(model.id).replaceAll("-", "_"); + return [ + `# Load it from the Hub directly +import edsnlp +nlp = edsnlp.load("${model.id}") +`, + `# Or install it as a package +!pip install git+https://huggingface.co/${model.id} + +# and import it as a module +import ${packageName} + +nlp = ${packageName}.load() # or edsnlp.load("${packageName}") +`, + ]; +}; + +export const espnetTTS = (model: ModelData): string[] => [ + `from espnet2.bin.tts_inference import Text2Speech + +model = Text2Speech.from_pretrained("${model.id}") + +speech, *_ = model("text to generate speech from")`, +]; + +export const espnetASR = (model: ModelData): string[] => [ + `from espnet2.bin.asr_inference import Speech2Text + +model = Speech2Text.from_pretrained( + "${model.id}" +) + +speech, rate = soundfile.read("speech.wav") +text, *_ = model(speech)[0]`, +]; + +const espnetUnknown = () => [`unknown model type (must be text-to-speech or automatic-speech-recognition)`]; + +export const espnet = (model: ModelData): string[] => { + if (model.tags.includes("text-to-speech")) { + return espnetTTS(model); + } else if (model.tags.includes("automatic-speech-recognition")) { + return espnetASR(model); + } + return espnetUnknown(); +}; + +export const fairseq = (model: ModelData): string[] => [ + `from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub + +models, cfg, task = load_model_ensemble_and_task_from_hf_hub( + "${model.id}" +)`, +]; + +export const flair = (model: ModelData): string[] => [ + `from flair.models import SequenceTagger + +tagger = SequenceTagger.load("${model.id}")`, +]; + +export const gliner = (model: ModelData): string[] => [ + `from gliner import GLiNER + +model = GLiNER.from_pretrained("${model.id}")`, +]; + +export const gliner2 = (model: ModelData): string[] => [ + `from gliner2 import GLiNER2 + +model = GLiNER2.from_pretrained("${model.id}") + +# Extract entities +text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." +result = extractor.extract_entities(text, ["company", "person", "product", "location"]) + +print(result)`, +]; + +export const indextts = (model: ModelData): string[] => [ + `# Download model +from huggingface_hub import snapshot_download + +snapshot_download(${model.id}, local_dir="checkpoints") + +from indextts.infer import IndexTTS + +# Ensure config.yaml is present in the checkpoints directory +tts = IndexTTS(model_dir="checkpoints", cfg_path="checkpoints/config.yaml") + +voice = "path/to/your/reference_voice.wav" # Path to the voice reference audio file +text = "Hello, how are you?" +output_path = "output_index.wav" + +tts.infer(voice, text, output_path)`, +]; + +export const htrflow = (model: ModelData): string[] => [ + `# CLI usage +# see docs: https://ai-riksarkivet.github.io/htrflow/latest/getting_started/quick_start.html +htrflow pipeline `, + `# Python usage +from htrflow.pipeline.pipeline import Pipeline +from htrflow.pipeline.steps import Task +from htrflow.models.framework.model import ModelClass + +pipeline = Pipeline( + [ + Task( + ModelClass, {"model": "${model.id}"}, {} + ), + ])`, +]; + +export const keras = (model: ModelData): string[] => [ + `# Available backend options are: "jax", "torch", "tensorflow". +import os +os.environ["KERAS_BACKEND"] = "jax" + +import keras + +model = keras.saving.load_model("hf://${model.id}") +`, +]; + +const _keras_hub_causal_lm = (modelId: string): string => ` +import keras_hub + +# Load CausalLM model (optional: use half precision for inference) +causal_lm = keras_hub.models.CausalLM.from_preset("hf://${modelId}", dtype="bfloat16") +causal_lm.compile(sampler="greedy") # (optional) specify a sampler + +# Generate text +causal_lm.generate("Keras: deep learning for", max_length=64) +`; + +const _keras_hub_text_to_image = (modelId: string): string => ` +import keras_hub + +# Load TextToImage model (optional: use half precision for inference) +text_to_image = keras_hub.models.TextToImage.from_preset("hf://${modelId}", dtype="bfloat16") + +# Generate images with a TextToImage model. +text_to_image.generate("Astronaut in a jungle") +`; + +const _keras_hub_text_classifier = (modelId: string): string => ` +import keras_hub + +# Load TextClassifier model +text_classifier = keras_hub.models.TextClassifier.from_preset( + "hf://${modelId}", + num_classes=2, +) +# Fine-tune +text_classifier.fit(x=["Thilling adventure!", "Total snoozefest."], y=[1, 0]) +# Classify text +text_classifier.predict(["Not my cup of tea."]) +`; + +const _keras_hub_image_classifier = (modelId: string): string => ` +import keras_hub +import keras + +# Load ImageClassifier model +image_classifier = keras_hub.models.ImageClassifier.from_preset( + "hf://${modelId}", + num_classes=2, +) +# Fine-tune +image_classifier.fit( + x=keras.random.randint((32, 64, 64, 3), 0, 256), + y=keras.random.randint((32, 1), 0, 2), +) +# Classify image +image_classifier.predict(keras.random.randint((1, 64, 64, 3), 0, 256)) +`; + +const _keras_hub_tasks_with_example = { + CausalLM: _keras_hub_causal_lm, + TextToImage: _keras_hub_text_to_image, + TextClassifier: _keras_hub_text_classifier, + ImageClassifier: _keras_hub_image_classifier, +}; + +const _keras_hub_task_without_example = (task: string, modelId: string): string => ` +import keras_hub + +# Create a ${task} model +task = keras_hub.models.${task}.from_preset("hf://${modelId}") +`; + +const _keras_hub_generic_backbone = (modelId: string): string => ` +import keras_hub + +# Create a Backbone model unspecialized for any task +backbone = keras_hub.models.Backbone.from_preset("hf://${modelId}") +`; + +export const keras_hub = (model: ModelData): string[] => { + const modelId = model.id; + const tasks = model.config?.keras_hub?.tasks ?? []; + + const snippets: string[] = []; + + // First, generate tasks with examples + for (const [task, snippet] of Object.entries(_keras_hub_tasks_with_example)) { + if (tasks.includes(task)) { + snippets.push(snippet(modelId)); + } + } + // Then, add remaining tasks + for (const task of tasks) { + if (!Object.keys(_keras_hub_tasks_with_example).includes(task)) { + snippets.push(_keras_hub_task_without_example(task, modelId)); + } + } + // Finally, add generic backbone snippet + snippets.push(_keras_hub_generic_backbone(modelId)); + + return snippets; +}; + +export const kernels = (model: ModelData): string[] => [ + `# !pip install kernels + +from kernels import get_kernel + +kernel = get_kernel("${model.id}")`, +]; + +export const kimi_audio = (model: ModelData): string[] => [ + `# Example usage for KimiAudio +# pip install git+https://github.com/MoonshotAI/Kimi-Audio.git + +from kimia_infer.api.kimia import KimiAudio + +model = KimiAudio(model_path="${model.id}", load_detokenizer=True) + +sampling_params = { + "audio_temperature": 0.8, + "audio_top_k": 10, + "text_temperature": 0.0, + "text_top_k": 5, +} + +# For ASR +asr_audio = "asr_example.wav" +messages_asr = [ + {"role": "user", "message_type": "text", "content": "Please transcribe the following audio:"}, + {"role": "user", "message_type": "audio", "content": asr_audio} +] +_, text = model.generate(messages_asr, **sampling_params, output_type="text") +print(text) + +# For Q&A +qa_audio = "qa_example.wav" +messages_conv = [{"role": "user", "message_type": "audio", "content": qa_audio}] +wav, text = model.generate(messages_conv, **sampling_params, output_type="both") +sf.write("output_audio.wav", wav.cpu().view(-1).numpy(), 24000) +print(text) +`, +]; + +export const kittentts = (model: ModelData): string[] => [ + `from kittentts import KittenTTS +m = KittenTTS("${model.id}") + +audio = m.generate("This high quality TTS model works without a GPU") + +# Save the audio +import soundfile as sf +sf.write('output.wav', audio, 24000)`, +]; + +export const lightning_ir = (model: ModelData): string[] => { + if (model.tags.includes("bi-encoder")) { + return [ + `#install from https://github.com/webis-de/lightning-ir + +from lightning_ir import BiEncoderModule +model = BiEncoderModule("${model.id}") + +model.score("query", ["doc1", "doc2", "doc3"])`, + ]; + } else if (model.tags.includes("cross-encoder")) { + return [ + `#install from https://github.com/webis-de/lightning-ir + +from lightning_ir import CrossEncoderModule +model = CrossEncoderModule("${model.id}") + +model.score("query", ["doc1", "doc2", "doc3"])`, + ]; + } + return [ + `#install from https://github.com/webis-de/lightning-ir + +from lightning_ir import BiEncoderModule, CrossEncoderModule + +# depending on the model type, use either BiEncoderModule or CrossEncoderModule +model = BiEncoderModule("${model.id}") +# model = CrossEncoderModule("${model.id}") + +model.score("query", ["doc1", "doc2", "doc3"])`, + ]; +}; + +export const llama_cpp_python = (model: ModelData): string[] => { + const snippets = [ + `# !pip install llama-cpp-python + +from llama_cpp import Llama + +llm = Llama.from_pretrained( + repo_id="${model.id}", + filename="{{GGUF_FILE}}", +) +`, + ]; + + if (model.tags.includes("conversational")) { + const messages = getModelInputSnippet(model) as ChatCompletionInputMessage[]; + snippets.push(`llm.create_chat_completion( + messages = ${stringifyMessages(messages, { attributeKeyQuotes: true, indent: "\t" })} +)`); + } else { + snippets.push(`output = llm( + "Once upon a time,", + max_tokens=512, + echo=True +) +print(output)`); + } + + return snippets; +}; + +export const lerobot = (model: ModelData): string[] => { + if (model.tags.includes("smolvla")) { + const smolvlaSnippets = [ + // Installation snippet + `# See https://github.com/huggingface/lerobot?tab=readme-ov-file#installation for more details +git clone https://github.com/huggingface/lerobot.git +cd lerobot +pip install -e .[smolvla]`, + // Finetune snippet + `# Launch finetuning on your dataset +python lerobot/scripts/train.py \\ +--policy.path=${model.id} \\ +--dataset.repo_id=lerobot/svla_so101_pickplace \\ +--batch_size=64 \\ +--steps=20000 \\ +--output_dir=outputs/train/my_smolvla \\ +--job_name=my_smolvla_training \\ +--policy.device=cuda \\ +--wandb.enable=true`, + ]; + if (model.id !== "lerobot/smolvla_base") { + // Inference snippet (only if not base model) + smolvlaSnippets.push( + `# Run the policy using the record function +python -m lerobot.record \\ + --robot.type=so101_follower \\ + --robot.port=/dev/ttyACM0 \\ # <- Use your port + --robot.id=my_blue_follower_arm \\ # <- Use your robot id + --robot.cameras="{ front: {type: opencv, index_or_path: 8, width: 640, height: 480, fps: 30}}" \\ # <- Use your cameras + --dataset.single_task="Grasp a lego block and put it in the bin." \\ # <- Use the same task description you used in your dataset recording + --dataset.repo_id=HF_USER/dataset_name \\ # <- This will be the dataset name on HF Hub + --dataset.episode_time_s=50 \\ + --dataset.num_episodes=10 \\ + --policy.path=${model.id}`, + ); + } + return smolvlaSnippets; + } + return []; +}; + +export const tf_keras = (model: ModelData): string[] => [ + `# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy) +# See https://github.com/keras-team/tf-keras for more details. +from huggingface_hub import from_pretrained_keras + +model = from_pretrained_keras("${model.id}") +`, +]; + +export const mamba_ssm = (model: ModelData): string[] => [ + `from mamba_ssm import MambaLMHeadModel + +model = MambaLMHeadModel.from_pretrained("${model.id}")`, +]; + +export const mars5_tts = (model: ModelData): string[] => [ + `# Install from https://github.com/Camb-ai/MARS5-TTS + +from inference import Mars5TTS +mars5 = Mars5TTS.from_pretrained("${model.id}")`, +]; + +export const matanyone = (model: ModelData): string[] => [ + `# Install from https://github.com/pq-yang/MatAnyone.git + +from matanyone.model.matanyone import MatAnyone +model = MatAnyone.from_pretrained("${model.id}")`, + ` +from matanyone import InferenceCore +processor = InferenceCore("${model.id}")`, +]; + +export const mesh_anything = (): string[] => [ + `# Install from https://github.com/buaacyw/MeshAnything.git + +from MeshAnything.models.meshanything import MeshAnything + +# refer to https://github.com/buaacyw/MeshAnything/blob/main/main.py#L91 on how to define args +# and https://github.com/buaacyw/MeshAnything/blob/main/app.py regarding usage +model = MeshAnything(args)`, +]; + +export const open_clip = (model: ModelData): string[] => [ + `import open_clip + +model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:${model.id}') +tokenizer = open_clip.get_tokenizer('hf-hub:${model.id}')`, +]; + +export const paddlenlp = (model: ModelData): string[] => { + if (model.config?.architectures?.[0]) { + const architecture = model.config.architectures[0]; + return [ + [ + `from paddlenlp.transformers import AutoTokenizer, ${architecture}`, + "", + `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`, + `model = ${architecture}.from_pretrained("${model.id}", from_hf_hub=True)`, + ].join("\n"), + ]; + } else { + return [ + [ + `# ⚠️ Type of model unknown`, + `from paddlenlp.transformers import AutoTokenizer, AutoModel`, + "", + `tokenizer = AutoTokenizer.from_pretrained("${model.id}", from_hf_hub=True)`, + `model = AutoModel.from_pretrained("${model.id}", from_hf_hub=True)`, + ].join("\n"), + ]; + } +}; + +export const paddleocr = (model: ModelData): string[] => { + const mapping: Record = { + textline_detection: { className: "TextDetection" }, + textline_recognition: { className: "TextRecognition" }, + seal_text_detection: { className: "SealTextDetection" }, + doc_img_unwarping: { className: "TextImageUnwarping" }, + doc_img_orientation_classification: { className: "DocImgOrientationClassification" }, + textline_orientation_classification: { className: "TextLineOrientationClassification" }, + chart_parsing: { className: "ChartParsing" }, + formula_recognition: { className: "FormulaRecognition" }, + layout_detection: { className: "LayoutDetection" }, + table_cells_detection: { className: "TableCellsDetection" }, + wired_table_classification: { className: "TableClassification" }, + table_structure_recognition: { className: "TableStructureRecognition" }, + }; + + if (model.tags.includes("doc_vlm")) { + return [ + `# 1. See https://www.paddlepaddle.org.cn/en/install to install paddlepaddle +# 2. pip install paddleocr + +from paddleocr import DocVLM +model = DocVLM(model_name="${nameWithoutNamespace(model.id)}") +output = model.predict( + input={"image": "path/to/image.png", "query": "Parsing this image and output the content in Markdown format."}, + batch_size=1 +) +for res in output: + res.print() + res.save_to_json(save_path="./output/res.json")`, + ]; + } + + if (model.tags.includes("document-parse")) { + const rawVersion = model.id.replace("PaddlePaddle/PaddleOCR-VL-", "v"); + const version = rawVersion === "PaddlePaddle/PaddleOCR-VL" ? "v1" : rawVersion; + return [ + `# See https://www.paddleocr.ai/latest/version3.x/pipeline_usage/PaddleOCR-VL.html to installation + +from paddleocr import PaddleOCRVL +pipeline = PaddleOCRVL(pipeline_version="${version}") +output = pipeline.predict("path/to/document_image.png") +for res in output: + res.print() + res.save_to_json(save_path="output") + res.save_to_markdown(save_path="output")`, + ]; + } + + for (const tag of model.tags) { + if (tag in mapping) { + const { className } = mapping[tag]; + return [ + `# 1. See https://www.paddlepaddle.org.cn/en/install to install paddlepaddle +# 2. pip install paddleocr + +from paddleocr import ${className} +model = ${className}(model_name="${nameWithoutNamespace(model.id)}") +output = model.predict(input="path/to/image.png", batch_size=1) +for res in output: + res.print() + res.save_to_img(save_path="./output/") + res.save_to_json(save_path="./output/res.json")`, + ]; + } + } + + return [ + `# Please refer to the document for information on how to use the model. +# https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/module_usage/module_overview.html`, + ]; +}; + +export const perception_encoder = (model: ModelData): string[] => { + const clip_model = `# Use PE-Core models as CLIP models +import core.vision_encoder.pe as pe + +model = pe.CLIP.from_config("${model.id}", pretrained=True)`; + + const vision_encoder = `# Use any PE model as a vision encoder +import core.vision_encoder.pe as pe + +model = pe.VisionTransformer.from_config("${model.id}", pretrained=True)`; + + if (model.id.includes("Core")) { + return [clip_model, vision_encoder]; + } else { + return [vision_encoder]; + } +}; +export const phantom_wan = (model: ModelData): string[] => [ + `from huggingface_hub import snapshot_download +from phantom_wan import WANI2V, configs + +checkpoint_dir = snapshot_download("${model.id}") +wan_i2v = WanI2V( + config=configs.WAN_CONFIGS['i2v-14B'], + checkpoint_dir=checkpoint_dir, + ) + video = wan_i2v.generate(text_prompt, image_prompt)`, +]; + +export const pocket_tts = (model: ModelData): string[] => [ + `from pocket_tts import TTSModel +import scipy.io.wavfile + +tts_model = TTSModel.load_model("${model.id}") +voice_state = tts_model.get_state_for_audio_prompt( + "hf://kyutai/tts-voices/alba-mackenna/casual.wav" +) +audio = tts_model.generate_audio(voice_state, "Hello world, this is a test.") +# Audio is a 1D torch tensor containing PCM data. +scipy.io.wavfile.write("output.wav", tts_model.sample_rate, audio.numpy())`, +]; + +export const pyannote_audio_pipeline = (model: ModelData): string[] => [ + `from pyannote.audio import Pipeline + +pipeline = Pipeline.from_pretrained("${model.id}") + +# inference on the whole file +pipeline("file.wav") + +# inference on an excerpt +from pyannote.core import Segment +excerpt = Segment(start=2.0, end=5.0) + +from pyannote.audio import Audio +waveform, sample_rate = Audio().crop("file.wav", excerpt) +pipeline({"waveform": waveform, "sample_rate": sample_rate})`, +]; + +const pyannote_audio_model = (model: ModelData): string[] => [ + `from pyannote.audio import Model, Inference + +model = Model.from_pretrained("${model.id}") +inference = Inference(model) + +# inference on the whole file +inference("file.wav") + +# inference on an excerpt +from pyannote.core import Segment +excerpt = Segment(start=2.0, end=5.0) +inference.crop("file.wav", excerpt)`, +]; + +export const pyannote_audio = (model: ModelData): string[] => { + if (model.tags.includes("pyannote-audio-pipeline")) { + return pyannote_audio_pipeline(model); + } + return pyannote_audio_model(model); +}; + +export const relik = (model: ModelData): string[] => [ + `from relik import Relik + +relik = Relik.from_pretrained("${model.id}")`, +]; + +export const renderformer = (model: ModelData): string[] => [ + `# Install from https://github.com/microsoft/renderformer + +from renderformer import RenderFormerRenderingPipeline +pipeline = RenderFormerRenderingPipeline.from_pretrained("${model.id}")`, +]; + +const tensorflowttsTextToMel = (model: ModelData): string[] => [ + `from tensorflow_tts.inference import AutoProcessor, TFAutoModel + +processor = AutoProcessor.from_pretrained("${model.id}") +model = TFAutoModel.from_pretrained("${model.id}") +`, +]; + +const tensorflowttsMelToWav = (model: ModelData): string[] => [ + `from tensorflow_tts.inference import TFAutoModel + +model = TFAutoModel.from_pretrained("${model.id}") +audios = model.inference(mels) +`, +]; + +const tensorflowttsUnknown = (model: ModelData): string[] => [ + `from tensorflow_tts.inference import TFAutoModel + +model = TFAutoModel.from_pretrained("${model.id}") +`, +]; + +export const tensorflowtts = (model: ModelData): string[] => { + if (model.tags.includes("text-to-mel")) { + return tensorflowttsTextToMel(model); + } else if (model.tags.includes("mel-to-wav")) { + return tensorflowttsMelToWav(model); + } + return tensorflowttsUnknown(model); +}; + +export const timm = (model: ModelData): string[] => [ + `import timm + +model = timm.create_model("hf_hub:${model.id}", pretrained=True)`, +]; + +export const saelens = (/* model: ModelData */): string[] => [ + `# pip install sae-lens +from sae_lens import SAE + +sae, cfg_dict, sparsity = SAE.from_pretrained( + release = "RELEASE_ID", # e.g., "gpt2-small-res-jb". See other options in https://github.com/jbloomAus/SAELens/blob/main/sae_lens/pretrained_saes.yaml + sae_id = "SAE_ID", # e.g., "blocks.8.hook_resid_pre". Won't always be a hook point +)`, +]; + +export const seed_story = (): string[] => [ + `# seed_story_cfg_path refers to 'https://github.com/TencentARC/SEED-Story/blob/master/configs/clm_models/agent_7b_sft.yaml' +# llm_cfg_path refers to 'https://github.com/TencentARC/SEED-Story/blob/master/configs/clm_models/llama2chat7b_lora.yaml' +from omegaconf import OmegaConf +import hydra + +# load Llama2 +llm_cfg = OmegaConf.load(llm_cfg_path) +llm = hydra.utils.instantiate(llm_cfg, torch_dtype="fp16") + +# initialize seed_story +seed_story_cfg = OmegaConf.load(seed_story_cfg_path) +seed_story = hydra.utils.instantiate(seed_story_cfg, llm=llm) `, +]; + +const skopsPickle = (model: ModelData, modelFile: string) => { + return [ + `import joblib +from skops.hub_utils import download +download("${model.id}", "path_to_folder") +model = joblib.load( + "${modelFile}" +) +# only load pickle files from sources you trust +# read more about it here https://skops.readthedocs.io/en/stable/persistence.html`, + ]; +}; + +const skopsFormat = (model: ModelData, modelFile: string) => { + return [ + `from skops.hub_utils import download +from skops.io import load +download("${model.id}", "path_to_folder") +# make sure model file is in skops format +# if model is a pickle file, make sure it's from a source you trust +model = load("path_to_folder/${modelFile}")`, + ]; +}; + +const skopsJobLib = (model: ModelData) => { + return [ + `from huggingface_hub import hf_hub_download +import joblib +model = joblib.load( + hf_hub_download("${model.id}", "sklearn_model.joblib") +) +# only load pickle files from sources you trust +# read more about it here https://skops.readthedocs.io/en/stable/persistence.html`, + ]; +}; + +export const sklearn = (model: ModelData): string[] => { + if (model.tags.includes("skops")) { + const skopsmodelFile = model.config?.sklearn?.model?.file; + const skopssaveFormat = model.config?.sklearn?.model_format; + if (!skopsmodelFile) { + return [`# ⚠️ Model filename not specified in config.json`]; + } + if (skopssaveFormat === "pickle") { + return skopsPickle(model, skopsmodelFile); + } else { + return skopsFormat(model, skopsmodelFile); + } + } else { + return skopsJobLib(model); + } +}; + +export const stable_audio_tools = (model: ModelData): string[] => [ + `import torch +import torchaudio +from einops import rearrange +from stable_audio_tools import get_pretrained_model +from stable_audio_tools.inference.generation import generate_diffusion_cond + +device = "cuda" if torch.cuda.is_available() else "cpu" + +# Download model +model, model_config = get_pretrained_model("${model.id}") +sample_rate = model_config["sample_rate"] +sample_size = model_config["sample_size"] + +model = model.to(device) + +# Set up text and timing conditioning +conditioning = [{ + "prompt": "128 BPM tech house drum loop", +}] + +# Generate stereo audio +output = generate_diffusion_cond( + model, + conditioning=conditioning, + sample_size=sample_size, + device=device +) + +# Rearrange audio batch to a single sequence +output = rearrange(output, "b d n -> d (b n)") + +# Peak normalize, clip, convert to int16, and save to file +output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu() +torchaudio.save("output.wav", output, sample_rate)`, +]; + +export const fastai = (model: ModelData): string[] => [ + `from huggingface_hub import from_pretrained_fastai + +learn = from_pretrained_fastai("${model.id}")`, +]; + +export const sam2 = (model: ModelData): string[] => { + const image_predictor = `# Use SAM2 with images +import torch +from sam2.sam2_image_predictor import SAM2ImagePredictor + +predictor = SAM2ImagePredictor.from_pretrained(${model.id}) + +with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): + predictor.set_image() + masks, _, _ = predictor.predict()`; + + const video_predictor = `# Use SAM2 with videos +import torch +from sam2.sam2_video_predictor import SAM2VideoPredictor + +predictor = SAM2VideoPredictor.from_pretrained(${model.id}) + +with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): + state = predictor.init_state() + + # add new prompts and instantly get the output on the same frame + frame_idx, object_ids, masks = predictor.add_new_points(state, ): + + # propagate the prompts to get masklets throughout the video + for frame_idx, object_ids, masks in predictor.propagate_in_video(state): + ...`; + return [image_predictor, video_predictor]; +}; + +export const sam_3d_objects = (model: ModelData): string[] => [ + `from inference import Inference, load_image, load_single_mask +from huggingface_hub import hf_hub_download + +path = hf_hub_download("${model.id}", "pipeline.yaml") +inference = Inference(path, compile=False) + +image = load_image("path_to_image.png") +mask = load_single_mask("path_to_mask.png", index=14) + +output = inference(image, mask)`, +]; + +export const sam_3d_body = (model: ModelData): string[] => [ + `from notebook.utils import setup_sam_3d_body + +estimator = setup_sam_3d_body(${model.id}) +outputs = estimator.process_one_image(image) +rend_img = visualize_sample_together(image, outputs, estimator.faces)`, +]; + +export const sampleFactory = (model: ModelData): string[] => [ + `python -m sample_factory.huggingface.load_from_hub -r ${model.id} -d ./train_dir`, +]; + +function get_widget_examples_from_st_model(model: ModelData): string[] | undefined { + const widgetExample = model.widgetData?.[0] as WidgetExampleSentenceSimilarityInput | undefined; + if (widgetExample?.source_sentence && widgetExample?.sentences?.length) { + return [widgetExample.source_sentence, ...widgetExample.sentences]; + } +} + +export const sentenceTransformers = (model: ModelData): string[] => { + const remote_code_snippet = model.tags.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : ""; + + if (model.tags.includes("PyLate")) { + return [ + `from pylate import models + +queries = [ + "Which planet is known as the Red Planet?", + "What is the largest planet in our solar system?", +] + +documents = [ + ["Mars is the Red Planet.", "Venus is Earth's twin."], + ["Jupiter is the largest planet.", "Saturn has rings."], +] + +model = models.ColBERT(model_name_or_path="${model.id}") + +queries_emb = model.encode(queries, is_query=True) +docs_emb = model.encode(documents, is_query=False)`, + ]; + } + + if (model.tags.includes("cross-encoder") || model.pipeline_tag == "text-ranking") { + return [ + `from sentence_transformers import CrossEncoder + +model = CrossEncoder("${model.id}"${remote_code_snippet}) + +query = "Which planet is known as the Red Planet?" +passages = [ + "Venus is often called Earth's twin because of its similar size and proximity.", + "Mars, known for its reddish appearance, is often referred to as the Red Planet.", + "Jupiter, the largest planet in our solar system, has a prominent red spot.", + "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." +] + +scores = model.predict([(query, passage) for passage in passages]) +print(scores)`, + ]; + } + + const exampleSentences = get_widget_examples_from_st_model(model) ?? [ + "The weather is lovely today.", + "It's so sunny outside!", + "He drove to the stadium.", + ]; + + return [ + `from sentence_transformers import SentenceTransformer + +model = SentenceTransformer("${model.id}"${remote_code_snippet}) + +sentences = ${JSON.stringify(exampleSentences, null, 4)} +embeddings = model.encode(sentences) + +similarities = model.similarity(embeddings, embeddings) +print(similarities.shape) +# [${exampleSentences.length}, ${exampleSentences.length}]`, + ]; +}; + +export const setfit = (model: ModelData): string[] => [ + `from setfit import SetFitModel + +model = SetFitModel.from_pretrained("${model.id}")`, +]; + +export const spacy = (model: ModelData): string[] => [ + `!pip install https://huggingface.co/${model.id}/resolve/main/${nameWithoutNamespace(model.id)}-any-py3-none-any.whl + +# Using spacy.load(). +import spacy +nlp = spacy.load("${nameWithoutNamespace(model.id)}") + +# Importing as module. +import ${nameWithoutNamespace(model.id)} +nlp = ${nameWithoutNamespace(model.id)}.load()`, +]; + +export const span_marker = (model: ModelData): string[] => [ + `from span_marker import SpanMarkerModel + +model = SpanMarkerModel.from_pretrained("${model.id}")`, +]; + +export const stanza = (model: ModelData): string[] => [ + `import stanza + +stanza.download("${nameWithoutNamespace(model.id).replace("stanza-", "")}") +nlp = stanza.Pipeline("${nameWithoutNamespace(model.id).replace("stanza-", "")}")`, +]; + +const speechBrainMethod = (speechbrainInterface: string) => { + switch (speechbrainInterface) { + case "EncoderClassifier": + return "classify_file"; + case "EncoderDecoderASR": + case "EncoderASR": + return "transcribe_file"; + case "SpectralMaskEnhancement": + return "enhance_file"; + case "SepformerSeparation": + return "separate_file"; + default: + return undefined; + } +}; + +export const speechbrain = (model: ModelData): string[] => { + const speechbrainInterface = model.config?.speechbrain?.speechbrain_interface; + if (speechbrainInterface === undefined) { + return [`# interface not specified in config.json`]; + } + + const speechbrainMethod = speechBrainMethod(speechbrainInterface); + if (speechbrainMethod === undefined) { + return [`# interface in config.json invalid`]; + } + + return [ + `from speechbrain.pretrained import ${speechbrainInterface} +model = ${speechbrainInterface}.from_hparams( + "${model.id}" +) +model.${speechbrainMethod}("file.wav")`, + ]; +}; + +export const terratorch = (model: ModelData): string[] => [ + `from terratorch.registry import BACKBONE_REGISTRY + +model = BACKBONE_REGISTRY.build("${model.id}")`, +]; + +const hasChatTemplate = (model: ModelData): boolean => + model.config?.tokenizer_config?.chat_template !== undefined || + model.config?.processor_config?.chat_template !== undefined || + model.config?.chat_template_jinja !== undefined; + +export const transformers = (model: ModelData): string[] => { + const info = model.transformersInfo; + if (!info) { + return [`# ⚠️ Type of model unknown`]; + } + const remote_code_snippet = model.tags.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : ""; + + const autoSnippet = []; + if (info.processor) { + const processorVarName = + info.processor === "AutoTokenizer" + ? "tokenizer" + : info.processor === "AutoFeatureExtractor" + ? "extractor" + : "processor"; + autoSnippet.push( + "# Load model directly", + `from transformers import ${info.processor}, ${info.auto_model}`, + "", + `${processorVarName} = ${info.processor}.from_pretrained("${model.id}"` + remote_code_snippet + ")", + `model = ${info.auto_model}.from_pretrained("${model.id}"` + remote_code_snippet + ")", + ); + if (model.tags.includes("conversational") && hasChatTemplate(model)) { + if (model.tags.includes("image-text-to-text")) { + autoSnippet.push( + "messages = [", + [ + " {", + ' "role": "user",', + ' "content": [', + ' {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},', + ' {"type": "text", "text": "What animal is on the candy?"}', + " ]", + " },", + ].join("\n"), + "]", + ); + } else { + autoSnippet.push("messages = [", ' {"role": "user", "content": "Who are you?"},', "]"); + } + autoSnippet.push( + `inputs = ${processorVarName}.apply_chat_template(`, + " messages,", + " add_generation_prompt=True,", + " tokenize=True,", + " return_dict=True,", + ' return_tensors="pt",', + ").to(model.device)", + "", + "outputs = model.generate(**inputs, max_new_tokens=40)", + `print(${processorVarName}.decode(outputs[0][inputs["input_ids"].shape[-1]:]))`, + ); + } + } else { + autoSnippet.push( + "# Load model directly", + `from transformers import ${info.auto_model}`, + `model = ${info.auto_model}.from_pretrained("${model.id}"` + remote_code_snippet + ', dtype="auto")', + ); + } + + if (model.pipeline_tag && LIBRARY_TASK_MAPPING.transformers?.includes(model.pipeline_tag)) { + const pipelineSnippet = ["# Use a pipeline as a high-level helper"]; + if (REMOVED_IN_V5_TRANSFORMERS_PIPELINES.includes(model.pipeline_tag)) { + pipelineSnippet.push( + `# Warning: Pipeline type "${model.pipeline_tag}" is no longer supported in transformers v5.`, + `# You must load the model directly (see below) or downgrade to v4.x with:`, + `# 'pip install "transformers<5.0.0'`, + ); + } + + pipelineSnippet.push( + "from transformers import pipeline", + "", + `pipe = pipeline("${model.pipeline_tag}", model="${model.id}"` + remote_code_snippet + ")", + ); + + if (model.tags.includes("conversational")) { + if (model.tags.includes("image-text-to-text")) { + pipelineSnippet.push( + "messages = [", + [ + " {", + ' "role": "user",', + ' "content": [', + ' {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},', + ' {"type": "text", "text": "What animal is on the candy?"}', + " ]", + " },", + ].join("\n"), + "]", + ); + pipelineSnippet.push("pipe(text=messages)"); + } else { + pipelineSnippet.push("messages = [", ' {"role": "user", "content": "Who are you?"},', "]"); + pipelineSnippet.push("pipe(messages)"); + } + } else if (model.pipeline_tag === "zero-shot-image-classification") { + pipelineSnippet.push( + "pipe(", + ' "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png",', + ' candidate_labels=["animals", "humans", "landscape"],', + ")", + ); + } else if (model.pipeline_tag === "image-classification") { + pipelineSnippet.push( + 'pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")', + ); + } + + return [pipelineSnippet.join("\n"), autoSnippet.join("\n")]; + } + return [autoSnippet.join("\n")]; +}; + +export const transformersJS = (model: ModelData): string[] => { + if (!model.pipeline_tag) { + return [`// ⚠️ Unknown pipeline tag`]; + } + + const libName = "@huggingface/transformers"; + + return [ + `// npm i ${libName} +import { pipeline } from '${libName}'; + +// Allocate pipeline +const pipe = await pipeline('${model.pipeline_tag}', '${model.id}');`, + ]; +}; + +const peftTask = (peftTaskType?: string) => { + switch (peftTaskType) { + case "CAUSAL_LM": + return "CausalLM"; + case "SEQ_2_SEQ_LM": + return "Seq2SeqLM"; + case "TOKEN_CLS": + return "TokenClassification"; + case "SEQ_CLS": + return "SequenceClassification"; + default: + return undefined; + } +}; + +export const peft = (model: ModelData): string[] => { + const { base_model_name_or_path: peftBaseModel, task_type: peftTaskType } = model.config?.peft ?? {}; + const pefttask = peftTask(peftTaskType); + if (!pefttask) { + return [`Task type is invalid.`]; + } + if (!peftBaseModel) { + return [`Base model is not found.`]; + } + + return [ + `from peft import PeftModel +from transformers import AutoModelFor${pefttask} + +base_model = AutoModelFor${pefttask}.from_pretrained("${peftBaseModel}") +model = PeftModel.from_pretrained(base_model, "${model.id}")`, + ]; +}; + +export const fasttext = (model: ModelData): string[] => [ + `from huggingface_hub import hf_hub_download +import fasttext + +model = fasttext.load_model(hf_hub_download("${model.id}", "model.bin"))`, +]; + +export const stableBaselines3 = (model: ModelData): string[] => [ + `from huggingface_sb3 import load_from_hub +checkpoint = load_from_hub( + repo_id="${model.id}", + filename="{MODEL FILENAME}.zip", +)`, +]; + +const nemoDomainResolver = (domain: string, model: ModelData): string[] | undefined => { + switch (domain) { + case "ASR": + return [ + `import nemo.collections.asr as nemo_asr +asr_model = nemo_asr.models.ASRModel.from_pretrained("${model.id}") + +transcriptions = asr_model.transcribe(["file.wav"])`, + ]; + default: + return undefined; + } +}; + +export const mlAgents = (model: ModelData): string[] => [ + `mlagents-load-from-hf --repo-id="${model.id}" --local-dir="./download: string[]s"`, +]; + +export const sentis = (/* model: ModelData */): string[] => [ + `string modelName = "[Your model name here].sentis"; +Model model = ModelLoader.Load(Application.streamingAssetsPath + "/" + modelName); +IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); +// Please see provided C# file for more details +`, +]; + +export const sana = (model: ModelData): string[] => [ + ` +# Load the model and infer image from text +import torch +from app.sana_pipeline import SanaPipeline +from torchvision.utils import save_image + +sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml") +sana.from_pretrained("hf://${model.id}") + +image = sana( + prompt='a cyberpunk cat with a neon sign that says "Sana"', + height=1024, + width=1024, + guidance_scale=5.0, + pag_guidance_scale=2.0, + num_inference_steps=18, +) `, +]; + +export const vibevoice = (model: ModelData): string[] => [ + `import torch, soundfile as sf, librosa, numpy as np +from vibevoice.processor.vibevoice_processor import VibeVoiceProcessor +from vibevoice.modular.modeling_vibevoice_inference import VibeVoiceForConditionalGenerationInference + +# Load voice sample (should be 24kHz mono) +voice, sr = sf.read("path/to/voice_sample.wav") +if voice.ndim > 1: voice = voice.mean(axis=1) +if sr != 24000: voice = librosa.resample(voice, sr, 24000) + +processor = VibeVoiceProcessor.from_pretrained("${model.id}") +model = VibeVoiceForConditionalGenerationInference.from_pretrained( + "${model.id}", torch_dtype=torch.bfloat16 +).to("cuda").eval() +model.set_ddpm_inference_steps(5) + +inputs = processor(text=["Speaker 0: Hello!\\nSpeaker 1: Hi there!"], + voice_samples=[[voice]], return_tensors="pt") +audio = model.generate(**inputs, cfg_scale=1.3, + tokenizer=processor.tokenizer).speech_outputs[0] +sf.write("output.wav", audio.cpu().numpy().squeeze(), 24000)`, +]; + +export const videoprism = (model: ModelData): string[] => [ + `# Install from https://github.com/google-deepmind/videoprism +import jax +from videoprism import models as vp + +flax_model = vp.get_model("${model.id}") +loaded_state = vp.load_pretrained_weights("${model.id}") + +@jax.jit +def forward_fn(inputs, train=False): + return flax_model.apply(loaded_state, inputs, train=train)`, +]; + +export const vfimamba = (model: ModelData): string[] => [ + `from Trainer_finetune import Model + +model = Model.from_pretrained("${model.id}")`, +]; + +export const lvface = (model: ModelData): string[] => [ + `from huggingface_hub import hf_hub_download + from inference_onnx import LVFaceONNXInferencer + +model_path = hf_hub_download("${model.id}", "LVFace-L_Glint360K/LVFace-L_Glint360K.onnx") +inferencer = LVFaceONNXInferencer(model_path, use_gpu=True, timeout=300) +img_path = 'path/to/image1.jpg' +embedding = inferencer.infer_from_image(img_path)`, +]; + +export const voicecraft = (model: ModelData): string[] => [ + `from voicecraft import VoiceCraft + +model = VoiceCraft.from_pretrained("${model.id}")`, +]; + +export const voxcpm = (model: ModelData): string[] => [ + `import soundfile as sf +from voxcpm import VoxCPM + +model = VoxCPM.from_pretrained("${model.id}") + +wav = model.generate( + text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.", + prompt_wav_path=None, # optional: path to a prompt speech for voice cloning + prompt_text=None, # optional: reference text + cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse + inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed + normalize=True, # enable external TN tool + denoise=True, # enable external Denoise tool + retry_badcase=True, # enable retrying mode for some bad cases (unstoppable) + retry_badcase_max_times=3, # maximum retrying times + retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech +) + +sf.write("output.wav", wav, 16000) +print("saved: output.wav")`, +]; + +export const vui = (): string[] => [ + `# !pip install git+https://github.com/fluxions-ai/vui + +import torchaudio + +from vui.inference import render +from vui.model import Vui, + +model = Vui.from_pretrained().cuda() +waveform = render( + model, + "Hey, here is some random stuff, usually something quite long as the shorter the text the less likely the model can cope!", +) +print(waveform.shape) +torchaudio.save("out.opus", waveform[0], 22050) +`, +]; + +export const chattts = (): string[] => [ + `import ChatTTS +import torchaudio + +chat = ChatTTS.Chat() +chat.load_models(compile=False) # Set to True for better performance + +texts = ["PUT YOUR TEXT HERE",] + +wavs = chat.infer(texts, ) + +torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)`, +]; + +export const ultralytics = (model: ModelData): string[] => { + // ultralytics models must have a version tag (e.g. `yolov8`) + const versionTag = model.tags.find((tag) => tag.match(/^yolov\d+$/)); + + const className = versionTag ? `YOLOv${versionTag.slice(4)}` : "YOLOvXX"; + const prefix = versionTag + ? "" + : `# Couldn't find a valid YOLO version tag.\n# Replace XX with the correct version.\n`; + + return [ + prefix + + `from ultralytics import ${className} + +model = ${className}.from_pretrained("${model.id}") +source = 'http://images.cocodataset.org/val2017/000000039769.jpg' +model.predict(source=source, save=True)`, + ]; +}; + +export const birefnet = (model: ModelData): string[] => [ + `# Option 1: use with transformers + +from transformers import AutoModelForImageSegmentation +birefnet = AutoModelForImageSegmentation.from_pretrained("${model.id}", trust_remote_code=True) +`, + `# Option 2: use with BiRefNet + +# Install from https://github.com/ZhengPeng7/BiRefNet + +from models.birefnet import BiRefNet +model = BiRefNet.from_pretrained("${model.id}")`, +]; + +export const supertonic = (): string[] => [ + `from supertonic import TTS + +tts = TTS(auto_download=True) + +style = tts.get_voice_style(voice_name="M1") + +text = "The train delay was announced at 4:45 PM on Wed, Apr 3, 2024 due to track maintenance." +wav, duration = tts.synthesize(text, voice_style=style) + +tts.save_audio(wav, "output.wav")`, +]; + +export const swarmformer = (model: ModelData): string[] => [ + `from swarmformer import SwarmFormerModel + +model = SwarmFormerModel.from_pretrained("${model.id}") +`, +]; + +export const univa = (model: ModelData): string[] => [ + `# Follow installation instructions at https://github.com/PKU-YuanGroup/UniWorld-V1 + +from univa.models.qwen2p5vl.modeling_univa_qwen2p5vl import UnivaQwen2p5VLForConditionalGeneration + model = UnivaQwen2p5VLForConditionalGeneration.from_pretrained( + "${model.id}", + torch_dtype=torch.bfloat16, + attn_implementation="flash_attention_2", + ).to("cuda") + processor = AutoProcessor.from_pretrained("${model.id}") +`, +]; + +const mlx_unknown = (model: ModelData): string[] => [ + `# Download the model from the Hub +pip install huggingface_hub[hf_xet] + +huggingface-cli download --local-dir ${nameWithoutNamespace(model.id)} ${model.id}`, +]; + +const mlxlm = (model: ModelData): string[] => [ + `# Make sure mlx-lm is installed +# pip install --upgrade mlx-lm +# if on a CUDA device, also pip install mlx[cuda] + +# Generate text with mlx-lm +from mlx_lm import load, generate + +model, tokenizer = load("${model.id}") + +prompt = "Once upon a time in" +text = generate(model, tokenizer, prompt=prompt, verbose=True)`, +]; + +const mlxchat = (model: ModelData): string[] => [ + `# Make sure mlx-lm is installed +# pip install --upgrade mlx-lm + +# Generate text with mlx-lm +from mlx_lm import load, generate + +model, tokenizer = load("${model.id}") + +prompt = "Write a story about Einstein" +messages = [{"role": "user", "content": prompt}] +prompt = tokenizer.apply_chat_template( + messages, add_generation_prompt=True +) + +text = generate(model, tokenizer, prompt=prompt, verbose=True)`, +]; + +const mlxvlm = (model: ModelData): string[] => [ + `# Make sure mlx-vlm is installed +# pip install --upgrade mlx-vlm + +from mlx_vlm import load, generate +from mlx_vlm.prompt_utils import apply_chat_template +from mlx_vlm.utils import load_config + +# Load the model +model, processor = load("${model.id}") +config = load_config("${model.id}") + +# Prepare input +image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] +prompt = "Describe this image." + +# Apply chat template +formatted_prompt = apply_chat_template( + processor, config, prompt, num_images=1 +) + +# Generate output +output = generate(model, processor, formatted_prompt, image) +print(output)`, +]; + +export const mlxim = (model: ModelData): string[] => [ + `from mlxim.model import create_model + +model = create_model(${model.id})`, +]; + +export const mlx = (model: ModelData): string[] => { + if (model.pipeline_tag === "image-text-to-text") { + return mlxvlm(model); + } + if (model.pipeline_tag === "text-generation") { + if (model.tags.includes("conversational")) { + return mlxchat(model); + } else { + return mlxlm(model); + } + } + return mlx_unknown(model); +}; + +export const model2vec = (model: ModelData): string[] => [ + `from model2vec import StaticModel + +model = StaticModel.from_pretrained("${model.id}")`, +]; + +export const pruna = (model: ModelData): string[] => { + let snippets: string[]; + + if (model.tags.includes("diffusers")) { + snippets = pruna_diffusers(model); + } else if (model.tags.includes("transformers")) { + snippets = pruna_transformers(model); + } else { + snippets = pruna_default(model); + } + + const ensurePrunaModelImport = (snippet: string): string => { + if (!/^from pruna import PrunaModel/m.test(snippet)) { + return `from pruna import PrunaModel\n${snippet}`; + } + return snippet; + }; + snippets = snippets.map(ensurePrunaModelImport); + + if (model.tags.includes("pruna_pro-ai")) { + return snippets.map((snippet) => + snippet.replace(/\bpruna\b/g, "pruna_pro").replace(/\bPrunaModel\b/g, "PrunaProModel"), + ); + } + + return snippets; +}; + +const pruna_diffusers = (model: ModelData): string[] => { + const diffusersSnippets = diffusers(model); + + return diffusersSnippets.map((snippet) => + snippet + // Replace pipeline classes with PrunaModel + .replace(/\b\w*Pipeline\w*\b/g, "PrunaModel") + // Clean up diffusers imports containing PrunaModel + .replace(/from diffusers import ([^,\n]*PrunaModel[^,\n]*)/g, "") + .replace(/from diffusers import ([^,\n]+),?\s*([^,\n]*PrunaModel[^,\n]*)/g, "from diffusers import $1") + .replace(/from diffusers import\s*(\n|$)/g, "") + // Fix PrunaModel imports + .replace(/from diffusers import PrunaModel/g, "from pruna import PrunaModel") + .replace(/from diffusers import ([^,\n]+), PrunaModel/g, "from diffusers import $1") + .replace(/from diffusers import PrunaModel, ([^,\n]+)/g, "from diffusers import $1") + // Clean up whitespace + .replace(/\n\n+/g, "\n") + .trim(), + ); +}; + +const pruna_transformers = (model: ModelData): string[] => { + const info = model.transformersInfo; + const transformersSnippets = transformers(model); + + // Replace pipeline with PrunaModel + let processedSnippets = transformersSnippets.map((snippet) => + snippet + .replace(/from transformers import pipeline/g, "from pruna import PrunaModel") + .replace(/pipeline\([^)]*\)/g, `PrunaModel.from_pretrained("${model.id}")`), + ); + + // Additional cleanup if auto_model info is available + if (info?.auto_model) { + processedSnippets = processedSnippets.map((snippet) => + snippet + .replace(new RegExp(`from transformers import ${info.auto_model}\n?`, "g"), "") + .replace(new RegExp(`${info.auto_model}.from_pretrained`, "g"), "PrunaModel.from_pretrained") + .replace(new RegExp(`^.*from.*import.*(, *${info.auto_model})+.*$`, "gm"), (line) => + line.replace(new RegExp(`, *${info.auto_model}`, "g"), ""), + ), + ); + } + + return processedSnippets; +}; + +const pruna_default = (model: ModelData): string[] => [ + `from pruna import PrunaModel +model = PrunaModel.from_pretrained("${model.id}") +`, +]; + +export const nemo = (model: ModelData): string[] => { + let command: string[] | undefined = undefined; + // Resolve the tag to a nemo domain/sub-domain + if (model.tags.includes("automatic-speech-recognition")) { + command = nemoDomainResolver("ASR", model); + } + + return command ?? [`# tag did not correspond to a valid NeMo domain.`]; +}; + +export const outetts = (model: ModelData): string[] => { + // Don’t show this block on GGUF / ONNX mirrors + const t = model.tags ?? []; + if (t.includes("gguf") || t.includes("onnx")) return []; + + // v1.0 HF → minimal runnable snippet + return [ + ` + import outetts + + enum = outetts.Models("${model.id}".split("/", 1)[1]) # VERSION_1_0_SIZE_1B + cfg = outetts.ModelConfig.auto_config(enum, outetts.Backend.HF) + tts = outetts.Interface(cfg) + + speaker = tts.load_default_speaker("EN-FEMALE-1-NEUTRAL") + tts.generate( + outetts.GenerationConfig( + text="Hello there, how are you doing?", + speaker=speaker, + ) + ).save("output.wav") + `, + ]; +}; + +export const pxia = (model: ModelData): string[] => [ + `from pxia import AutoModel + +model = AutoModel.from_pretrained("${model.id}")`, +]; + +export const pythae = (model: ModelData): string[] => [ + `from pythae.models import AutoModel + +model = AutoModel.load_from_hf_hub("${model.id}")`, +]; + +export const qwen3_tts = (model: ModelData): string[] => [ + `# pip install qwen-tts +import torch +import soundfile as sf +from qwen_tts import Qwen3TTSModel + +model = Qwen3TTSModel.from_pretrained( + "${model.id}", + device_map="cuda:0", + dtype=torch.bfloat16, + attn_implementation="flash_attention_2", +) + +wavs, sr = model.generate_custom_voice( + text="Your text here.", + language="English", + speaker="Ryan", + instruct="Speak in a natural tone.", +) + +sf.write("output.wav", wavs[0], sr)`, +]; + +const musicgen = (model: ModelData): string[] => [ + `from audiocraft.models import MusicGen + +model = MusicGen.get_pretrained("${model.id}") + +descriptions = ['happy rock', 'energetic EDM', 'sad jazz'] +wav = model.generate(descriptions) # generates 3 samples.`, +]; + +const magnet = (model: ModelData): string[] => [ + `from audiocraft.models import MAGNeT + +model = MAGNeT.get_pretrained("${model.id}") + +descriptions = ['disco beat', 'energetic EDM', 'funky groove'] +wav = model.generate(descriptions) # generates 3 samples.`, +]; + +const audiogen = (model: ModelData): string[] => [ + `from audiocraft.models import AudioGen + +model = AudioGen.get_pretrained("${model.id}") +model.set_generation_params(duration=5) # generate 5 seconds. +descriptions = ['dog barking', 'sirene of an emergency vehicle', 'footsteps in a corridor'] +wav = model.generate(descriptions) # generates 3 samples.`, +]; +export const anemoi = (model: ModelData): string[] => [ + `from anemoi.inference.runners.default import DefaultRunner +from anemoi.inference.config.run import RunConfiguration +# Create Configuration +config = RunConfiguration(checkpoint = {"huggingface":"${model.id}"}) +# Load Runner +runner = DefaultRunner(config)`, +]; + +export const audiocraft = (model: ModelData): string[] => { + if (model.tags.includes("musicgen")) { + return musicgen(model); + } else if (model.tags.includes("audiogen")) { + return audiogen(model); + } else if (model.tags.includes("magnet")) { + return magnet(model); + } else { + return [`# Type of model unknown.`]; + } +}; + +export const whisperkit = (): string[] => [ + `# Install CLI with Homebrew on macOS device +brew install whisperkit-cli + +# View all available inference options +whisperkit-cli transcribe --help + +# Download and run inference using whisper base model +whisperkit-cli transcribe --audio-path /path/to/audio.mp3 + +# Or use your preferred model variant +whisperkit-cli transcribe --model "large-v3" --model-prefix "distil" --audio-path /path/to/audio.mp3 --verbose`, +]; + +export const threedtopia_xl = (model: ModelData): string[] => [ + `from threedtopia_xl.models import threedtopia_xl + +model = threedtopia_xl.from_pretrained("${model.id}") +model.generate(cond="path/to/image.png")`, +]; + +export const hezar = (model: ModelData): string[] => [ + `from hezar import Model + +model = Model.load("${model.id}")`, +]; + +export const zonos = (model: ModelData): string[] => [ + `# pip install git+https://github.com/Zyphra/Zonos.git +import torchaudio +from zonos.model import Zonos +from zonos.conditioning import make_cond_dict + +model = Zonos.from_pretrained("${model.id}", device="cuda") + +wav, sr = torchaudio.load("speaker.wav") # 5-10s reference clip +speaker = model.make_speaker_embedding(wav, sr) + +cond = make_cond_dict(text="Hello, world!", speaker=speaker, language="en-us") +codes = model.generate(model.prepare_conditioning(cond)) + +audio = model.autoencoder.decode(codes)[0].cpu() +torchaudio.save("sample.wav", audio, model.autoencoder.sampling_rate) +`, +]; + +export const moshi = (model: ModelData): string[] => { + // Detect backend from model name (no distinguishing tags available) + if (model.id.includes("-mlx")) { + // MLX backend (macOS Apple Silicon) + // -q flag only accepts 4 or 8, bf16 models don't use it + const quantFlag = model.id.includes("-q4") ? " -q 4" : model.id.includes("-q8") ? " -q 8" : ""; + return [ + `# pip install moshi_mlx +# Run local inference (macOS Apple Silicon) +python -m moshi_mlx.local${quantFlag} --hf-repo "${model.id}" + +# Or run with web UI +python -m moshi_mlx.local_web${quantFlag} --hf-repo "${model.id}"`, + ]; + } + + if (model.id.includes("-candle")) { + // Rust/Candle backend + return [ + `# pip install rustymimi +# Candle backend - see https://github.com/kyutai-labs/moshi +# for Rust installation instructions`, + ]; + } + + // PyTorch backend (default) + return [ + `# pip install moshi +# Run the interactive web server +python -m moshi.server --hf-repo "${model.id}" +# Then open https://localhost:8998 in your browser`, + `# pip install moshi +import torch +from moshi.models import loaders + +# Load checkpoint info from HuggingFace +checkpoint = loaders.CheckpointInfo.from_hf_repo("${model.id}") + +# Load the Mimi audio codec +mimi = checkpoint.get_mimi(device="cuda") +mimi.set_num_codebooks(8) + +# Encode audio (24kHz, mono) +wav = torch.randn(1, 1, 24000 * 10) # [batch, channels, samples] +with torch.no_grad(): + codes = mimi.encode(wav.cuda()) + decoded = mimi.decode(codes)`, + ]; +}; + +//#endregion diff --git a/node_modules/@huggingface/tasks/src/model-libraries.ts b/node_modules/@huggingface/tasks/src/model-libraries.ts new file mode 100644 index 0000000000000000000000000000000000000000..60a1a4f4a54dd125f7a52398fd28ebe4356709e6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/model-libraries.ts @@ -0,0 +1,1551 @@ +import * as snippets from "./model-libraries-snippets.js"; +import type { ModelData } from "./model-data.js"; +import type { ElasticSearchQuery } from "./model-libraries-downloads.js"; + +/** + * Elements configurable by a model library. + */ +export interface LibraryUiElement { + /** + * Pretty name of the library. + * displayed in tags, and on the main + * call-to-action button on the model page. + */ + prettyLabel: string; + /** + * Repo name of the library's (usually on GitHub) code repo + */ + repoName: string; + /** + * URL to library's (usually on GitHub) code repo + */ + repoUrl: string; + /** + * URL to library's docs + */ + docsUrl?: string; + /** + * Code snippet(s) displayed on model page + */ + snippets?: (model: ModelData) => string[]; + /** + * Elastic query used to count this library's model downloads + * + * By default, those files are counted: + * "config.json", "config.yaml", "hyperparams.yaml", "params.json", "meta.yaml" + */ + countDownloads?: ElasticSearchQuery; + /** + * should we display this library in hf.co/models filter + * (only for popular libraries with > 100 models) + */ + filter?: boolean; +} + +/** + * Add your new library here. + * + * This is for modeling (= architectures) libraries, not for file formats (like ONNX, etc). + * (unlike libraries, file formats live in an enum inside the internal codebase.) + * + * Doc on how to add a library to the Hub: + * + * https://huggingface.co/docs/hub/models-adding-libraries + * + * /!\ IMPORTANT + * + * The key you choose is the tag your models have in their library_name on the Hub. + */ + +export const MODEL_LIBRARIES_UI_ELEMENTS = { + acestep: { + prettyLabel: "ACE-Step", + repoName: "ACE-Step", + repoUrl: "https://github.com/ace-step/ACE-Step", + filter: false, + countDownloads: `path:"ace_step_transformer/config.json"`, + }, + "adapter-transformers": { + prettyLabel: "Adapters", + repoName: "adapters", + repoUrl: "https://github.com/Adapter-Hub/adapters", + docsUrl: "https://huggingface.co/docs/hub/adapters", + snippets: snippets.adapters, + filter: true, + countDownloads: `path:"adapter_config.json"`, + }, + allennlp: { + prettyLabel: "AllenNLP", + repoName: "AllenNLP", + repoUrl: "https://github.com/allenai/allennlp", + docsUrl: "https://huggingface.co/docs/hub/allennlp", + snippets: snippets.allennlp, + filter: true, + }, + anemoi: { + prettyLabel: "AnemoI", + repoName: "AnemoI", + repoUrl: "https://github.com/ecmwf/anemoi-inference", + docsUrl: "https://anemoi.readthedocs.io/en/latest/", + filter: false, + countDownloads: `path_extension:"ckpt"`, + snippets: snippets.anemoi, + }, + araclip: { + prettyLabel: "AraClip", + repoName: "AraClip", + repoUrl: "https://huggingface.co/Arabic-Clip/araclip", + filter: false, + snippets: snippets.araclip, + }, + "aviation-ner": { + prettyLabel: "Aviation NER", + repoName: "Aviation NER", + repoUrl: "https://github.com/Boeing/aviation_ner_sdr", + docsUrl: "https://github.com/Boeing/aviation_ner_sdr", + countDownloads: `path:"gliner_config.json"`, + filter: false, + }, + asteroid: { + prettyLabel: "Asteroid", + repoName: "Asteroid", + repoUrl: "https://github.com/asteroid-team/asteroid", + docsUrl: "https://huggingface.co/docs/hub/asteroid", + snippets: snippets.asteroid, + filter: true, + countDownloads: `path:"pytorch_model.bin"`, + }, + audiocraft: { + prettyLabel: "Audiocraft", + repoName: "audiocraft", + repoUrl: "https://github.com/facebookresearch/audiocraft", + snippets: snippets.audiocraft, + filter: false, + countDownloads: `path:"state_dict.bin"`, + }, + audioseal: { + prettyLabel: "AudioSeal", + repoName: "audioseal", + repoUrl: "https://github.com/facebookresearch/audioseal", + filter: false, + countDownloads: `path_extension:"pth"`, + snippets: snippets.audioseal, + }, + "bagel-mot": { + prettyLabel: "Bagel", + repoName: "Bagel", + repoUrl: "https://github.com/ByteDance-Seed/Bagel/", + filter: false, + countDownloads: `path:"llm_config.json"`, + }, + bboxmaskpose: { + prettyLabel: "BBoxMaskPose", + repoName: "BBoxMaskPose", + repoUrl: "https://github.com/MiraPurkrabek/BBoxMaskPose", + filter: false, + countDownloads: `path_extension:"pth"`, + }, + ben2: { + prettyLabel: "BEN2", + repoName: "BEN2", + repoUrl: "https://github.com/PramaLLC/BEN2", + snippets: snippets.ben2, + filter: false, + }, + bertopic: { + prettyLabel: "BERTopic", + repoName: "BERTopic", + repoUrl: "https://github.com/MaartenGr/BERTopic", + snippets: snippets.bertopic, + filter: true, + }, + big_vision: { + prettyLabel: "Big Vision", + repoName: "big_vision", + repoUrl: "https://github.com/google-research/big_vision", + filter: false, + countDownloads: `path_extension:"npz"`, + }, + birder: { + prettyLabel: "Birder", + repoName: "Birder", + repoUrl: "https://gitlab.com/birder/birder", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + birefnet: { + prettyLabel: "BiRefNet", + repoName: "BiRefNet", + repoUrl: "https://github.com/ZhengPeng7/BiRefNet", + snippets: snippets.birefnet, + filter: false, + }, + bm25s: { + prettyLabel: "BM25S", + repoName: "bm25s", + repoUrl: "https://github.com/xhluca/bm25s", + snippets: snippets.bm25s, + filter: false, + countDownloads: `path:"params.index.json"`, + }, + boltzgen: { + prettyLabel: "BoltzGen", + repoName: "BoltzGen", + repoUrl: "https://github.com/HannesStark/boltzgen", + filter: false, + countDownloads: `path:"boltzgen1_diverse.ckpt"`, + }, + cancertathomev2: { + prettyLabel: "Cancer@HomeV2", + repoName: "Cancer@HomeV2", + repoUrl: "https://huggingface.co/OpenPeerAI/CancerAtHomeV2", + filter: false, + countDownloads: `path:"run.py"`, + }, + cartesia_pytorch: { + prettyLabel: "Cartesia Pytorch", + repoName: "Cartesia Pytorch", + repoUrl: "https://github.com/cartesia-ai/cartesia_pytorch", + snippets: snippets.cartesia_pytorch, + }, + cartesia_mlx: { + prettyLabel: "Cartesia MLX", + repoName: "Cartesia MLX", + repoUrl: "https://github.com/cartesia-ai/cartesia_mlx", + snippets: snippets.cartesia_mlx, + }, + champ: { + prettyLabel: "Champ", + repoName: "Champ", + repoUrl: "https://github.com/fudan-generative-vision/champ", + countDownloads: `path:"champ/motion_module.pth"`, + }, + chatterbox: { + prettyLabel: "Chatterbox", + repoName: "Chatterbox", + repoUrl: "https://github.com/resemble-ai/chatterbox", + snippets: snippets.chatterbox, + countDownloads: `path:"tokenizer.json"`, + filter: false, + }, + chaossim: { + prettyLabel: "ChaosSIM", + repoName: "ChaosSIM", + repoUrl: "https://huggingface.co/OpenPeerAI/ChaosSIM/", + countDownloads: `path:"ChaosSim.nb"`, + filter: false, + }, + chat_tts: { + prettyLabel: "ChatTTS", + repoName: "ChatTTS", + repoUrl: "https://github.com/2noise/ChatTTS.git", + snippets: snippets.chattts, + filter: false, + countDownloads: `path:"asset/GPT.pt"`, + }, + "chronos-forecasting": { + prettyLabel: "Chronos", + repoName: "Chronos", + repoUrl: "https://github.com/amazon-science/chronos-forecasting", + snippets: snippets.chronos_forecasting, + }, + clara: { + prettyLabel: "Clara", + repoName: "Clara", + filter: false, + repoUrl: "https://github.com/nvidia/clara", + countDownloads: `path_extension:"ckpt" OR path:"config.json"`, + }, + clipscope: { + prettyLabel: "clipscope", + repoName: "clipscope", + repoUrl: "https://github.com/Lewington-pitsos/clipscope", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + "cloud-agents": { + prettyLabel: "Cloud Agents", + repoName: "Cloud Agents", + repoUrl: "https://huggingface.co/OpenPeerAI/Cloud-Agents", + filter: false, + countDownloads: `path:"setup.py"`, + }, + colipri: { + prettyLabel: "COLIPRI", + repoName: "COLIPRI", + repoUrl: "https://huggingface.co/microsoft/colipri", + snippets: snippets.colipri, + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + cosyvoice: { + prettyLabel: "CosyVoice", + repoName: "CosyVoice", + repoUrl: "https://github.com/FunAudioLLM/CosyVoice", + filter: false, + countDownloads: `path_extension:"onnx" OR path_extension:"pt"`, + }, + cotracker: { + prettyLabel: "CoTracker", + repoName: "CoTracker", + repoUrl: "https://github.com/facebookresearch/co-tracker", + filter: false, + countDownloads: `path_extension:"pth"`, + }, + colpali: { + prettyLabel: "ColPali", + repoName: "ColPali", + repoUrl: "https://github.com/ManuelFay/colpali", + filter: false, + countDownloads: `path:"adapter_config.json"`, + }, + comet: { + prettyLabel: "COMET", + repoName: "COMET", + repoUrl: "https://github.com/Unbabel/COMET/", + countDownloads: `path:"hparams.yaml"`, + }, + cosmos: { + prettyLabel: "Cosmos", + repoName: "Cosmos", + repoUrl: "https://github.com/NVIDIA/Cosmos", + countDownloads: `path:"config.json" OR path_extension:"pt"`, + }, + "cxr-foundation": { + prettyLabel: "CXR Foundation", + repoName: "cxr-foundation", + repoUrl: "https://github.com/google-health/cxr-foundation", + snippets: snippets.cxr_foundation, + filter: false, + countDownloads: `path:"precomputed_embeddings/embeddings.npz" OR path:"pax-elixr-b-text/saved_model.pb"`, + }, + deepforest: { + prettyLabel: "DeepForest", + repoName: "deepforest", + docsUrl: "https://deepforest.readthedocs.io/en/latest/", + repoUrl: "https://github.com/weecology/DeepForest", + }, + "depth-anything-v2": { + prettyLabel: "DepthAnythingV2", + repoName: "Depth Anything V2", + repoUrl: "https://github.com/DepthAnything/Depth-Anything-V2", + snippets: snippets.depth_anything_v2, + filter: false, + countDownloads: `path_extension:"pth"`, + }, + "depth-pro": { + prettyLabel: "Depth Pro", + repoName: "Depth Pro", + repoUrl: "https://github.com/apple/ml-depth-pro", + countDownloads: `path_extension:"pt"`, + snippets: snippets.depth_pro, + filter: false, + }, + "derm-foundation": { + prettyLabel: "Derm Foundation", + repoName: "derm-foundation", + repoUrl: "https://github.com/google-health/derm-foundation", + snippets: snippets.derm_foundation, + filter: false, + countDownloads: `path:"scin_dataset_precomputed_embeddings.npz" OR path:"saved_model.pb"`, + }, + "describe-anything": { + prettyLabel: "Describe Anything", + repoName: "Describe Anything", + repoUrl: "https://github.com/NVlabs/describe-anything", + snippets: snippets.describe_anything, + filter: false, + }, + "dia-tts": { + prettyLabel: "Dia", + repoName: "Dia", + repoUrl: "https://github.com/nari-labs/dia", + snippets: snippets.dia, + filter: false, + }, + dia2: { + prettyLabel: "Dia2", + repoName: "Dia2", + repoUrl: "https://github.com/nari-labs/dia2", + snippets: snippets.dia2, + filter: false, + }, + "diff-interpretation-tuning": { + prettyLabel: "Diff Interpretation Tuning", + repoName: "Diff Interpretation Tuning", + repoUrl: "https://github.com/Aviously/diff-interpretation-tuning", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + diffree: { + prettyLabel: "Diffree", + repoName: "Diffree", + repoUrl: "https://github.com/OpenGVLab/Diffree", + filter: false, + countDownloads: `path:"diffree-step=000010999.ckpt"`, + }, + diffusers: { + prettyLabel: "Diffusers", + repoName: "🤗/diffusers", + repoUrl: "https://github.com/huggingface/diffusers", + docsUrl: "https://huggingface.co/docs/hub/diffusers", + snippets: snippets.diffusers, + filter: true, + /// diffusers has its own more complex "countDownloads" query + }, + diffusionkit: { + prettyLabel: "DiffusionKit", + repoName: "DiffusionKit", + repoUrl: "https://github.com/argmaxinc/DiffusionKit", + snippets: snippets.diffusionkit, + }, + "docking-at-home": { + prettyLabel: "Docking@Home", + repoName: "Docking@Home", + repoUrl: "https://huggingface.co/OpenPeerAI/DockingAtHOME", + filter: false, + countDownloads: `path:"setup.py"`, + }, + doctr: { + prettyLabel: "docTR", + repoName: "doctr", + repoUrl: "https://github.com/mindee/doctr", + }, + edsnlp: { + prettyLabel: "EDS-NLP", + repoName: "edsnlp", + repoUrl: "https://github.com/aphp/edsnlp", + docsUrl: "https://aphp.github.io/edsnlp/latest/", + filter: false, + snippets: snippets.edsnlp, + countDownloads: `path_filename:"config" AND path_extension:"cfg"`, + }, + elm: { + prettyLabel: "ELM", + repoName: "elm", + repoUrl: "https://github.com/slicex-ai/elm", + filter: false, + countDownloads: `path_filename:"slicex_elm_config" AND path_extension:"json"`, + }, + espnet: { + prettyLabel: "ESPnet", + repoName: "ESPnet", + repoUrl: "https://github.com/espnet/espnet", + docsUrl: "https://huggingface.co/docs/hub/espnet", + snippets: snippets.espnet, + filter: true, + }, + fairseq: { + prettyLabel: "Fairseq", + repoName: "fairseq", + repoUrl: "https://github.com/pytorch/fairseq", + snippets: snippets.fairseq, + filter: true, + }, + fastai: { + prettyLabel: "fastai", + repoName: "fastai", + repoUrl: "https://github.com/fastai/fastai", + docsUrl: "https://huggingface.co/docs/hub/fastai", + snippets: snippets.fastai, + filter: true, + }, + fastprint: { + prettyLabel: "Fast Print", + repoName: "Fast Print", + repoUrl: "https://huggingface.co/OpenPeerAI/FastPrint", + countDownloads: `path_extension:"cs"`, + }, + fasttext: { + prettyLabel: "fastText", + repoName: "fastText", + repoUrl: "https://fasttext.cc/", + snippets: snippets.fasttext, + filter: true, + countDownloads: `path_extension:"bin"`, + }, + fixer: { + prettyLabel: "Fixer", + repoName: "Fixer", + repoUrl: "https://github.com/nv-tlabs/Fixer", + filter: false, + countDownloads: `path:"pretrained/pretrained_fixer.pkl"`, + }, + flair: { + prettyLabel: "Flair", + repoName: "Flair", + repoUrl: "https://github.com/flairNLP/flair", + docsUrl: "https://huggingface.co/docs/hub/flair", + snippets: snippets.flair, + filter: true, + countDownloads: `path:"pytorch_model.bin"`, + }, + fme: { + prettyLabel: "Full Model Emulation", + repoName: "Full Model Emulation", + repoUrl: "https://github.com/ai2cm/ace", + docsUrl: "https://ai2-climate-emulator.readthedocs.io/en/latest/", + filter: false, + countDownloads: `path_extension:"tar"`, + }, + "gemma.cpp": { + prettyLabel: "gemma.cpp", + repoName: "gemma.cpp", + repoUrl: "https://github.com/google/gemma.cpp", + filter: false, + countDownloads: `path_extension:"sbs"`, + }, + "geometry-crafter": { + prettyLabel: "GeometryCrafter", + repoName: "GeometryCrafter", + repoUrl: "https://github.com/TencentARC/GeometryCrafter", + countDownloads: `path:"point_map_vae/diffusion_pytorch_model.safetensors"`, + }, + gliner: { + prettyLabel: "GLiNER", + repoName: "GLiNER", + repoUrl: "https://github.com/urchade/GLiNER", + snippets: snippets.gliner, + filter: false, + countDownloads: `path:"gliner_config.json"`, + }, + gliner2: { + prettyLabel: "GLiNER2", + repoName: "GLiNER2", + repoUrl: "https://github.com/fastino-ai/GLiNER2", + snippets: snippets.gliner2, + filter: false, + }, + "glm-tts": { + prettyLabel: "GLM-TTS", + repoName: "GLM-TTS", + repoUrl: "https://github.com/zai-org/GLM-TTS", + filter: false, + countDownloads: `path:"flow/flow.pt"`, + }, + "glyph-byt5": { + prettyLabel: "Glyph-ByT5", + repoName: "Glyph-ByT5", + repoUrl: "https://github.com/AIGText/Glyph-ByT5", + filter: false, + countDownloads: `path:"checkpoints/byt5_model.pt"`, + }, + grok: { + prettyLabel: "Grok", + repoName: "Grok", + repoUrl: "https://github.com/xai-org/grok-1", + filter: false, + countDownloads: `path:"ckpt/tensor00000_000" OR path:"ckpt-0/tensor00000_000"`, + }, + "habibi-tts": { + prettyLabel: "Habibi-TTS", + repoName: "Habibi-TTS", + repoUrl: "https://github.com/SWivid/Habibi-TTS", + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + hallo: { + prettyLabel: "Hallo", + repoName: "Hallo", + repoUrl: "https://github.com/fudan-generative-vision/hallo", + countDownloads: `path:"hallo/net.pth"`, + }, + hermes: { + prettyLabel: "HERMES", + repoName: "HERMES", + repoUrl: "https://github.com/LMD0311/HERMES", + filter: false, + countDownloads: `path:"ckpt/hermes_final.pth"`, + }, + hezar: { + prettyLabel: "Hezar", + repoName: "Hezar", + repoUrl: "https://github.com/hezarai/hezar", + docsUrl: "https://hezarai.github.io/hezar", + countDownloads: `path:"model_config.yaml" OR path:"embedding/embedding_config.yaml"`, + }, + htrflow: { + prettyLabel: "HTRflow", + repoName: "HTRflow", + repoUrl: "https://github.com/AI-Riksarkivet/htrflow", + docsUrl: "https://ai-riksarkivet.github.io/htrflow", + snippets: snippets.htrflow, + }, + "hunyuan-dit": { + prettyLabel: "HunyuanDiT", + repoName: "HunyuanDiT", + repoUrl: "https://github.com/Tencent/HunyuanDiT", + countDownloads: `path:"pytorch_model_ema.pt" OR path:"pytorch_model_distill.pt"`, + }, + "hunyuan3d-2": { + prettyLabel: "Hunyuan3D-2", + repoName: "Hunyuan3D-2", + repoUrl: "https://github.com/Tencent/Hunyuan3D-2", + countDownloads: `path_filename:"model_index" OR path_filename:"config"`, + }, + "hunyuanworld-voyager": { + prettyLabel: "HunyuanWorld-voyager", + repoName: "HunyuanWorld-voyager", + repoUrl: "https://github.com/Tencent-Hunyuan/HunyuanWorld-Voyager", + }, + "hy-worldplay": { + prettyLabel: "HY-WorldPlay", + repoName: "HY-WorldPlay", + repoUrl: "https://github.com/Tencent-Hunyuan/HY-WorldPlay", + filter: false, + countDownloads: `path_extension:"json"`, + }, + "image-matching-models": { + prettyLabel: "Image Matching Models", + repoName: "Image Matching Models", + repoUrl: "https://github.com/alexstoken/image-matching-models", + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + imstoucan: { + prettyLabel: "IMS Toucan", + repoName: "IMS-Toucan", + repoUrl: "https://github.com/DigitalPhonetics/IMS-Toucan", + countDownloads: `path:"embedding_gan.pt" OR path:"Vocoder.pt" OR path:"ToucanTTS.pt"`, + }, + "index-tts": { + prettyLabel: "IndexTTS", + repoName: "IndexTTS", + repoUrl: "https://github.com/index-tts/index-tts", + snippets: snippets.indextts, + filter: false, + }, + infinitetalk: { + prettyLabel: "InfiniteTalk", + repoName: "InfiniteTalk", + repoUrl: "https://github.com/MeiGen-AI/InfiniteTalk", + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + "infinite-you": { + prettyLabel: "InfiniteYou", + repoName: "InfiniteYou", + repoUrl: "https://github.com/bytedance/InfiniteYou", + filter: false, + countDownloads: `path:"infu_flux_v1.0/sim_stage1/image_proj_model.bin" OR path:"infu_flux_v1.0/aes_stage2/image_proj_model.bin"`, + }, + intellifold: { + prettyLabel: "IntelliFold", + repoName: "IntelliFold", + repoUrl: "https://github.com/IntelliGen-AI/IntelliFold", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + keras: { + prettyLabel: "Keras", + repoName: "Keras", + repoUrl: "https://github.com/keras-team/keras", + docsUrl: "https://huggingface.co/docs/hub/keras", + snippets: snippets.keras, + filter: true, + countDownloads: `path:"config.json" OR path_extension:"keras"`, + }, + "tf-keras": { + // Legacy "Keras 2" library (tensorflow-only) + prettyLabel: "TF-Keras", + repoName: "TF-Keras", + repoUrl: "https://github.com/keras-team/tf-keras", + docsUrl: "https://huggingface.co/docs/hub/tf-keras", + snippets: snippets.tf_keras, + countDownloads: `path:"saved_model.pb"`, + }, + "keras-hub": { + prettyLabel: "KerasHub", + repoName: "KerasHub", + repoUrl: "https://github.com/keras-team/keras-hub", + docsUrl: "https://keras.io/keras_hub/", + snippets: snippets.keras_hub, + filter: true, + }, + kernels: { + prettyLabel: "Kernels", + repoName: "Kernels", + repoUrl: "https://github.com/huggingface/kernels", + docsUrl: "https://huggingface.co/docs/kernels", + snippets: snippets.kernels, + countDownloads: `path_filename:"_ops" AND path_extension:"py"`, + }, + "kimi-audio": { + prettyLabel: "KimiAudio", + repoName: "KimiAudio", + repoUrl: "https://github.com/MoonshotAI/Kimi-Audio", + snippets: snippets.kimi_audio, + filter: false, + }, + kittentts: { + prettyLabel: "KittenTTS", + repoName: "KittenTTS", + repoUrl: "https://github.com/KittenML/KittenTTS", + snippets: snippets.kittentts, + }, + kronos: { + prettyLabel: "KRONOS", + repoName: "KRONOS", + repoUrl: "https://github.com/mahmoodlab/KRONOS", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + k2: { + prettyLabel: "K2", + repoName: "k2", + repoUrl: "https://github.com/k2-fsa/k2", + }, + "lightning-ir": { + prettyLabel: "Lightning IR", + repoName: "Lightning IR", + repoUrl: "https://github.com/webis-de/lightning-ir", + snippets: snippets.lightning_ir, + }, + litert: { + prettyLabel: "LiteRT", + repoName: "LiteRT", + repoUrl: "https://github.com/google-ai-edge/LiteRT", + filter: false, + countDownloads: `path_extension:"tflite"`, + }, + "litert-lm": { + prettyLabel: "LiteRT-LM", + repoName: "LiteRT-LM", + repoUrl: "https://github.com/google-ai-edge/LiteRT-LM", + filter: false, + countDownloads: `path_extension:"litertlm" OR path_extension:"task"`, + }, + lerobot: { + prettyLabel: "LeRobot", + repoName: "LeRobot", + repoUrl: "https://github.com/huggingface/lerobot", + docsUrl: "https://huggingface.co/docs/lerobot", + filter: false, + snippets: snippets.lerobot, + }, + lightglue: { + prettyLabel: "LightGlue", + repoName: "LightGlue", + repoUrl: "https://github.com/cvg/LightGlue", + filter: false, + countDownloads: `path_extension:"pth" OR path:"config.json"`, + }, + liveportrait: { + prettyLabel: "LivePortrait", + repoName: "LivePortrait", + repoUrl: "https://github.com/KwaiVGI/LivePortrait", + filter: false, + countDownloads: `path:"liveportrait/landmark.onnx"`, + }, + "llama-cpp-python": { + prettyLabel: "llama-cpp-python", + repoName: "llama-cpp-python", + repoUrl: "https://github.com/abetlen/llama-cpp-python", + snippets: snippets.llama_cpp_python, + }, + "mini-omni2": { + prettyLabel: "Mini-Omni2", + repoName: "Mini-Omni2", + repoUrl: "https://github.com/gpt-omni/mini-omni2", + countDownloads: `path:"model_config.yaml"`, + }, + mindspore: { + prettyLabel: "MindSpore", + repoName: "mindspore", + repoUrl: "https://github.com/mindspore-ai/mindspore", + }, + "magi-1": { + prettyLabel: "MAGI-1", + repoName: "MAGI-1", + repoUrl: "https://github.com/SandAI-org/MAGI-1", + countDownloads: `path:"ckpt/vae/config.json"`, + }, + "magenta-realtime": { + prettyLabel: "Magenta RT", + repoName: "Magenta RT", + repoUrl: "https://github.com/magenta/magenta-realtime", + countDownloads: `path:"checkpoints/llm_base_x4286_c1860k.tar" OR path:"checkpoints/llm_large_x3047_c1860k.tar" OR path:"checkpoints/llm_large_x3047_c1860k/checkpoint"`, + }, + "mamba-ssm": { + prettyLabel: "MambaSSM", + repoName: "MambaSSM", + repoUrl: "https://github.com/state-spaces/mamba", + filter: false, + snippets: snippets.mamba_ssm, + }, + "mars5-tts": { + prettyLabel: "MARS5-TTS", + repoName: "MARS5-TTS", + repoUrl: "https://github.com/Camb-ai/MARS5-TTS", + filter: false, + countDownloads: `path:"mars5_ar.safetensors"`, + snippets: snippets.mars5_tts, + }, + matanyone: { + prettyLabel: "MatAnyone", + repoName: "MatAnyone", + repoUrl: "https://github.com/pq-yang/MatAnyone", + snippets: snippets.matanyone, + filter: false, + }, + "mesh-anything": { + prettyLabel: "MeshAnything", + repoName: "MeshAnything", + repoUrl: "https://github.com/buaacyw/MeshAnything", + filter: false, + countDownloads: `path:"MeshAnything_350m.pth"`, + snippets: snippets.mesh_anything, + }, + merlin: { + prettyLabel: "Merlin", + repoName: "Merlin", + repoUrl: "https://github.com/StanfordMIMI/Merlin", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + medvae: { + prettyLabel: "MedVAE", + repoName: "MedVAE", + repoUrl: "https://github.com/StanfordMIMI/MedVAE", + filter: false, + countDownloads: `path_extension:"ckpt"`, + }, + mitie: { + prettyLabel: "MITIE", + repoName: "MITIE", + repoUrl: "https://github.com/mit-nlp/MITIE", + countDownloads: `path_filename:"total_word_feature_extractor"`, + }, + "ml-agents": { + prettyLabel: "ml-agents", + repoName: "ml-agents", + repoUrl: "https://github.com/Unity-Technologies/ml-agents", + docsUrl: "https://huggingface.co/docs/hub/ml-agents", + snippets: snippets.mlAgents, + filter: true, + countDownloads: `path_extension:"onnx"`, + }, + "ml-sharp": { + prettyLabel: "Sharp", + repoName: "Sharp", + repoUrl: "https://github.com/apple/ml-sharp", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + mlx: { + prettyLabel: "MLX", + repoName: "MLX", + repoUrl: "https://github.com/ml-explore/mlx-examples/tree/main", + snippets: snippets.mlx, + filter: true, + }, + "mlx-image": { + prettyLabel: "mlx-image", + repoName: "mlx-image", + repoUrl: "https://github.com/riccardomusmeci/mlx-image", + docsUrl: "https://huggingface.co/docs/hub/mlx-image", + snippets: snippets.mlxim, + filter: false, + countDownloads: `path:"model.safetensors"`, + }, + "mlc-llm": { + prettyLabel: "MLC-LLM", + repoName: "MLC-LLM", + repoUrl: "https://github.com/mlc-ai/mlc-llm", + docsUrl: "https://llm.mlc.ai/docs/", + filter: false, + countDownloads: `path:"mlc-chat-config.json"`, + }, + model2vec: { + prettyLabel: "Model2Vec", + repoName: "model2vec", + repoUrl: "https://github.com/MinishLab/model2vec", + snippets: snippets.model2vec, + filter: false, + }, + moshi: { + prettyLabel: "Moshi", + repoName: "Moshi", + repoUrl: "https://github.com/kyutai-labs/moshi", + snippets: snippets.moshi, + filter: false, + countDownloads: `path:"tokenizer-e351c8d8-checkpoint125.safetensors"`, + }, + mtvcraft: { + prettyLabel: "MTVCraft", + repoName: "MTVCraft", + repoUrl: "https://github.com/baaivision/MTVCraft", + filter: false, + countDownloads: `path:"vae/3d-vae.pt"`, + }, + nemo: { + prettyLabel: "NeMo", + repoName: "NeMo", + repoUrl: "https://github.com/NVIDIA/NeMo", + snippets: snippets.nemo, + filter: true, + countDownloads: `path_extension:"nemo" OR path:"model_config.yaml" OR path_extension:"json"`, + }, + "open-oasis": { + prettyLabel: "open-oasis", + repoName: "open-oasis", + repoUrl: "https://github.com/etched-ai/open-oasis", + countDownloads: `path:"oasis500m.safetensors"`, + }, + open_clip: { + prettyLabel: "OpenCLIP", + repoName: "OpenCLIP", + repoUrl: "https://github.com/mlfoundations/open_clip", + snippets: snippets.open_clip, + filter: true, + countDownloads: `path:"open_clip_model.safetensors" + OR path:"model.safetensors" + OR path:"open_clip_pytorch_model.bin" + OR path:"pytorch_model.bin"`, + }, + openpeerllm: { + prettyLabel: "OpenPeerLLM", + repoName: "OpenPeerLLM", + repoUrl: "https://huggingface.co/openpeerai/openpeerllm", + docsUrl: "https://huggingface.co/OpenPeerAI/OpenPeerLLM/blob/main/README.md", + countDownloads: `path:".meta-huggingface.json"`, + filter: false, + }, + "open-sora": { + prettyLabel: "Open-Sora", + repoName: "Open-Sora", + repoUrl: "https://github.com/hpcaitech/Open-Sora", + filter: false, + countDownloads: `path:"Open_Sora_v2.safetensors"`, + }, + outetts: { + prettyLabel: "OuteTTS", + repoName: "OuteTTS", + repoUrl: "https://github.com/edwko/OuteTTS", + snippets: snippets.outetts, + filter: false, + }, + paddlenlp: { + prettyLabel: "paddlenlp", + repoName: "PaddleNLP", + repoUrl: "https://github.com/PaddlePaddle/PaddleNLP", + docsUrl: "https://huggingface.co/docs/hub/paddlenlp", + snippets: snippets.paddlenlp, + filter: true, + countDownloads: `path:"model_config.json"`, + }, + PaddleOCR: { + prettyLabel: "PaddleOCR", + repoName: "PaddleOCR", + repoUrl: "https://github.com/PaddlePaddle/PaddleOCR", + docsUrl: "https://www.paddleocr.ai/", + snippets: snippets.paddleocr, + filter: true, + countDownloads: `path_extension:"safetensors" OR path:"inference.pdiparams"`, + }, + peft: { + prettyLabel: "PEFT", + repoName: "PEFT", + repoUrl: "https://github.com/huggingface/peft", + snippets: snippets.peft, + filter: true, + countDownloads: `path:"adapter_config.json"`, + }, + "perception-encoder": { + prettyLabel: "PerceptionEncoder", + repoName: "PerceptionModels", + repoUrl: "https://github.com/facebookresearch/perception_models", + filter: false, + snippets: snippets.perception_encoder, + countDownloads: `path_extension:"pt"`, + }, + "phantom-wan": { + prettyLabel: "Phantom", + repoName: "Phantom", + repoUrl: "https://github.com/Phantom-video/Phantom", + snippets: snippets.phantom_wan, + filter: false, + countDownloads: `path_extension:"pth"`, + }, + "pocket-tts": { + prettyLabel: "Pocket-TTS", + repoName: "PocketTTS", + repoUrl: "https://github.com/kyutai-labs/pocket-tts", + snippets: snippets.pocket_tts, + filter: false, + countDownloads: `path:"tts_b6369a24.safetensors"`, + }, + "pruna-ai": { + prettyLabel: "Pruna AI", + repoName: "Pruna AI", + repoUrl: "https://github.com/PrunaAI/pruna", + snippets: snippets.pruna, + docsUrl: "https://docs.pruna.ai", + }, + pxia: { + prettyLabel: "pxia", + repoName: "pxia", + repoUrl: "https://github.com/not-lain/pxia", + snippets: snippets.pxia, + filter: false, + }, + "pyannote-audio": { + prettyLabel: "pyannote.audio", + repoName: "pyannote-audio", + repoUrl: "https://github.com/pyannote/pyannote-audio", + snippets: snippets.pyannote_audio, + filter: true, + }, + "py-feat": { + prettyLabel: "Py-Feat", + repoName: "Py-Feat", + repoUrl: "https://github.com/cosanlab/py-feat", + docsUrl: "https://py-feat.org/", + filter: false, + }, + pythae: { + prettyLabel: "pythae", + repoName: "pythae", + repoUrl: "https://github.com/clementchadebec/benchmark_VAE", + snippets: snippets.pythae, + filter: false, + }, + quantumpeer: { + prettyLabel: "QuantumPeer", + repoName: "QuantumPeer", + repoUrl: "https://github.com/OpenPeer-AI/QuantumPeer", + filter: false, + countDownloads: `path_extension:"setup.py"`, + }, + qwen3_tts: { + prettyLabel: "Qwen3-TTS", + repoName: "Qwen3-TTS", + repoUrl: "https://github.com/QwenLM/Qwen3-TTS", + snippets: snippets.qwen3_tts, + filter: false, + }, + recurrentgemma: { + prettyLabel: "RecurrentGemma", + repoName: "recurrentgemma", + repoUrl: "https://github.com/google-deepmind/recurrentgemma", + filter: false, + countDownloads: `path:"tokenizer.model"`, + }, + relik: { + prettyLabel: "Relik", + repoName: "Relik", + repoUrl: "https://github.com/SapienzaNLP/relik", + snippets: snippets.relik, + filter: false, + }, + refiners: { + prettyLabel: "Refiners", + repoName: "Refiners", + repoUrl: "https://github.com/finegrain-ai/refiners", + docsUrl: "https://refine.rs/", + filter: false, + countDownloads: `path:"model.safetensors"`, + }, + renderformer: { + prettyLabel: "RenderFormer", + repoName: "RenderFormer", + repoUrl: "https://github.com/microsoft/renderformer", + snippets: snippets.renderformer, + filter: false, + }, + reverb: { + prettyLabel: "Reverb", + repoName: "Reverb", + repoUrl: "https://github.com/revdotcom/reverb", + filter: false, + }, + rkllm: { + prettyLabel: "RKLLM", + repoName: "RKLLM", + repoUrl: "https://github.com/airockchip/rknn-llm", + countDownloads: `path_extension:"rkllm"`, + }, + saelens: { + prettyLabel: "SAELens", + repoName: "SAELens", + repoUrl: "https://github.com/jbloomAus/SAELens", + snippets: snippets.saelens, + filter: false, + }, + sam2: { + prettyLabel: "sam2", + repoName: "sam2", + repoUrl: "https://github.com/facebookresearch/segment-anything-2", + filter: false, + snippets: snippets.sam2, + countDownloads: `path_extension:"pt"`, + }, + "sam-3d-body": { + prettyLabel: "SAM 3D Body", + repoName: "SAM 3D Body", + repoUrl: "https://github.com/facebookresearch/sam-3d-body", + filter: false, + snippets: snippets.sam_3d_body, + countDownloads: `path:"model_config.yaml"`, + }, + "sam-3d-objects": { + prettyLabel: "SAM 3D Objects", + repoName: "SAM 3D Objects", + repoUrl: "https://github.com/facebookresearch/sam-3d-objects", + filter: false, + snippets: snippets.sam_3d_objects, + countDownloads: `path:"checkpoints/pipeline.yaml"`, + }, + same: { + prettyLabel: "SAME", + repoName: "SAME", + repoUrl: "https://github.com/GengzeZhou/SAME", + filter: false, + countDownloads: `path:"ckpt/SAME.pt" OR path:"pretrain/Attnq_pretrained_ckpt.pt"`, + }, + "sample-factory": { + prettyLabel: "sample-factory", + repoName: "sample-factory", + repoUrl: "https://github.com/alex-petrenko/sample-factory", + docsUrl: "https://huggingface.co/docs/hub/sample-factory", + snippets: snippets.sampleFactory, + filter: true, + countDownloads: `path:"cfg.json"`, + }, + "sap-rpt-1-oss": { + prettyLabel: "sap-rpt-1-oss", + repoName: "sap-rpt-1-oss", + repoUrl: "https://github.com/SAP-samples/sap-rpt-1-oss", + countDownloads: `path_extension:"pt"`, + snippets: snippets.sap_rpt_one_oss, + }, + sapiens: { + prettyLabel: "sapiens", + repoName: "sapiens", + repoUrl: "https://github.com/facebookresearch/sapiens", + filter: false, + countDownloads: `path_extension:"pt2" OR path_extension:"pth" OR path_extension:"onnx"`, + }, + seedvr: { + prettyLabel: "SeedVR", + repoName: "SeedVR", + repoUrl: "https://github.com/ByteDance-Seed/SeedVR", + filter: false, + countDownloads: `path_extension:"pth"`, + }, + "self-forcing": { + prettyLabel: "SelfForcing", + repoName: "SelfForcing", + repoUrl: "https://github.com/guandeh17/Self-Forcing", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + "sentence-transformers": { + prettyLabel: "sentence-transformers", + repoName: "sentence-transformers", + repoUrl: "https://github.com/UKPLab/sentence-transformers", + docsUrl: "https://huggingface.co/docs/hub/sentence-transformers", + snippets: snippets.sentenceTransformers, + filter: true, + }, + setfit: { + prettyLabel: "setfit", + repoName: "setfit", + repoUrl: "https://github.com/huggingface/setfit", + docsUrl: "https://huggingface.co/docs/hub/setfit", + snippets: snippets.setfit, + filter: true, + }, + sklearn: { + prettyLabel: "Scikit-learn", + repoName: "Scikit-learn", + repoUrl: "https://github.com/scikit-learn/scikit-learn", + snippets: snippets.sklearn, + filter: true, + countDownloads: `path:"sklearn_model.joblib"`, + }, + spacy: { + prettyLabel: "spaCy", + repoName: "spaCy", + repoUrl: "https://github.com/explosion/spaCy", + docsUrl: "https://huggingface.co/docs/hub/spacy", + snippets: snippets.spacy, + filter: true, + countDownloads: `path_extension:"whl"`, + }, + "span-marker": { + prettyLabel: "SpanMarker", + repoName: "SpanMarkerNER", + repoUrl: "https://github.com/tomaarsen/SpanMarkerNER", + docsUrl: "https://huggingface.co/docs/hub/span_marker", + snippets: snippets.span_marker, + filter: true, + }, + speechbrain: { + prettyLabel: "speechbrain", + repoName: "speechbrain", + repoUrl: "https://github.com/speechbrain/speechbrain", + docsUrl: "https://huggingface.co/docs/hub/speechbrain", + snippets: snippets.speechbrain, + filter: true, + countDownloads: `path:"hyperparams.yaml"`, + }, + "ssr-speech": { + prettyLabel: "SSR-Speech", + repoName: "SSR-Speech", + repoUrl: "https://github.com/WangHelin1997/SSR-Speech", + filter: false, + countDownloads: `path_extension:".pth"`, + }, + "stable-audio-tools": { + prettyLabel: "Stable Audio Tools", + repoName: "stable-audio-tools", + repoUrl: "https://github.com/Stability-AI/stable-audio-tools.git", + filter: false, + countDownloads: `path:"model.safetensors"`, + snippets: snippets.stable_audio_tools, + }, + monkeyocr: { + prettyLabel: "MonkeyOCR", + repoName: "monkeyocr", + repoUrl: "https://github.com/Yuliang-Liu/MonkeyOCR", + filter: false, + countDownloads: `path:"Recognition/config.json"`, + }, + "diffusion-single-file": { + prettyLabel: "Diffusion Single File", + repoName: "diffusion-single-file", + repoUrl: "https://github.com/comfyanonymous/ComfyUI", + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + "seed-story": { + prettyLabel: "SEED-Story", + repoName: "SEED-Story", + repoUrl: "https://github.com/TencentARC/SEED-Story", + filter: false, + countDownloads: `path:"cvlm_llama2_tokenizer/tokenizer.model"`, + snippets: snippets.seed_story, + }, + soloaudio: { + prettyLabel: "SoloAudio", + repoName: "SoloAudio", + repoUrl: "https://github.com/WangHelin1997/SoloAudio", + filter: false, + countDownloads: `path:"soloaudio_v2.pt"`, + }, + songbloom: { + prettyLabel: "SongBloom", + repoName: "SongBloom", + repoUrl: "https://github.com/Cypress-Yang/SongBloom", + filter: false, + countDownloads: `path_extension:"pt"`, + }, + "stable-baselines3": { + prettyLabel: "stable-baselines3", + repoName: "stable-baselines3", + repoUrl: "https://github.com/huggingface/huggingface_sb3", + docsUrl: "https://huggingface.co/docs/hub/stable-baselines3", + snippets: snippets.stableBaselines3, + filter: true, + countDownloads: `path_extension:"zip"`, + }, + stanza: { + prettyLabel: "Stanza", + repoName: "stanza", + repoUrl: "https://github.com/stanfordnlp/stanza", + docsUrl: "https://huggingface.co/docs/hub/stanza", + snippets: snippets.stanza, + filter: true, + countDownloads: `path:"models/default.zip"`, + }, + supertonic: { + prettyLabel: "Supertonic", + repoName: "Supertonic", + repoUrl: "https://github.com/supertone-inc/supertonic", + snippets: snippets.supertonic, + filter: false, + }, + swarmformer: { + prettyLabel: "SwarmFormer", + repoName: "SwarmFormer", + repoUrl: "https://github.com/takara-ai/SwarmFormer", + snippets: snippets.swarmformer, + filter: false, + }, + "f5-tts": { + prettyLabel: "F5-TTS", + repoName: "F5-TTS", + repoUrl: "https://github.com/SWivid/F5-TTS", + filter: false, + countDownloads: `path_extension:"safetensors" OR path_extension:"pt"`, + }, + genmo: { + prettyLabel: "Genmo", + repoName: "Genmo", + repoUrl: "https://github.com/genmoai/models", + filter: false, + countDownloads: `path:"vae_stats.json"`, + }, + "tencent-song-generation": { + prettyLabel: "SongGeneration", + repoName: "SongGeneration", + repoUrl: "https://github.com/tencent-ailab/songgeneration", + filter: false, + countDownloads: `path:"ckpt/songgeneration_base/model.pt"`, + }, + tensorflowtts: { + prettyLabel: "TensorFlowTTS", + repoName: "TensorFlowTTS", + repoUrl: "https://github.com/TensorSpeech/TensorFlowTTS", + snippets: snippets.tensorflowtts, + }, + tensorrt: { + prettyLabel: "TensorRT", + repoName: "TensorRT", + repoUrl: "https://github.com/NVIDIA/TensorRT", + countDownloads: `path_extension:"onnx"`, + }, + tabpfn: { + prettyLabel: "TabPFN", + repoName: "TabPFN", + repoUrl: "https://github.com/PriorLabs/TabPFN", + }, + terratorch: { + prettyLabel: "TerraTorch", + repoName: "TerraTorch", + repoUrl: "https://github.com/IBM/terratorch", + docsUrl: "https://ibm.github.io/terratorch/", + filter: false, + countDownloads: `path_extension:"pt" OR path_extension:"ckpt"`, + snippets: snippets.terratorch, + }, + "tic-clip": { + prettyLabel: "TiC-CLIP", + repoName: "TiC-CLIP", + repoUrl: "https://github.com/apple/ml-tic-clip", + filter: false, + countDownloads: `path_extension:"pt" AND path_prefix:"checkpoints/"`, + }, + timesfm: { + prettyLabel: "TimesFM", + repoName: "timesfm", + repoUrl: "https://github.com/google-research/timesfm", + filter: false, + countDownloads: `path:"checkpoints/checkpoint_1100000/state/checkpoint" OR path:"checkpoints/checkpoint_2150000/state/checkpoint" OR path_extension:"ckpt"`, + }, + timm: { + prettyLabel: "timm", + repoName: "pytorch-image-models", + repoUrl: "https://github.com/rwightman/pytorch-image-models", + docsUrl: "https://huggingface.co/docs/hub/timm", + snippets: snippets.timm, + filter: true, + countDownloads: `path:"pytorch_model.bin" OR path:"model.safetensors"`, + }, + tirex: { + prettyLabel: "TiRex", + repoName: "TiRex", + repoUrl: "https://github.com/NX-AI/tirex", + countDownloads: `path_extension:"ckpt"`, + }, + torchgeo: { + prettyLabel: "TorchGeo", + repoName: "TorchGeo", + repoUrl: "https://github.com/microsoft/torchgeo", + docsUrl: "https://torchgeo.readthedocs.io/", + filter: false, + countDownloads: `path_extension:"pt" OR path_extension:"pth"`, + }, + transformers: { + prettyLabel: "Transformers", + repoName: "🤗/transformers", + repoUrl: "https://github.com/huggingface/transformers", + docsUrl: "https://huggingface.co/docs/hub/transformers", + snippets: snippets.transformers, + filter: true, + }, + "transformers.js": { + prettyLabel: "Transformers.js", + repoName: "transformers.js", + repoUrl: "https://github.com/huggingface/transformers.js", + docsUrl: "https://huggingface.co/docs/hub/transformers-js", + snippets: snippets.transformersJS, + filter: true, + }, + trellis: { + prettyLabel: "Trellis", + repoName: "Trellis", + repoUrl: "https://github.com/microsoft/TRELLIS", + countDownloads: `path_extension:"safetensors"`, + }, + ultralytics: { + prettyLabel: "ultralytics", + repoName: "ultralytics", + repoUrl: "https://github.com/ultralytics/ultralytics", + docsUrl: "https://github.com/ultralytics/ultralytics", + filter: false, + countDownloads: `path_extension:"pt"`, + snippets: snippets.ultralytics, + }, + univa: { + prettyLabel: "univa", + repoName: "univa", + repoUrl: "https://github.com/PKU-YuanGroup/UniWorld-V1", + snippets: snippets.univa, + filter: true, + countDownloads: `path:"config.json"`, + }, + "uni-3dar": { + prettyLabel: "Uni-3DAR", + repoName: "Uni-3DAR", + repoUrl: "https://github.com/dptech-corp/Uni-3DAR", + docsUrl: "https://github.com/dptech-corp/Uni-3DAR", + countDownloads: `path_extension:"pt"`, + }, + "unity-sentis": { + prettyLabel: "unity-sentis", + repoName: "unity-sentis", + repoUrl: "https://github.com/Unity-Technologies/sentis-samples", + snippets: snippets.sentis, + filter: true, + countDownloads: `path_extension:"sentis"`, + }, + sana: { + prettyLabel: "Sana", + repoName: "Sana", + repoUrl: "https://github.com/NVlabs/Sana", + countDownloads: `path_extension:"pth"`, + snippets: snippets.sana, + }, + videoprism: { + prettyLabel: "VideoPrism", + repoName: "VideoPrism", + repoUrl: "https://github.com/google-deepmind/videoprism", + countDownloads: `path_extension:"npz"`, + snippets: snippets.videoprism, + }, + "vfi-mamba": { + prettyLabel: "VFIMamba", + repoName: "VFIMamba", + repoUrl: "https://github.com/MCG-NJU/VFIMamba", + countDownloads: `path_extension:"pkl"`, + snippets: snippets.vfimamba, + }, + vismatch: { + prettyLabel: "VisMatch", + repoName: "VisMatch", + repoUrl: "https://github.com/gmberton/vismatch", + filter: false, + countDownloads: `path:"vismatch.yaml"`, + }, + lvface: { + prettyLabel: "LVFace", + repoName: "LVFace", + repoUrl: "https://github.com/bytedance/LVFace", + countDownloads: `path_extension:"pt" OR path_extension:"onnx"`, + snippets: snippets.lvface, + }, + voicecraft: { + prettyLabel: "VoiceCraft", + repoName: "VoiceCraft", + repoUrl: "https://github.com/jasonppy/VoiceCraft", + docsUrl: "https://github.com/jasonppy/VoiceCraft", + snippets: snippets.voicecraft, + }, + voxcpm: { + prettyLabel: "VoxCPM", + repoName: "VoxCPM", + repoUrl: "https://github.com/OpenBMB/VoxCPM", + snippets: snippets.voxcpm, + filter: false, + }, + vui: { + prettyLabel: "Vui", + repoName: "Vui", + repoUrl: "https://github.com/vui-ai/vui", + countDownloads: `path_extension:"pt"`, + snippets: snippets.vui, + }, + vibevoice: { + prettyLabel: "VibeVoice", + repoName: "VibeVoice", + repoUrl: "https://github.com/microsoft/VibeVoice", + snippets: snippets.vibevoice, + filter: false, + }, + videox_fun: { + prettyLabel: "VideoX Fun", + repoName: "VideoX Fun", + repoUrl: "https://github.com/aigc-apps/VideoX-Fun", + filter: false, + countDownloads: `path_extension:"safetensors"`, + }, + "wan2.2": { + prettyLabel: "Wan2.2", + repoName: "Wan2.2", + repoUrl: "https://github.com/Wan-Video/Wan2.2", + countDownloads: `path_filename:"config" AND path_extension:"json"`, + }, + wham: { + prettyLabel: "WHAM", + repoName: "wham", + repoUrl: "https://huggingface.co/microsoft/wham", + docsUrl: "https://huggingface.co/microsoft/wham/blob/main/README.md", + countDownloads: `path_extension:"ckpt"`, + }, + whisperkit: { + prettyLabel: "WhisperKit", + repoName: "WhisperKit", + repoUrl: "https://github.com/argmaxinc/WhisperKit", + docsUrl: "https://github.com/argmaxinc/WhisperKit?tab=readme-ov-file#homebrew", + snippets: snippets.whisperkit, + countDownloads: `path_filename:"model" AND path_extension:"mil" AND _exists_:"path_prefix"`, + }, + yolov10: { + // YOLOv10 is a fork of ultraLytics. Code snippets and download count are the same but the repo is different. + prettyLabel: "YOLOv10", + repoName: "YOLOv10", + repoUrl: "https://github.com/THU-MIG/yolov10", + docsUrl: "https://github.com/THU-MIG/yolov10", + countDownloads: `path_extension:"pt" OR path_extension:"safetensors"`, + snippets: snippets.ultralytics, + }, + yolov26: { + prettyLabel: "YOLOv26", + repoName: "YOLOv26", + repoUrl: "https://github.com/ultralytics/ultralytics", + docsUrl: "https://docs.ultralytics.com/models/yolo26/", + countDownloads: `path_extension:"pt" OR path_extension:"safetensors"`, + }, + zonos: { + prettyLabel: "Zonos", + repoName: "Zonos", + repoUrl: "https://github.com/Zyphra/Zonos", + docsUrl: "https://github.com/Zyphra/Zonos", + snippets: snippets.zonos, + filter: false, + }, + "3dtopia-xl": { + prettyLabel: "3DTopia-XL", + repoName: "3DTopia-XL", + repoUrl: "https://github.com/3DTopia/3DTopia-XL", + filter: false, + countDownloads: `path:"model_vae_fp16.pt"`, + snippets: snippets.threedtopia_xl, + }, +} satisfies Record; + +export type ModelLibraryKey = keyof typeof MODEL_LIBRARIES_UI_ELEMENTS; + +export const ALL_MODEL_LIBRARY_KEYS = Object.keys(MODEL_LIBRARIES_UI_ELEMENTS) as ModelLibraryKey[]; + +export const ALL_DISPLAY_MODEL_LIBRARY_KEYS = ( + Object.entries(MODEL_LIBRARIES_UI_ELEMENTS as Record) as [ + ModelLibraryKey, + LibraryUiElement, + ][] +) + // eslint-disable-next-line @typescript-eslint/no-unused-vars + .filter(([_, v]) => v.filter) + .map(([k]) => k); diff --git a/node_modules/@huggingface/tasks/src/pipelines.ts b/node_modules/@huggingface/tasks/src/pipelines.ts new file mode 100644 index 0000000000000000000000000000000000000000..36c9c90fcad11941c485ae829cd86b398e29ac56 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/pipelines.ts @@ -0,0 +1,664 @@ +export const MODALITIES = ["multimodal", "nlp", "cv", "audio", "tabular", "rl", "other"] as const; + +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; + +/** + * Public interface for a sub task. + * + * This can be used in a model card's `model-index` metadata. + * and is more granular classification that can grow significantly + * over time as new tasks are added. + */ +export interface SubTask { + /** + * type of the task (e.g. audio-source-separation) + */ + type: string; + /** + * displayed name of the task (e.g. Audio Source Separation) + */ + name: string; +} + +/** + * Public interface for a PipelineData. + * + * This information corresponds to a pipeline type (aka task) + * in the Hub. + */ +export interface PipelineData { + /** + * displayed name of the task (e.g. Text Classification) + */ + name: string; + subtasks?: SubTask[]; + modality: Modality; + /** + * whether to hide in /models filters + */ + hideInModels?: boolean; + /** + * whether to hide in /datasets filters + */ + hideInDatasets?: boolean; +} + +/// Coarse-grained taxonomy of tasks +/// +/// This type is used in multiple places in the Hugging Face +/// ecosystem: +/// - To determine which widget to show. +/// - To determine which endpoint of Inference Endpoints to use. +/// - As filters at the left of models and datasets page. +/// +/// Note that this is sensitive to order. +/// For each domain, the order should be of decreasing specificity. +/// This will impact the default pipeline tag of a model when not +/// specified. +export const PIPELINE_DATA = { + "text-classification": { + name: "Text Classification", + subtasks: [ + { + type: "acceptability-classification", + name: "Acceptability Classification", + }, + { + type: "entity-linking-classification", + name: "Entity Linking Classification", + }, + { + type: "fact-checking", + name: "Fact Checking", + }, + { + type: "intent-classification", + name: "Intent Classification", + }, + { + type: "language-identification", + name: "Language Identification", + }, + { + type: "multi-class-classification", + name: "Multi Class Classification", + }, + { + type: "multi-label-classification", + name: "Multi Label Classification", + }, + { + type: "multi-input-text-classification", + name: "Multi-input Text Classification", + }, + { + type: "natural-language-inference", + name: "Natural Language Inference", + }, + { + type: "semantic-similarity-classification", + name: "Semantic Similarity Classification", + }, + { + type: "sentiment-classification", + name: "Sentiment Classification", + }, + { + type: "topic-classification", + name: "Topic Classification", + }, + { + type: "semantic-similarity-scoring", + name: "Semantic Similarity Scoring", + }, + { + type: "sentiment-scoring", + name: "Sentiment Scoring", + }, + { + type: "sentiment-analysis", + name: "Sentiment Analysis", + }, + { + type: "hate-speech-detection", + name: "Hate Speech Detection", + }, + { + type: "text-scoring", + name: "Text Scoring", + }, + ], + modality: "nlp", + }, + "token-classification": { + name: "Token Classification", + subtasks: [ + { + type: "named-entity-recognition", + name: "Named Entity Recognition", + }, + { + type: "part-of-speech", + name: "Part of Speech", + }, + { + type: "parsing", + name: "Parsing", + }, + { + type: "lemmatization", + name: "Lemmatization", + }, + { + type: "word-sense-disambiguation", + name: "Word Sense Disambiguation", + }, + { + type: "coreference-resolution", + name: "Coreference-resolution", + }, + ], + modality: "nlp", + }, + "table-question-answering": { + name: "Table Question Answering", + modality: "nlp", + }, + "question-answering": { + name: "Question Answering", + subtasks: [ + { + type: "extractive-qa", + name: "Extractive QA", + }, + { + type: "open-domain-qa", + name: "Open Domain QA", + }, + { + type: "closed-domain-qa", + name: "Closed Domain QA", + }, + ], + modality: "nlp", + }, + "zero-shot-classification": { + name: "Zero-Shot Classification", + modality: "nlp", + }, + translation: { + name: "Translation", + modality: "nlp", + }, + summarization: { + name: "Summarization", + subtasks: [ + { + type: "news-articles-summarization", + name: "News Articles Summarization", + }, + { + type: "news-articles-headline-generation", + name: "News Articles Headline Generation", + }, + ], + modality: "nlp", + }, + "feature-extraction": { + name: "Feature Extraction", + modality: "nlp", + }, + "text-generation": { + name: "Text Generation", + subtasks: [ + { + type: "dialogue-modeling", + name: "Dialogue Modeling", + }, + { + type: "dialogue-generation", + name: "Dialogue Generation", + }, + { + type: "conversational", + name: "Conversational", + }, + { + type: "language-modeling", + name: "Language Modeling", + }, + { + type: "text-simplification", + name: "Text simplification", + }, + { + type: "explanation-generation", + name: "Explanation Generation", + }, + { + type: "abstractive-qa", + name: "Abstractive QA", + }, + { + type: "open-domain-abstractive-qa", + name: "Open Domain Abstractive QA", + }, + { + type: "closed-domain-qa", + name: "Closed Domain QA", + }, + { + type: "open-book-qa", + name: "Open Book QA", + }, + { + type: "closed-book-qa", + name: "Closed Book QA", + }, + { + type: "text2text-generation", + name: "Text2Text Generation", + }, + ], + modality: "nlp", + }, + "fill-mask": { + name: "Fill-Mask", + subtasks: [ + { + type: "slot-filling", + name: "Slot Filling", + }, + { + type: "masked-language-modeling", + name: "Masked Language Modeling", + }, + ], + modality: "nlp", + }, + "sentence-similarity": { + name: "Sentence Similarity", + modality: "nlp", + }, + "text-to-speech": { + name: "Text-to-Speech", + modality: "audio", + }, + "text-to-audio": { + name: "Text-to-Audio", + modality: "audio", + }, + "automatic-speech-recognition": { + name: "Automatic Speech Recognition", + modality: "audio", + }, + "audio-to-audio": { + name: "Audio-to-Audio", + modality: "audio", + }, + "audio-classification": { + name: "Audio Classification", + subtasks: [ + { + type: "keyword-spotting", + name: "Keyword Spotting", + }, + { + type: "speaker-identification", + name: "Speaker Identification", + }, + { + type: "audio-intent-classification", + name: "Audio Intent Classification", + }, + { + type: "audio-emotion-recognition", + name: "Audio Emotion Recognition", + }, + { + type: "audio-language-identification", + name: "Audio Language Identification", + }, + ], + modality: "audio", + }, + "audio-text-to-text": { + name: "Audio-Text-to-Text", + modality: "multimodal", + hideInDatasets: true, + }, + "voice-activity-detection": { + name: "Voice Activity Detection", + modality: "audio", + }, + "depth-estimation": { + name: "Depth Estimation", + modality: "cv", + }, + "image-classification": { + name: "Image Classification", + subtasks: [ + { + type: "multi-label-image-classification", + name: "Multi Label Image Classification", + }, + { + type: "multi-class-image-classification", + name: "Multi Class Image Classification", + }, + ], + modality: "cv", + }, + "object-detection": { + name: "Object Detection", + subtasks: [ + { + type: "face-detection", + name: "Face Detection", + }, + { + type: "vehicle-detection", + name: "Vehicle Detection", + }, + ], + modality: "cv", + }, + "image-segmentation": { + name: "Image Segmentation", + subtasks: [ + { + type: "instance-segmentation", + name: "Instance Segmentation", + }, + { + type: "semantic-segmentation", + name: "Semantic Segmentation", + }, + { + type: "panoptic-segmentation", + name: "Panoptic Segmentation", + }, + ], + modality: "cv", + }, + "text-to-image": { + name: "Text-to-Image", + modality: "cv", + }, + "image-to-text": { + name: "Image-to-Text", + subtasks: [ + { + type: "image-captioning", + name: "Image Captioning", + }, + ], + modality: "cv", + }, + "image-to-image": { + name: "Image-to-Image", + subtasks: [ + { + type: "image-inpainting", + name: "Image Inpainting", + }, + { + type: "image-colorization", + name: "Image Colorization", + }, + { + type: "super-resolution", + name: "Super Resolution", + }, + ], + modality: "cv", + }, + "image-to-video": { + name: "Image-to-Video", + modality: "cv", + }, + "unconditional-image-generation": { + name: "Unconditional Image Generation", + modality: "cv", + }, + "video-classification": { + name: "Video Classification", + modality: "cv", + }, + "reinforcement-learning": { + name: "Reinforcement Learning", + modality: "rl", + }, + robotics: { + name: "Robotics", + modality: "rl", + subtasks: [ + { + type: "grasping", + name: "Grasping", + }, + { + type: "task-planning", + name: "Task Planning", + }, + ], + }, + "tabular-classification": { + name: "Tabular Classification", + modality: "tabular", + subtasks: [ + { + type: "tabular-multi-class-classification", + name: "Tabular Multi Class Classification", + }, + { + type: "tabular-multi-label-classification", + name: "Tabular Multi Label Classification", + }, + ], + }, + "tabular-regression": { + name: "Tabular Regression", + modality: "tabular", + subtasks: [ + { + type: "tabular-single-column-regression", + name: "Tabular Single Column Regression", + }, + ], + }, + "tabular-to-text": { + name: "Tabular to Text", + modality: "tabular", + subtasks: [ + { + type: "rdf-to-text", + name: "RDF to text", + }, + ], + hideInModels: true, + }, + "table-to-text": { + name: "Table to Text", + modality: "nlp", + hideInModels: true, + }, + "multiple-choice": { + name: "Multiple Choice", + subtasks: [ + { + type: "multiple-choice-qa", + name: "Multiple Choice QA", + }, + { + type: "multiple-choice-coreference-resolution", + name: "Multiple Choice Coreference Resolution", + }, + ], + modality: "nlp", + hideInModels: true, + }, + "text-ranking": { + name: "Text Ranking", + modality: "nlp", + }, + "text-retrieval": { + name: "Text Retrieval", + subtasks: [ + { + type: "document-retrieval", + name: "Document Retrieval", + }, + { + type: "utterance-retrieval", + name: "Utterance Retrieval", + }, + { + type: "entity-linking-retrieval", + name: "Entity Linking Retrieval", + }, + { + type: "fact-checking-retrieval", + name: "Fact Checking Retrieval", + }, + ], + modality: "nlp", + hideInModels: true, + }, + "time-series-forecasting": { + name: "Time Series Forecasting", + modality: "tabular", + subtasks: [ + { + type: "univariate-time-series-forecasting", + name: "Univariate Time Series Forecasting", + }, + { + type: "multivariate-time-series-forecasting", + name: "Multivariate Time Series Forecasting", + }, + ], + }, + "text-to-video": { + name: "Text-to-Video", + modality: "cv", + }, + "image-text-to-text": { + name: "Image-Text-to-Text", + modality: "multimodal", + }, + "image-text-to-image": { + name: "Image-Text-to-Image", + modality: "multimodal", + }, + "image-text-to-video": { + name: "Image-Text-to-Video", + modality: "multimodal", + }, + "visual-question-answering": { + name: "Visual Question Answering", + subtasks: [ + { + type: "visual-question-answering", + name: "Visual Question Answering", + }, + ], + modality: "multimodal", + }, + "document-question-answering": { + name: "Document Question Answering", + subtasks: [ + { + type: "document-question-answering", + name: "Document Question Answering", + }, + ], + modality: "multimodal", + hideInDatasets: true, + }, + "zero-shot-image-classification": { + name: "Zero-Shot Image Classification", + modality: "cv", + }, + "graph-ml": { + name: "Graph Machine Learning", + modality: "other", + }, + "mask-generation": { + name: "Mask Generation", + modality: "cv", + }, + "zero-shot-object-detection": { + name: "Zero-Shot Object Detection", + modality: "cv", + }, + "text-to-3d": { + name: "Text-to-3D", + modality: "cv", + }, + "image-to-3d": { + name: "Image-to-3D", + modality: "cv", + }, + "image-feature-extraction": { + name: "Image Feature Extraction", + modality: "cv", + }, + "video-text-to-text": { + name: "Video-Text-to-Text", + modality: "multimodal", + hideInDatasets: false, + }, + "keypoint-detection": { + name: "Keypoint Detection", + subtasks: [ + { + type: "pose-estimation", + name: "Pose Estimation", + }, + ], + modality: "cv", + hideInDatasets: true, + }, + "visual-document-retrieval": { + name: "Visual Document Retrieval", + modality: "multimodal", + }, + "any-to-any": { + name: "Any-to-Any", + modality: "multimodal", + }, + "video-to-video": { + name: "Video-to-Video", + modality: "cv", + hideInDatasets: true, + }, + other: { + name: "Other", + modality: "other", + hideInModels: true, + hideInDatasets: true, + }, +} satisfies Record; + +export type PipelineType = keyof typeof PIPELINE_DATA; + +export type WidgetType = PipelineType | "conversational"; + +export const PIPELINE_TYPES = Object.keys(PIPELINE_DATA) as PipelineType[]; + +export const SUBTASK_TYPES = Object.values(PIPELINE_DATA) + .flatMap((data) => ("subtasks" in data ? data.subtasks : [])) + .map((s) => s.type); + +export const PIPELINE_TYPES_SET = new Set(PIPELINE_TYPES); diff --git a/node_modules/@huggingface/tasks/src/snippets/common.ts b/node_modules/@huggingface/tasks/src/snippets/common.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b325d35f7571276741cfab9bfb3f802d99f5d8a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/snippets/common.ts @@ -0,0 +1,39 @@ +import type { ChatCompletionInputMessage, GenerationParameters } from "../tasks/index.js"; + +export function stringifyMessages( + messages: ChatCompletionInputMessage[], + opts?: { + indent?: string; + attributeKeyQuotes?: boolean; + customContentEscaper?: (str: string) => string; + }, +): string { + let messagesStr = JSON.stringify(messages, null, "\t"); + if (opts?.indent) { + messagesStr = messagesStr.replaceAll("\n", `\n${opts.indent}`); + } + if (!opts?.attributeKeyQuotes) { + messagesStr = messagesStr.replace(/"([^"]+)":/g, "$1:"); + } + if (opts?.customContentEscaper) { + messagesStr = opts.customContentEscaper(messagesStr); + } + return messagesStr; +} + +type PartialGenerationParameters = Partial>; + +export function stringifyGenerationConfig( + config: PartialGenerationParameters, + opts: { + indent: string; + attributeValueConnector: string; + attributeKeyQuotes?: boolean; + }, +): string { + const quote = opts.attributeKeyQuotes ? `"` : ""; + + return Object.entries(config) + .map(([key, val]) => `${quote}${key}${quote}${opts.attributeValueConnector}${val},`) + .join(`${opts.indent}`); +} diff --git a/node_modules/@huggingface/tasks/src/snippets/index.ts b/node_modules/@huggingface/tasks/src/snippets/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd77dfd5213a3c73a1514ec0d14c87093b5bfb52 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/snippets/index.ts @@ -0,0 +1,3 @@ +export * from "./common.js"; +export * from "./inputs.js"; +export * from "./types.js"; diff --git a/node_modules/@huggingface/tasks/src/snippets/inputs.ts b/node_modules/@huggingface/tasks/src/snippets/inputs.ts new file mode 100644 index 0000000000000000000000000000000000000000..cffcde67adf7295b5ceae4dfca727eb8503fdd10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/snippets/inputs.ts @@ -0,0 +1,191 @@ +import type { PipelineType } from "../pipelines.js"; +import type { ChatCompletionInputMessage } from "../tasks/index.js"; +import type { ModelDataMinimal } from "./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!"`; + +const inputsTranslation = () => `"Меня зовут Вольфганг и я живу в Берлине"`; + +const inputsSummarization = () => + `"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."`; + +const inputsTableQuestionAnswering = () => + `{ + "query": "How many stars does the transformers repository have?", + "table": { + "Repository": ["Transformers", "Datasets", "Tokenizers"], + "Stars": ["36542", "4512", "3934"], + "Contributors": ["651", "77", "34"], + "Programming language": [ + "Python", + "Python", + "Rust, Python and NodeJS" + ] + } +}`; + +const inputsVisualQuestionAnswering = () => + `{ + "image": "cat.png", + "question": "What is in this image?" + }`; + +const inputsQuestionAnswering = () => + `{ + "question": "What is my name?", + "context": "My name is Clara and I live in Berkeley." +}`; + +const inputsTextClassification = () => `"I like you. I love you"`; + +const inputsTokenClassification = () => `"My name is Sarah Jessica Parker but you can call me Jessica"`; + +const inputsTextGeneration = (model: ModelDataMinimal): string | ChatCompletionInputMessage[] => { + if (model.tags.includes("conversational")) { + return model.pipeline_tag === "text-generation" + ? [{ role: "user", content: "What is the capital of France?" }] + : [ + { + role: "user", + content: [ + { + type: "text", + text: "Describe this image in one sentence.", + }, + { + type: "image_url", + image_url: { + url: "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg", + }, + }, + ], + }, + ]; + } + return `"Can you please let us know more details about your "`; +}; + +const inputsFillMask = (model: ModelDataMinimal) => `"The answer to the universe is ${model.mask_token}."`; + +const inputsSentenceSimilarity = () => + `{ + "source_sentence": "That is a happy person", + "sentences": [ + "That is a happy dog", + "That is a very happy person", + "Today is a sunny day" + ] +}`; + +const inputsFeatureExtraction = () => `"Today is a sunny day and I will get some ice cream."`; + +const inputsImageClassification = () => `"cats.jpg"`; + +const inputsImageToText = () => `"cats.jpg"`; + +const inputsImageToImage = () => `{ + "image": "cat.png", + "prompt": "Turn the cat into a tiger." +}`; + +const inputsImageToVideo = () => `{ + "image": "cat.png", + "prompt": "The cat starts to dance" +}`; + +const inputsImageTextToImage = () => `{ + "image": "cat.png", + "prompt": "Turn the cat into a tiger." +}`; + +const inputsImageTextToVideo = () => `{ + "image": "cat.png", + "prompt": "The cat starts to dance" +}`; + +const inputsImageSegmentation = () => `"cats.jpg"`; + +const inputsObjectDetection = () => `"cats.jpg"`; + +const inputsAudioToAudio = () => `"sample1.flac"`; + +const inputsAudioClassification = () => `"sample1.flac"`; + +const inputsTextToImage = () => `"Astronaut riding a horse"`; + +const inputsTextToVideo = () => `"A young man walking on the street"`; + +const inputsTextToSpeech = () => `"The answer to the universe is 42"`; + +const inputsTextToAudio = () => `"liquid drum and bass, atmospheric synths, airy sounds"`; + +const inputsAutomaticSpeechRecognition = () => `"sample1.flac"`; + +const inputsTabularPrediction = () => + `'{"Height":[11.52,12.48],"Length1":[23.2,24.0],"Length2":[25.4,26.3],"Species": ["Bream","Bream"]}'`; + +const inputsZeroShotImageClassification = () => `"cats.jpg"`; + +const modelInputSnippets: { + [key in PipelineType]?: (model: ModelDataMinimal) => string | ChatCompletionInputMessage[]; +} = { + "audio-to-audio": inputsAudioToAudio, + "audio-classification": inputsAudioClassification, + "automatic-speech-recognition": inputsAutomaticSpeechRecognition, + "document-question-answering": inputsVisualQuestionAnswering, + "feature-extraction": inputsFeatureExtraction, + "fill-mask": inputsFillMask, + "image-classification": inputsImageClassification, + "image-to-text": inputsImageToText, + "image-to-image": inputsImageToImage, + "image-to-video": inputsImageToVideo, + "image-text-to-image": inputsImageTextToImage, + "image-text-to-video": inputsImageTextToVideo, + "image-segmentation": inputsImageSegmentation, + "object-detection": inputsObjectDetection, + "question-answering": inputsQuestionAnswering, + "sentence-similarity": inputsSentenceSimilarity, + summarization: inputsSummarization, + "table-question-answering": inputsTableQuestionAnswering, + "tabular-regression": inputsTabularPrediction, + "tabular-classification": inputsTabularPrediction, + "text-classification": inputsTextClassification, + "text-generation": inputsTextGeneration, + "image-text-to-text": inputsTextGeneration, + "text-to-image": inputsTextToImage, + "text-to-video": inputsTextToVideo, + "text-to-speech": inputsTextToSpeech, + "text-to-audio": inputsTextToAudio, + "token-classification": inputsTokenClassification, + translation: inputsTranslation, + "zero-shot-classification": inputsZeroShotClassification, + "zero-shot-image-classification": inputsZeroShotImageClassification, +}; + +// Use noWrap to put the whole snippet on a single line (removing new lines and tabulations) +// Use noQuotes to strip quotes from start & end (example: "abc" -> abc) +export function getModelInputSnippet( + model: ModelDataMinimal, + noWrap = false, + noQuotes = false, +): string | ChatCompletionInputMessage[] { + if (model.pipeline_tag) { + const inputs = modelInputSnippets[model.pipeline_tag]; + if (inputs) { + let result = inputs(model); + if (typeof result === "string") { + if (noWrap) { + result = result.replace(/(?:(?:\r?\n|\r)\t*)|\t+/g, " "); + } + if (noQuotes) { + const REGEX_QUOTES = /^"(.+)"$/s; + const match = result.match(REGEX_QUOTES); + result = match ? match[1] : result; + } + } + return result; + } + } + return "No input example has been defined for this model task."; +} diff --git a/node_modules/@huggingface/tasks/src/snippets/types.ts b/node_modules/@huggingface/tasks/src/snippets/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..22400d3ae11adf9f1eaa5f71dada70056e4a51e8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/snippets/types.ts @@ -0,0 +1,21 @@ +import type { ModelData } from "../model-data.js"; + +/** + * Minimal model data required for snippets. + * + * Add more fields as needed. + */ +export type ModelDataMinimal = Pick< + ModelData, + "id" | "pipeline_tag" | "mask_token" | "library_name" | "config" | "tags" | "inference" +>; + +// Order of the elements in InferenceModal.svelte is determined by this const +export const inferenceSnippetLanguages = ["python", "js", "sh"] as const; +export type InferenceSnippetLanguage = (typeof inferenceSnippetLanguages)[number]; + +export interface InferenceSnippet { + language: InferenceSnippetLanguage; // e.g. `python`, `curl`, `js` + client: string; // e.g. `huggingface_hub`, `openai`, `fetch`, etc. + content: string; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/any-to-any/about.md b/node_modules/@huggingface/tasks/src/tasks/any-to-any/about.md new file mode 100644 index 0000000000000000000000000000000000000000..6e7c42430ad76f75966ae1b5f57640f3fd6452dc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/any-to-any/about.md @@ -0,0 +1,71 @@ +## Use Cases + +### Embodied Agents + +Any-to-any models can help embodied agents operate in multi-sensory environments, such as video games or physical robots. The model can take in an image or video of a scene, text prompts, and audio, and respond by generating text, actions, predict next frames, or generate speech commands. + +### Real-time Accessibility Systems + +Vision-language based any-to-any models can be used to aid visually impaired people. A real-time on-device any-to-any model can take a real-world video stream from wearable glasses, and describe the scene in audio (e.g., "A person in a red coat is walking toward you"), or provide real-time closed captions and environmental sound cues. + +### Multimodal Content Creation + +One can use any-to-any models to generate multimodal content. For example, given a video and an outline, the model can generate speech, better videos, or a descriptive blog post. Moreover, these models can sync narration timing with visual transitions. + +## Inference + +You can infer with any-to-any models using transformers. Below is an example that passes a video as part of a chat conversation to the Qwen2.5-Omni-7B model, and retrieves text and audio responses. Make sure to check the model you're inferring with. + +```python +import soundfile as sf +from transformers import Qwen2_5OmniForConditionalGeneration, Qwen2_5OmniProcessor + +model = Qwen2_5OmniForConditionalGeneration.from_pretrained( + "Qwen/Qwen2.5-Omni-7B", + torch_dtype="auto", + device_map="auto", + attn_implementation="flash_attention_2", +) +processor = Qwen2_5OmniProcessor.from_pretrained("Qwen/Qwen2.5-Omni-7B") + +conversation = [ + { + "role": "system", + "content": [ + {"type": "text", "text": "You are Qwen, a virtual human developed by the Qwen Team, Alibaba Group, capable of perceiving auditory and visual inputs, as well as generating text and speech."} + ], + }, + { + "role": "user", + "content": [ + {"type": "video", "video": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2.5-Omni/draw.mp4"}, + {"type": "text", "text": "What can you hear and see in this video?"}, + ], + }, +] + +inputs = processor.apply_chat_template( + conversation, + load_audio_from_video=True, + add_generation_prompt=True, + tokenize=True, + return_dict=True, + return_tensors="pt", + video_fps=2, + + # kwargs to be passed to `Qwen2-5-OmniProcessor` + padding=True, + use_audio_in_video=True, +) + +# Inference: Generation of the output text and audio +text_ids, audio = model.generate(**inputs, use_audio_in_video=True) + +text = processor.batch_decode(text_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False) +print(text) +sf.write( + "output.wav", + audio.reshape(-1).detach().cpu().numpy(), + samplerate=24000, +) +``` diff --git a/node_modules/@huggingface/tasks/src/tasks/any-to-any/data.ts b/node_modules/@huggingface/tasks/src/tasks/any-to-any/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c7351e545d29fb525d758c05ac2d6b32a9ba4d4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/any-to-any/data.ts @@ -0,0 +1,65 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A dataset with multiple modality input and output pairs.", + id: "PKU-Alignment/align-anything", + }, + ], + demo: { + inputs: [ + { + filename: "any-to-any-input.jpg", + type: "img", + }, + { + label: "Text Prompt", + content: "What is the significance of this place?", + type: "text", + }, + ], + outputs: [ + { + label: "Generated Text", + content: + "The place in the picture is Osaka Castle, located in Osaka, Japan. Osaka Castle is a historic castle that was originally built in the 16th century by Toyotomi Hideyoshi, a powerful warlord of the time. It is one of the most famous landmarks in Osaka and is known for its distinctive white walls and black roof tiles. The castle has been rebuilt several times over the centuries and is now a popular tourist attraction, offering visitors a glimpse into Japan's rich history and culture.", + type: "text", + }, + { + filename: "any-to-any-output.wav", + type: "audio", + }, + ], + }, + metrics: [], + models: [ + { + description: "Strong model that can take in video, audio, image, text and output text and natural speech.", + id: "Qwen/Qwen2.5-Omni-7B", + }, + { + description: "Robust model that can take in image and text and generate image and text.", + id: "OmniGen2/OmniGen2", + }, + { + description: "Any-to-any model with speech, video, audio, image and text understanding capabilities.", + id: "openbmb/MiniCPM-o-2_6", + }, + { + description: "A model that can understand image and text and generate image and text.", + id: "ByteDance-Seed/BAGEL-7B-MoT", + }, + ], + spaces: [ + { + description: "An application to chat with an any-to-any (image & text) model.", + id: "OmniGen2/OmniGen2", + }, + ], + summary: "Any-to-any models can understand two or more modalities and output two or more modalities.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/audio-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..dfeab08f05ba1c3b6b2040094bb254b26be93379 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-classification/about.md @@ -0,0 +1,86 @@ +## Use Cases + +### Command Recognition + +Command recognition or keyword spotting classifies utterances into a predefined set of commands. This is often done on-device for fast response time. + +As an example, using the Google Speech Commands dataset, given an input, a model can classify which of the following commands the user is typing: + +``` +'yes', 'no', 'up', 'down', 'left', 'right', 'on', 'off', 'stop', 'go', 'unknown', 'silence' +``` + +Speechbrain models can easily perform this task with just a couple of lines of code! + +```python +from speechbrain.pretrained import EncoderClassifier +model = EncoderClassifier.from_hparams( + "speechbrain/google_speech_command_xvector" +) +model.classify_file("file.wav") +``` + +### Language Identification + +Datasets such as VoxLingua107 allow anyone to train language identification models for up to 107 languages! This can be extremely useful as a preprocessing step for other systems. Here's an example [model](https://huggingface.co/TalTechNLP/voxlingua107-epaca-tdnn)trained on VoxLingua107. + +### Emotion recognition + +Emotion recognition is self explanatory. In addition to trying the widgets, you can use Inference Endpoints to perform audio classification. Here is a simple example that uses a [HuBERT](https://huggingface.co/superb/hubert-large-superb-er) model fine-tuned for this task. + +```python +import json +import requests + +headers = {"Authorization": f"Bearer {API_TOKEN}"} +API_URL = "https://router.huggingface.co/hf-inference/models/superb/hubert-large-superb-er" + +def query(filename): + with open(filename, "rb") as f: + data = f.read() + response = requests.request("POST", API_URL, headers=headers, data=data) + return json.loads(response.content.decode("utf-8")) + +data = query("sample1.flac") +# [{'label': 'neu', 'score': 0.60}, +# {'label': 'hap', 'score': 0.20}, +# {'label': 'ang', 'score': 0.13}, +# {'label': 'sad', 'score': 0.07}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer with audio classification models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.audioClassification({ + data: await (await fetch("sample.flac")).blob(), + model: "facebook/mms-lid-126", +}); +``` + +### Speaker Identification + +Speaker Identification is classifying the audio of the person speaking. Speakers are usually predefined. You can try out this task with [this model](https://huggingface.co/superb/wav2vec2-base-superb-sid). A useful dataset for this task is VoxCeleb1. + +## Solving audio classification for your own data + +We have some great news! You can do fine-tuning (transfer learning) to train a well-performing model without requiring as much data. Pretrained models such as Wav2Vec2 and HuBERT exist. [Facebook's Wav2Vec2 XLS-R model](https://huggingface.co/docs/transformers/model_doc/xlsr_wav2vec2) is a large multilingual model trained on 128 languages and with 436K hours of speech. Similarly, you can also use [OpenAI's Whisper](https://huggingface.co/docs/transformers/model_doc/whisper) trained on up to 4 Million hours of multilingual speech data for this task too! + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +### Notebooks + +- [PyTorch](https://colab.research.google.com/github/huggingface/notebooks/blob/master/examples/audio_classification.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/audio-classification) + +### Documentation + +- [Hugging Face Audio Course](https://huggingface.co/learn/audio-course/chapter4/introduction) +- [Audio classification task guide](https://huggingface.co/docs/transformers/tasks/audio_classification) diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/audio-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..8919f81c0eb0770fdbe91f10f40cd6e4e9b61047 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-classification/data.ts @@ -0,0 +1,81 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A benchmark of 10 different audio tasks.", + id: "s3prl/superb", + }, + { + description: "A dataset of YouTube clips and their sound categories.", + id: "agkphysics/AudioSet", + }, + ], + demo: { + inputs: [ + { + filename: "audio.wav", + type: "audio", + }, + ], + outputs: [ + { + data: [ + { + label: "Up", + score: 0.2, + }, + { + label: "Down", + score: 0.8, + }, + ], + type: "chart", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "An easy-to-use model for command recognition.", + id: "speechbrain/google_speech_command_xvector", + }, + { + description: "An emotion recognition model.", + id: "ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition", + }, + { + description: "A language identification model.", + id: "facebook/mms-lid-126", + }, + ], + spaces: [ + { + description: "An application that can classify music into different genre.", + id: "kurianbenoy/audioclassification", + }, + ], + summary: + "Audio classification is the task of assigning a label or class to a given audio. It can be used for recognizing which command a user is giving or the emotion of a statement, as well as identifying a speaker.", + widgetModels: ["MIT/ast-finetuned-audioset-10-10-0.4593"], + youtubeId: "KWwzcmG98Ds", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/audio-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a87b2e46c61aad7d73c704486e130a39d92566f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-classification/inference.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Audio Classification inference + */ +export interface AudioClassificationInput { + /** + * The input audio data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the audio data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Audio Classification + */ + parameters?: AudioClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Audio Classification + */ +export interface AudioClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type AudioClassificationOutput = AudioClassificationOutputElement[]; +/** + * Outputs for Audio Classification inference + */ +export interface AudioClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..df86e333b4f05aeb8f9268edb6c646d4b56fd03e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/input.json @@ -0,0 +1,36 @@ +{ + "$id": "/inference/schemas/audio-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Audio Classification inference", + "title": "AudioClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input audio data as a base64-encoded string. If no `parameters` are provided, you can also provide the audio data as a raw bytes payload.", + "type": "string", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Audio Classification", + "$ref": "#/$defs/AudioClassificationParameters" + } + }, + "$defs": { + "AudioClassificationParameters": { + "title": "AudioClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "AudioClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f1f2dfe8ef36519f30898d6ad5e6924112e5e860 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/audio-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "AudioClassificationOutput", + "description": "Outputs for Audio Classification inference", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..685385e25ce815731bacd5dd916deeccca7ea9a2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/about.md @@ -0,0 +1,139 @@ +## Use Cases + +> This task takes `audio` and a `text prompt` and returns `text` (answers, summaries, structured notes, etc.). + +### Audio question answering + +Ask targeted questions about lectures, podcasts, or calls and get context-aware answers. +**Example:** Audio: physics lecture → Prompt: “What did the teacher say about gravity and how is it measured?” + +### Meeting notes & action items + +Turn multi-speaker meetings into concise minutes with decisions, owners, and deadlines. +**Example:** Audio: weekly stand-up → Prompt: “Summarize key decisions and list action items with assignees.” + +### Speech understanding & intent + +Go beyond transcription to extract intent, sentiment, uncertainty, or emotion from spoken language. +**Example:** “I’m not sure I can finish this on time.” → Prompt: “Describe speaker intent and confidence.” + +### Music & sound analysis (textual) + +Describe instrumentation, genre, tempo, or sections, and suggest edits or techniques (text output only). +**Example:** Song demo → Prompt: “Identify key and tempo, then suggest jazz reharmonization ideas for the chorus.” + +## Inference + +You can use the 'transformers' library, and your audio file to any of the `audio-text-to-text` model, with instructions and get text responses. Following code examples show how to do so. + +### Speech Transcription and Analysis + +These models don’t just turn speech into text—they also capture tone, emotion, and speaker traits. This makes them useful for tasks like sentiment analysis or identifying speaker profiles. + +You can try audio transcription with [Voxtral Mini](https://huggingface.co/mistralai/Voxtral-Mini-3B-2507) using the following code. + +```python +from transformers import VoxtralForConditionalGeneration, AutoProcessor +import torch + +device = "cuda" +repo_id = "mistralai/Voxtral-Mini-3B-2507" + +processor = AutoProcessor.from_pretrained(repo_id) +model = VoxtralForConditionalGeneration.from_pretrained(repo_id, dtype=torch.bfloat16, device_map=device) + +inputs = processor.apply_transcription_request(language="en", audio="https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/obama.mp3", model_id=repo_id) +inputs = inputs.to(device, dtype=torch.bfloat16) + +outputs = model.generate(**inputs, max_new_tokens=500) +decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True) + +print("\nGenerated responses:") +print("=" * 80) +for decoded_output in decoded_outputs: + print(decoded_output) + print("=" * 80) +``` + +### Audio Question Answering + +These models can understand audio directly and answer questions about it. For example, summarizing a podcast clip or explaining parts of a recorded conversation. + +You can experiment with [Qwen2-Audio-Instruct-Demo](https://huggingface.co/Qwen/Qwen2-Audio-Instruct-Demo) for conversations with both text and audio inputs, letting you ask follow-up questions about different sounds or speech clips. + +```python +from io import BytesIO +from urllib.request import urlopen +import librosa +from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor + +processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct") +model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto") + +conversation = [ + {'role': 'system', 'content': 'You are a helpful assistant.'}, + {"role": "user", "content": [ + {"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/glass-breaking-151256.mp3"}, + {"type": "text", "text": "What's that sound?"}, + ]}, + {"role": "assistant", "content": "It is the sound of glass shattering."}, + {"role": "user", "content": [ + {"type": "text", "text": "What can you do when you hear that?"}, + ]}, + {"role": "assistant", "content": "Stay alert and cautious, and check if anyone is hurt or if there is any damage to property."}, + {"role": "user", "content": [ + {"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/1272-128104-0000.flac"}, + {"type": "text", "text": "What does the person say?"}, + ]}, +] +text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False) +audios = [] +for message in conversation: + if isinstance(message["content"], list): + for ele in message["content"]: + if ele["type"] == "audio": + audios.append( + librosa.load( + BytesIO(urlopen(ele['audio_url']).read()), + sr=processor.feature_extractor.sampling_rate)[0] + ) + +inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True) +inputs.input_ids = inputs.input_ids.to("cuda") + +generate_ids = model.generate(**inputs, max_length=256) +generate_ids = generate_ids[:, inputs.input_ids.size(1):] + +response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] +``` + +## Useful Resources + +If you want to learn more about this concept, here are some useful links: + +### Papers + +- [SpeechGPT](https://huggingface.co/papers/2507.13264) — multimodal dialogue with speech and text. +- [Voxtral](https://huggingface.co/papers/2507.13264) — a state-of-the-art audio-text model. +- [Qwen2-audio-instruct](https://huggingface.co/papers/2407.10759) — large-scale audio-language modeling for instruction following. +- [AudioPaLM](https://huggingface.co/papers/2306.12925) — scaling audio-language models with PaLM. + +### Models, Codes & Demos + +- [Qwen2-audio-instruct](https://github.com/QwenLM/Qwen2-Audio) — open-source implementation with demos. +- [SpeechGPT](https://github.com/0nutation/SpeechGPT) — An end-to-end framework for audio conversational models built on top of large language models. +- [AudioPaLM](https://google-research.github.io/seanet/audiopalm/examples/) — resources and code for AudioPaLM. +- [Audio Flamingo](https://huggingface.co/nvidia/audio-flamingo-3) — unifies speech, sound, and music understanding with long-context reasoning. +- [Ultravox](https://github.com/fixie-ai/ultravox) — a fast multimodal large language model designed for real-time voice interactions. +- [Ichigo](https://github.com/menloresearch/ichigo) — an audio-text-to-text model for audio-related tasks. + +### Datasets + +- [nvidia/AF-Think](https://huggingface.co/datasets/nvidia/AF-Think) +- [nvidia/AudioSkills](https://huggingface.co/datasets/nvidia/AudioSkills) + +### Tools & Extras + +- [Fast-RTC](https://huggingface.co/fastrtc) — turn any Python function into a real-time audio/video stream. +- [PhiCookBook](https://github.com/microsoft/PhiCookBook) — Microsoft’s open-source guide to small language models. +- [Qwen2-audio-instruct](https://qwenlm.github.io/blog/qwen2-audio/) — Blogpost explaining usage and demos of Qwen2-audio-instruct. diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfc75f0104388ae93a6f5d8a77fcf5fd5c00476b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-text-to-text/data.ts @@ -0,0 +1,70 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A dataset containing audio conversations with question–answer pairs.", + id: "nvidia/AF-Think", + }, + { + description: "A more advanced and comprehensive dataset that contains characteristics of the audio as well", + id: "tsinghua-ee/QualiSpeech", + }, + ], + demo: { + inputs: [ + { + filename: "audio.wav", + type: "audio", + }, + { + label: "Text Prompt", + content: "What is the gender of the speaker?", + type: "text", + }, + ], + outputs: [ + { + label: "Generated Text", + content: "The gender of the speaker is female.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: + "A lightweight model that has capabilities of taking both audio and text as inputs and generating responses.", + id: "fixie-ai/ultravox-v0_5-llama-3_2-1b", + }, + { + description: "A multimodal model that supports voice chat and audio analysis.", + id: "Qwen/Qwen2-Audio-7B-Instruct", + }, + { + description: "A model for audio understanding, speech translation, and transcription.", + id: "mistralai/Voxtral-Small-24B-2507", + }, + { + description: "A new model capable of audio question answering and reasoning.", + id: "nvidia/audio-flamingo-3", + }, + ], + spaces: [ + { + description: "A space that takes input as both audio and text and generates answers.", + id: "iamomtiwari/ATTT", + }, + { + description: "A web application that demonstrates chatting with the Qwen2Audio Model.", + id: "freddyaboulton/talk-to-qwen-webrtc", + }, + ], + summary: + "Audio-text-to-text models take both an audio clip and a text prompt as input, and generate natural language text as output. These models can answer questions about spoken content, summarize meetings, analyze music, or interpret speech beyond simple transcription. They are useful for applications that combine speech understanding with reasoning or conversation.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/about.md b/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/about.md new file mode 100644 index 0000000000000000000000000000000000000000..eeda8c16afa49909aa4d2c868f9a87634978908e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/about.md @@ -0,0 +1,56 @@ +## Use Cases + +### Speech Enhancement (Noise removal) + +Speech Enhancement is a bit self explanatory. It improves (or enhances) the quality of an audio by removing noise. There are multiple libraries to solve this task, such as Speechbrain, Asteroid and ESPNet. Here is a simple example using Speechbrain + +```python +from speechbrain.pretrained import SpectralMaskEnhancement +model = SpectralMaskEnhancement.from_hparams( + "speechbrain/mtl-mimic-voicebank" +) +model.enhance_file("file.wav") +``` + +Alternatively, you can use [Inference Endpoints](https://huggingface.co/inference-endpoints) to solve this task + +```python +import json +import requests + +headers = {"Authorization": f"Bearer {API_TOKEN}"} +API_URL = "https://router.huggingface.co/hf-inference/models/speechbrain/mtl-mimic-voicebank" + +def query(filename): + with open(filename, "rb") as f: + data = f.read() + response = requests.request("POST", API_URL, headers=headers, data=data) + return json.loads(response.content.decode("utf-8")) + +data = query("sample1.flac") +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer with audio-to-audio models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.audioToAudio({ + data: await (await fetch("sample.flac")).blob(), + model: "speechbrain/sepformer-wham", +}); +``` + +### Audio Source Separation + +Audio Source Separation allows you to isolate different sounds from individual sources. For example, if you have an audio file with multiple people speaking, you can get an audio file for each of them. You can then use an Automatic Speech Recognition system to extract the text from each of these sources as an initial step for your system! + +Audio-to-Audio can also be used to remove noise from audio files: you get one audio for the person speaking and another audio for the noise. This can also be useful when you have multi-person audio with some noise: yyou can get one audio for each person and then one audio for the noise. + +## Training a model for your own data + +If you want to learn how to train models for the Audio-to-Audio task, we recommend the following tutorials: + +- [Speech Enhancement](https://speechbrain.github.io/tutorial_enhancement.html) +- [Source Separation](https://speechbrain.github.io/tutorial_separation.html) diff --git a/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/data.ts b/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cea0d5ee0b9b812d7a65ce8a1435ad23fc0dbce5 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/audio-to-audio/data.ts @@ -0,0 +1,66 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "512-element X-vector embeddings of speakers from CMU ARCTIC dataset.", + id: "Matthijs/cmu-arctic-xvectors", + }, + ], + demo: { + inputs: [ + { + filename: "input.wav", + type: "audio", + }, + ], + outputs: [ + { + filename: "label-0.wav", + type: "audio", + }, + { + filename: "label-1.wav", + type: "audio", + }, + ], + }, + metrics: [ + { + description: + "The Signal-to-Noise ratio is the relationship between the target signal level and the background noise level. It is calculated as the logarithm of the target signal divided by the background noise, in decibels.", + id: "snri", + }, + { + description: + "The Signal-to-Distortion ratio is the relationship between the target signal and the sum of noise, interference, and artifact errors", + id: "sdri", + }, + ], + models: [ + { + description: "A speech enhancement model.", + id: "ResembleAI/resemble-enhance", + }, + { + description: "A model that can change the voice in a speech recording.", + id: "microsoft/speecht5_vc", + }, + ], + spaces: [ + { + description: "An application for speech separation.", + id: "younver/speechbrain-speech-separation", + }, + { + description: "An application for audio style transfer.", + id: "nakas/audio-diffusion_style_transfer", + }, + ], + summary: + "Audio-to-Audio is a family of tasks in which the input is an audio and the output is one or multiple generated audios. Some example tasks are speech enhancement and source separation.", + widgetModels: ["speechbrain/sepformer-wham"], + youtubeId: "iohj7nCCYoM", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/about.md b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/about.md new file mode 100644 index 0000000000000000000000000000000000000000..e1cab59719bfff5746bb9fb8b46213412dd8bd00 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/about.md @@ -0,0 +1,90 @@ +## Use Cases + +### Virtual Speech Assistants + +Many edge devices have an embedded virtual assistant to interact with the end users better. These assistances rely on ASR models to recognize different voice commands to perform various tasks. For instance, you can ask your phone for dialing a phone number, ask a general question, or schedule a meeting. + +### Caption Generation + +A caption generation model takes audio as input from sources to generate automatic captions through transcription, for live-streamed or recorded videos. This can help with content accessibility. For example, an audience watching a video that includes a non-native language, can rely on captions to interpret the content. It can also help with information retention at online-classes environments improving knowledge assimilation while reading and taking notes faster. + +## Task Variants + +### Multilingual ASR + +Multilingual ASR models can convert audio inputs with multiple languages into transcripts. Some multilingual ASR models include [language identification](https://huggingface.co/tasks/audio-classification) blocks to improve the performance. + +The use of Multilingual ASR has become popular, the idea of maintaining just a single model for all language can simplify the production pipeline. Take a look at [Whisper](https://huggingface.co/openai/whisper-large-v2) to get an idea on how 100+ languages can be processed by a single model. + +## Inference + +The Hub contains over [17,000 ASR models](https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&sort=downloads) that you can test right away in your browser using the model page widgets. You can also use any model as a service using the Serverless Inference API. We also support libraries such as [transformers](https://huggingface.co/models?library=transformers&pipeline_tag=automatic-speech-recognition&sort=downloads), [speechbrain](https://huggingface.co/models?library=speechbrain&pipeline_tag=automatic-speech-recognition&sort=downloads), [NeMo](https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&library=nemo&sort=downloads) and [espnet](https://huggingface.co/models?library=espnet&pipeline_tag=automatic-speech-recognition&sort=downloads) via the Serverless Inference API. Here's a simple code snippet to run inference: + +```python +import json +import requests + +headers = {"Authorization": f"Bearer {API_TOKEN}"} +API_URL = "https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3" + +def query(filename): + with open(filename, "rb") as f: + data = f.read() + response = requests.request("POST", API_URL, headers=headers, data=data) + return json.loads(response.content.decode("utf-8")) + +data = query("sample1.flac") +``` + +You can also use [huggingface.js](https://github.com/huggingface/huggingface.js), the JavaScript client, to transcribe audio with the Serverless Inference API. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.automaticSpeechRecognition({ + data: await (await fetch("sample.flac")).blob(), + model: "openai/whisper-large-v3", +}); +``` + +For transformers-compatible models like Whisper, Wav2Vec2, and HuBERT, you can also run inference with the library as follows: + +```python +# pip install --upgrade transformers + +from transformers import pipeline + +pipe = pipeline("automatic-speech-recognition", "openai/whisper-large-v3") + +pipe("sample.flac") +# {'text': "GOING ALONG SLUSHY COUNTRY ROADS AND SPEAKING TO DAMP AUDIENCES IN DRAUGHTY SCHOOL ROOMS DAY AFTER DAY FOR A FORTNIGHT HE'LL HAVE TO PUT IN AN APPEARANCE AT SOME PLACE OF WORSHIP ON SUNDAY MORNING AND HE CAN COME TO US IMMEDIATELY AFTERWARDS"} +``` + +## Solving ASR for your own data + +We have some great news! You can fine-tune (transfer learning) a foundational speech model on a specific language without tonnes of data. Pretrained models such as Whisper, Wav2Vec2-MMS and HuBERT exist. [OpenAI's Whisper model](https://huggingface.co/openai/whisper-large-v3) is a large multilingual model trained on 100+ languages and with 4 Million hours of speech. + +The following detailed [blog post](https://huggingface.co/blog/fine-tune-whisper) shows how to fine-tune a pre-trained Whisper checkpoint on labeled data for ASR. With the right data and strategy you can fine-tune a high-performant model on a free Google Colab instance too. We suggest to read the blog post for more info! + +## Hugging Face Whisper Event + +On December 2022, over 450 participants collaborated, fine-tuned and shared 600+ ASR Whisper models in 100+ different languages. You can compare these models on the event's speech recognition [leaderboard](https://huggingface.co/spaces/whisper-event/leaderboard?dataset=mozilla-foundation%2Fcommon_voice_11_0&config=ar&split=test). + +These events help democratize ASR for all languages, including low-resource languages. In addition to the trained models, the [event](https://github.com/huggingface/community-events/tree/main/whisper-fine-tuning-event) helps to build practical collaborative knowledge. + +## Useful Resources + +- [Hugging Face Audio Course](https://huggingface.co/learn/audio-course/chapter5/introduction) +- [Fine-tuning MetaAI's MMS Adapter Models for Multi-Lingual ASR](https://huggingface.co/blog/mms_adapters) +- [Making automatic speech recognition work on large files with Wav2Vec2 in 🤗 Transformers](https://huggingface.co/blog/asr-chunking) +- [Boosting Wav2Vec2 with n-grams in 🤗 Transformers](https://huggingface.co/blog/wav2vec2-with-ngram) +- [ML for Audio Study Group - Intro to Audio and ASR Deep Dive](https://www.youtube.com/watch?v=D-MH6YjuIlE) +- [Massively Multilingual ASR: 50 Languages, 1 Model, 1 Billion Parameters](https://arxiv.org/pdf/2007.03001.pdf) +- An ASR toolkit made by [NVIDIA: NeMo](https://github.com/NVIDIA/NeMo) with code and pretrained models useful for new ASR models. Watch the [introductory video](https://www.youtube.com/embed/wBgpMf_KQVw) for an overview. +- [An introduction to SpeechT5, a multi-purpose speech recognition and synthesis model](https://huggingface.co/blog/speecht5) +- [Fine-tune Whisper For Multilingual ASR with 🤗Transformers](https://huggingface.co/blog/fine-tune-whisper) +- [Automatic speech recognition task guide](https://huggingface.co/docs/transformers/tasks/asr) +- [Speech Synthesis, Recognition, and More With SpeechT5](https://huggingface.co/blog/speecht5) +- [Fine-Tune W2V2-Bert for low-resource ASR with 🤗 Transformers](https://huggingface.co/blog/fine-tune-w2v2-bert) +- [Speculative Decoding for 2x Faster Whisper Inference](https://huggingface.co/blog/whisper-speculative-decoding) diff --git a/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/data.ts b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..b177a7f123045e717efe832e24a5d790517ff3cb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/data.ts @@ -0,0 +1,94 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "31,175 hours of multilingual audio-text dataset in 108 languages.", + id: "mozilla-foundation/common_voice_17_0", + }, + { + description: "Multilingual and diverse audio dataset with 101k hours of audio.", + id: "amphion/Emilia-Dataset", + }, + { + description: "A dataset with 44.6k hours of English speaker data and 6k hours of other language speakers.", + id: "parler-tts/mls_eng", + }, + { + description: "A multilingual audio dataset with 370K hours of audio.", + id: "espnet/yodas", + }, + ], + demo: { + inputs: [ + { + filename: "input.flac", + type: "audio", + }, + ], + outputs: [ + { + /// GOING ALONG SLUSHY COUNTRY ROADS AND SPEAKING TO DAMP AUDIENCES I + label: "Transcript", + content: "Going along slushy country roads and speaking to damp audiences in...", + type: "text", + }, + ], + }, + metrics: [ + { + description: "", + id: "wer", + }, + { + description: "", + id: "cer", + }, + ], + models: [ + { + description: "A powerful ASR model by OpenAI.", + id: "openai/whisper-large-v3", + }, + { + description: "A good generic speech model by MetaAI for fine-tuning.", + id: "facebook/w2v-bert-2.0", + }, + { + description: "An end-to-end model that performs ASR and Speech Translation by MetaAI.", + id: "facebook/seamless-m4t-v2-large", + }, + { + description: "A powerful multilingual ASR and Speech Translation model by Nvidia.", + id: "nvidia/canary-1b", + }, + { + description: "Powerful speaker diarization model.", + id: "pyannote/speaker-diarization-3.1", + }, + ], + spaces: [ + { + description: "A powerful general-purpose speech recognition application.", + id: "hf-audio/whisper-large-v3", + }, + { + description: "Latest ASR model from Useful Sensors.", + id: "mrfakename/Moonshinex", + }, + { + description: "A high quality speech and text translation model by Meta.", + id: "facebook/seamless_m4t", + }, + { + description: "A powerful multilingual ASR and Speech Translation model by Nvidia", + id: "nvidia/canary-1b", + }, + ], + summary: + "Automatic Speech Recognition (ASR), also known as Speech to Text (STT), is the task of transcribing a given audio to text. It has many applications, such as voice user interfaces.", + widgetModels: ["openai/whisper-large-v3"], + youtubeId: "TksaY_FDgnk", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/inference.ts b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..664a22176769af9d798595b92a820299361b9dc8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/inference.ts @@ -0,0 +1,150 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Automatic Speech Recognition inference + */ +export interface AutomaticSpeechRecognitionInput { + /** + * The input audio data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the audio data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Automatic Speech Recognition + */ + parameters?: AutomaticSpeechRecognitionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Automatic Speech Recognition + */ +export interface AutomaticSpeechRecognitionParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + /** + * Whether to output corresponding timestamps with the generated text + */ + return_timestamps?: boolean; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +/** + * Outputs of inference for the Automatic Speech Recognition task + */ +export interface AutomaticSpeechRecognitionOutput { + /** + * When returnTimestamps is enabled, chunks contains a list of audio chunks identified by + * the model. + */ + chunks?: AutomaticSpeechRecognitionOutputChunk[]; + /** + * The recognized text. + */ + text: string; + [property: string]: unknown; +} +export interface AutomaticSpeechRecognitionOutputChunk { + /** + * A chunk of text identified by the model + */ + text: string; + /** + * The start and end timestamps corresponding with the text + */ + timestamp: number[]; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..b1e050e75e8a4794c9499c87b2ba9fc1c10b8bb2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/input.json @@ -0,0 +1,35 @@ +{ + "$id": "/inference/schemas/automatic-speech-recognition/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Automatic Speech Recognition inference", + "title": "AutomaticSpeechRecognitionInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input audio data as a base64-encoded string. If no `parameters` are provided, you can also provide the audio data as a raw bytes payload.", + "type": "string", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Automatic Speech Recognition", + "$ref": "#/$defs/AutomaticSpeechRecognitionParameters" + } + }, + "$defs": { + "AutomaticSpeechRecognitionParameters": { + "title": "AutomaticSpeechRecognitionParameters", + "type": "object", + "properties": { + "return_timestamps": { + "type": "boolean", + "description": "Whether to output corresponding timestamps with the generated text" + }, + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..fd71699aa4ad069c54522d1e4a65ec9f84f273af --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/automatic-speech-recognition/spec/output.json @@ -0,0 +1,38 @@ +{ + "$id": "/inference/schemas/automatic-speech-recognition/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Automatic Speech Recognition task", + "title": "AutomaticSpeechRecognitionOutput", + "type": "object", + "properties": { + "text": { + "type": "string", + "description": "The recognized text." + }, + "chunks": { + "type": "array", + "description": "When returnTimestamps is enabled, chunks contains a list of audio chunks identified by the model.", + "items": { + "type": "object", + "title": "AutomaticSpeechRecognitionOutputChunk", + "properties": { + "text": { + "type": "string", + "description": "A chunk of text identified by the model" + }, + "timestamp": { + "type": "array", + "description": "The start and end timestamps corresponding with the text", + "items": { + "type": "number" + }, + "minLength": 2, + "maxLength": 2 + } + }, + "required": ["text", "timestamp"] + } + } + }, + "required": ["text"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/chat-completion/inference.ts b/node_modules/@huggingface/tasks/src/tasks/chat-completion/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..f299398c4296c728f44e96572f4f7e75930816f3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/chat-completion/inference.ts @@ -0,0 +1,329 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Chat Completion Input. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface ChatCompletionInput { + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing + * frequency in the text so far, + * decreasing the model's likelihood to repeat the same line verbatim. + */ + frequency_penalty?: number; + /** + * UNUSED + * Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON + * object that maps tokens + * (specified by their token ID in the tokenizer) to an associated bias value from -100 to + * 100. Mathematically, + * the bias is added to the logits generated by the model prior to sampling. The exact + * effect will vary per model, + * but values between -1 and 1 should decrease or increase likelihood of selection; values + * like -100 or 100 should + * result in a ban or exclusive selection of the relevant token. + */ + logit_bias?: number[]; + /** + * Whether to return log probabilities of the output tokens or not. If true, returns the log + * probabilities of each + * output token returned in the content of message. + */ + logprobs?: boolean; + /** + * The maximum number of tokens that can be generated in the chat completion. + */ + max_tokens?: number; + /** + * A list of messages comprising the conversation so far. + */ + messages: ChatCompletionInputMessage[]; + /** + * [UNUSED] ID of the model to use. See the model endpoint compatibility table for details + * on which models work with the Chat API. + */ + model?: string; + /** + * UNUSED + * How many chat completion choices to generate for each input message. Note that you will + * be charged based on the + * number of generated tokens across all of the choices. Keep n as 1 to minimize costs. + */ + n?: number; + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they + * appear in the text so far, + * increasing the model's likelihood to talk about new topics + */ + presence_penalty?: number; + response_format?: ChatCompletionInputGrammarType; + seed?: number; + /** + * Up to 4 sequences where the API will stop generating further tokens. + */ + stop?: string[]; + stream?: boolean; + stream_options?: ChatCompletionInputStreamOptions; + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the + * output more random, while + * lower values like 0.2 will make it more focused and deterministic. + * + * We generally recommend altering this or `top_p` but not both. + */ + temperature?: number; + tool_choice?: ChatCompletionInputToolChoice; + /** + * A prompt to be appended before the tools + */ + tool_prompt?: string; + /** + * A list of tools the model may call. Currently, only functions are supported as a tool. + * Use this to provide a list of + * functions the model may generate JSON inputs for. + */ + tools?: ChatCompletionInputTool[]; + /** + * An integer between 0 and 5 specifying the number of most likely tokens to return at each + * token position, each with + * an associated log probability. logprobs must be set to true if this parameter is used. + */ + top_logprobs?: number; + /** + * An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the + * tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% + * probability mass are considered. + */ + top_p?: number; + [property: string]: unknown; +} +export interface ChatCompletionInputMessage { + content?: ChatCompletionInputMessageContent; + name?: string; + role: string; + tool_calls?: ChatCompletionInputToolCall[]; + [property: string]: unknown; +} +export type ChatCompletionInputMessageContent = ChatCompletionInputMessageChunk[] | string; +export interface ChatCompletionInputMessageChunk { + image_url?: ChatCompletionInputURL; + text?: string; + type: ChatCompletionInputMessageChunkType; + [property: string]: unknown; +} +export interface ChatCompletionInputURL { + url: string; + [property: string]: unknown; +} +export type ChatCompletionInputMessageChunkType = "text" | "image_url"; +export interface ChatCompletionInputToolCall { + function: ChatCompletionInputFunctionDefinition; + id: string; + type: string; + [property: string]: unknown; +} +export interface ChatCompletionInputFunctionDefinition { + description?: string; + name: string; + parameters?: unknown; + [property: string]: unknown; +} +export interface ChatCompletionInputGrammarType { + json_schema?: ChatCompletionInputJSONSchemaConfig; + type: ChatCompletionInputGrammarTypeType; + [property: string]: unknown; +} +export interface ChatCompletionInputJSONSchemaConfig { + /** + * A description of what the response format is for, used by the model to determine how to + * respond in the format. + */ + description?: string; + /** + * The name of the response format. + */ + name: string; + /** + * The schema for the response format, described as a JSON Schema object. Learn how to build + * JSON schemas [here](https://json-schema.org/). + */ + schema?: { + [key: string]: unknown; + }; + /** + * Whether to enable strict schema adherence when generating the output. If set to true, the + * model will always follow the exact schema defined in the `schema` field. + */ + strict?: boolean; + [property: string]: unknown; +} +export type ChatCompletionInputGrammarTypeType = "text" | "json_schema" | "json_object"; +export interface ChatCompletionInputStreamOptions { + /** + * If set, an additional chunk will be streamed before the data: [DONE] message. The usage + * field on this chunk shows the token usage statistics for the entire request, and the + * choices field will always be an empty array. All other chunks will also include a usage + * field, but with a null value. + */ + include_usage?: boolean; + [property: string]: unknown; +} +/** + * + * + */ +export type ChatCompletionInputToolChoice = ChatCompletionInputToolChoiceEnum | ChatCompletionInputToolChoiceObject; +/** + * Means the model can pick between generating a message or calling one or more tools. + * + * Means the model will not call any tool and instead generates a message. + * + * Means the model must call one or more tools. + */ +export type ChatCompletionInputToolChoiceEnum = "auto" | "none" | "required"; +export interface ChatCompletionInputToolChoiceObject { + function: ChatCompletionInputFunctionName; + [property: string]: unknown; +} +export interface ChatCompletionInputFunctionName { + name: string; + [property: string]: unknown; +} +export interface ChatCompletionInputTool { + function: ChatCompletionInputFunctionDefinition; + type: string; + [property: string]: unknown; +} +/** + * Chat Completion Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface ChatCompletionOutput { + choices: ChatCompletionOutputComplete[]; + created: number; + id: string; + model: string; + system_fingerprint: string; + usage: ChatCompletionOutputUsage; + [property: string]: unknown; +} +export interface ChatCompletionOutputComplete { + finish_reason: string; + index: number; + logprobs?: ChatCompletionOutputLogprobs; + message: ChatCompletionOutputMessage; + [property: string]: unknown; +} +export interface ChatCompletionOutputLogprobs { + content: ChatCompletionOutputLogprob[]; + [property: string]: unknown; +} +export interface ChatCompletionOutputLogprob { + logprob: number; + token: string; + top_logprobs: ChatCompletionOutputTopLogprob[]; + [property: string]: unknown; +} +export interface ChatCompletionOutputTopLogprob { + logprob: number; + token: string; + [property: string]: unknown; +} +export interface ChatCompletionOutputMessage { + content?: string; + role: string; + tool_call_id?: string; + tool_calls?: ChatCompletionOutputToolCall[]; + [property: string]: unknown; +} +export interface ChatCompletionOutputToolCall { + function: ChatCompletionOutputFunctionDefinition; + id: string; + type: string; + [property: string]: unknown; +} +export interface ChatCompletionOutputFunctionDefinition { + arguments: string; + description?: string; + name: string; + [property: string]: unknown; +} +export interface ChatCompletionOutputUsage { + completion_tokens: number; + prompt_tokens: number; + total_tokens: number; + [property: string]: unknown; +} +/** + * Chat Completion Stream Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface ChatCompletionStreamOutput { + choices: ChatCompletionStreamOutputChoice[]; + created: number; + id: string; + model: string; + system_fingerprint: string; + usage?: ChatCompletionStreamOutputUsage; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputChoice { + delta: ChatCompletionStreamOutputDelta; + finish_reason?: string; + index: number; + logprobs?: ChatCompletionStreamOutputLogprobs; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputDelta { + content?: string; + role: string; + tool_call_id?: string; + tool_calls?: ChatCompletionStreamOutputDeltaToolCall[]; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputDeltaToolCall { + function: ChatCompletionStreamOutputFunction; + id: string; + index: number; + type: string; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputFunction { + arguments: string; + name?: string; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputLogprobs { + content: ChatCompletionStreamOutputLogprob[]; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputLogprob { + logprob: number; + token: string; + top_logprobs: ChatCompletionStreamOutputTopLogprob[]; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputTopLogprob { + logprob: number; + token: string; + [property: string]: unknown; +} +export interface ChatCompletionStreamOutputUsage { + completion_tokens: number; + prompt_tokens: number; + total_tokens: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..523b755d5a77f26fc6cb6a4b02f87817b535199f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/input.json @@ -0,0 +1,433 @@ +{ + "$id": "/inference/schemas/chat-completion/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Chat Completion Input.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "ChatCompletionInput", + "type": "object", + "required": ["messages"], + "properties": { + "frequency_penalty": { + "type": "number", + "format": "float", + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far,\ndecreasing the model's likelihood to repeat the same line verbatim.", + "example": "1.0", + "nullable": true + }, + "logit_bias": { + "type": "array", + "items": { + "type": "number", + "format": "float" + }, + "description": "UNUSED\nModify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens\n(specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically,\nthe bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model,\nbut values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should\nresult in a ban or exclusive selection of the relevant token.", + "nullable": true + }, + "logprobs": { + "type": "boolean", + "description": "Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each\noutput token returned in the content of message.", + "example": "false", + "nullable": true + }, + "max_tokens": { + "type": "integer", + "format": "int32", + "description": "The maximum number of tokens that can be generated in the chat completion.", + "default": "1024", + "example": "32", + "nullable": true, + "minimum": 0 + }, + "messages": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionInputMessage" + }, + "description": "A list of messages comprising the conversation so far.", + "example": "[{\"role\": \"user\", \"content\": \"What is Deep Learning?\"}]" + }, + "model": { + "type": "string", + "description": "[UNUSED] ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.", + "example": "mistralai/Mistral-7B-Instruct-v0.2", + "nullable": true + }, + "n": { + "type": "integer", + "format": "int32", + "description": "UNUSED\nHow many chat completion choices to generate for each input message. Note that you will be charged based on the\nnumber of generated tokens across all of the choices. Keep n as 1 to minimize costs.", + "example": "2", + "nullable": true, + "minimum": 0 + }, + "presence_penalty": { + "type": "number", + "format": "float", + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far,\nincreasing the model's likelihood to talk about new topics", + "example": 0.1, + "nullable": true + }, + "response_format": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionInputGrammarType" + } + ], + "default": "null", + "nullable": true + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + }, + "stop": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Up to 4 sequences where the API will stop generating further tokens.", + "example": "null", + "nullable": true + }, + "stream": { + "type": "boolean" + }, + "stream_options": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionInputStreamOptions" + } + ], + "nullable": true + }, + "temperature": { + "type": "number", + "format": "float", + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while\nlower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.", + "example": 1, + "nullable": true + }, + "tool_choice": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionInputToolChoice" + } + ], + "default": "auto", + "nullable": true + }, + "tool_prompt": { + "type": "string", + "description": "A prompt to be appended before the tools", + "example": "Given the functions available, please respond with a JSON for a function call with its proper arguments that best answers the given prompt. Respond in the format {name: function name, parameters: dictionary of argument name and its value}.Do not use variables.", + "nullable": true + }, + "tools": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionInputTool" + }, + "description": "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of\nfunctions the model may generate JSON inputs for.", + "example": "null", + "nullable": true + }, + "top_logprobs": { + "type": "integer", + "format": "int32", + "description": "An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with\nan associated log probability. logprobs must be set to true if this parameter is used.", + "example": "5", + "nullable": true, + "minimum": 0 + }, + "top_p": { + "type": "number", + "format": "float", + "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the\ntokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.", + "example": 0.95, + "nullable": true + } + }, + "$defs": { + "ChatCompletionInputMessage": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionInputMessageBody" + }, + { + "type": "object", + "required": ["role"], + "properties": { + "name": { + "type": "string", + "example": "\"David\"", + "nullable": true + }, + "role": { + "type": "string", + "example": "user" + } + } + } + ], + "title": "ChatCompletionInputMessage" + }, + "ChatCompletionInputMessageBody": { + "oneOf": [ + { + "type": "object", + "required": ["content"], + "properties": { + "content": { + "$ref": "#/$defs/ChatCompletionInputMessageContent" + } + } + }, + { + "type": "object", + "required": ["tool_calls"], + "properties": { + "tool_calls": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionInputToolCall" + } + } + } + } + ], + "title": "ChatCompletionInputMessageBody" + }, + "ChatCompletionInputMessageContent": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionInputMessageChunk" + } + } + ], + "title": "ChatCompletionInputMessageContent" + }, + "ChatCompletionInputMessageChunk": { + "oneOf": [ + { + "type": "object", + "required": ["text", "type"], + "properties": { + "text": { + "type": "string" + }, + "type": { + "type": "string", + "enum": ["text"] + } + } + }, + { + "type": "object", + "required": ["image_url", "type"], + "properties": { + "image_url": { + "$ref": "#/$defs/ChatCompletionInputUrl" + }, + "type": { + "type": "string", + "enum": ["image_url"] + } + } + } + ], + "discriminator": { + "propertyName": "type" + }, + "title": "ChatCompletionInputMessageChunk" + }, + "ChatCompletionInputUrl": { + "type": "object", + "required": ["url"], + "properties": { + "url": { + "type": "string" + } + }, + "title": "ChatCompletionInputUrl" + }, + "ChatCompletionInputToolCall": { + "type": "object", + "required": ["id", "type", "function"], + "properties": { + "function": { + "$ref": "#/$defs/ChatCompletionInputFunctionDefinition" + }, + "id": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "title": "ChatCompletionInputToolCall" + }, + "ChatCompletionInputFunctionDefinition": { + "type": "object", + "required": ["name"], + "properties": { + "parameters": {}, + "description": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string" + } + }, + "title": "ChatCompletionInputFunctionDefinition" + }, + "ChatCompletionInputGrammarType": { + "oneOf": [ + { + "$ref": "#/$defs/ChatCompletionInputResponseFormatText" + }, + { + "$ref": "#/$defs/ChatCompletionInputResponseFormatJSONSchema" + }, + { + "$ref": "#/$defs/ChatCompletionInputResponseFormatJSONObject" + } + ], + "title": "ChatCompletionInputGrammarType" + }, + "ChatCompletionInputResponseFormatText": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "type": "string", + "enum": ["text"] + } + }, + "title": "ChatCompletionInputResponseFormatText" + }, + "ChatCompletionInputResponseFormatJSONSchema": { + "type": "object", + "required": ["type", "json_schema"], + "properties": { + "type": { + "type": "string", + "enum": ["json_schema"] + }, + "json_schema": { + "$ref": "#/$defs/ChatCompletionInputJsonSchemaConfig" + } + }, + "title": "ChatCompletionInputResponseFormatJSONSchema" + }, + "ChatCompletionInputResponseFormatJSONObject": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "type": "string", + "enum": ["json_object"] + } + }, + "title": "ChatCompletionInputResponseFormatJSONObject" + }, + "ChatCompletionInputJsonSchemaConfig": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string", + "description": "The name of the response format." + }, + "description": { + "type": "string", + "description": "A description of what the response format is for, used by the model to determine how to respond in the format.", + "nullable": true + }, + "schema": { + "type": "object", + "description": "The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas [here](https://json-schema.org/).", + "nullable": true + }, + "strict": { + "type": "boolean", + "description": "Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field.", + "nullable": true + } + }, + "title": "ChatCompletionInputJsonSchemaConfig" + }, + "ChatCompletionInputStreamOptions": { + "type": "object", + "properties": { + "include_usage": { + "type": "boolean", + "description": "If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value.", + "example": "true" + } + }, + "title": "ChatCompletionInputStreamOptions" + }, + "ChatCompletionInputToolChoice": { + "oneOf": [ + { + "type": "string", + "description": "Means the model can pick between generating a message or calling one or more tools.", + "enum": ["auto"] + }, + { + "type": "string", + "description": "Means the model will not call any tool and instead generates a message.", + "enum": ["none"] + }, + { + "type": "string", + "description": "Means the model must call one or more tools.", + "enum": ["required"] + }, + { + "type": "object", + "required": ["function"], + "properties": { + "function": { + "$ref": "#/$defs/ChatCompletionInputFunctionName" + } + } + } + ], + "description": "", + "title": "ChatCompletionInputToolChoice" + }, + "ChatCompletionInputFunctionName": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + } + }, + "title": "ChatCompletionInputFunctionName" + }, + "ChatCompletionInputTool": { + "type": "object", + "required": ["type", "function"], + "properties": { + "function": { + "$ref": "#/$defs/ChatCompletionInputFunctionDefinition" + }, + "type": { + "type": "string", + "example": "function" + } + }, + "title": "ChatCompletionInputTool" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..759d657badf96b416f794720fd2328472acd7b36 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/output.json @@ -0,0 +1,212 @@ +{ + "$id": "/inference/schemas/chat-completion/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Chat Completion Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "ChatCompletionOutput", + "type": "object", + "required": ["id", "created", "model", "system_fingerprint", "choices", "usage"], + "properties": { + "choices": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionOutputComplete" + } + }, + "created": { + "type": "integer", + "format": "int64", + "example": "1706270835", + "minimum": 0 + }, + "id": { + "type": "string" + }, + "model": { + "type": "string", + "example": "mistralai/Mistral-7B-Instruct-v0.2" + }, + "system_fingerprint": { + "type": "string" + }, + "usage": { + "$ref": "#/$defs/ChatCompletionOutputUsage" + } + }, + "$defs": { + "ChatCompletionOutputComplete": { + "type": "object", + "required": ["index", "message", "finish_reason"], + "properties": { + "finish_reason": { + "type": "string" + }, + "index": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "logprobs": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionOutputLogprobs" + } + ], + "nullable": true + }, + "message": { + "$ref": "#/$defs/ChatCompletionOutputMessage" + } + }, + "title": "ChatCompletionOutputComplete" + }, + "ChatCompletionOutputLogprobs": { + "type": "object", + "required": ["content"], + "properties": { + "content": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionOutputLogprob" + } + } + }, + "title": "ChatCompletionOutputLogprobs" + }, + "ChatCompletionOutputLogprob": { + "type": "object", + "required": ["token", "logprob", "top_logprobs"], + "properties": { + "logprob": { + "type": "number", + "format": "float" + }, + "token": { + "type": "string" + }, + "top_logprobs": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionOutputTopLogprob" + } + } + }, + "title": "ChatCompletionOutputLogprob" + }, + "ChatCompletionOutputTopLogprob": { + "type": "object", + "required": ["token", "logprob"], + "properties": { + "logprob": { + "type": "number", + "format": "float" + }, + "token": { + "type": "string" + } + }, + "title": "ChatCompletionOutputTopLogprob" + }, + "ChatCompletionOutputMessage": { + "oneOf": [ + { + "$ref": "#/$defs/ChatCompletionOutputTextMessage" + }, + { + "$ref": "#/$defs/ChatCompletionOutputToolCallMessage" + } + ], + "title": "ChatCompletionOutputMessage" + }, + "ChatCompletionOutputTextMessage": { + "type": "object", + "required": ["role", "content"], + "properties": { + "content": { + "type": "string", + "example": "My name is David and I" + }, + "role": { + "type": "string", + "example": "user" + }, + "tool_call_id": { + "type": "string", + "nullable": true + } + }, + "title": "ChatCompletionOutputTextMessage" + }, + "ChatCompletionOutputToolCallMessage": { + "type": "object", + "required": ["role", "tool_calls"], + "properties": { + "role": { + "type": "string", + "example": "assistant" + }, + "tool_calls": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionOutputToolCall" + } + } + }, + "title": "ChatCompletionOutputToolCallMessage" + }, + "ChatCompletionOutputToolCall": { + "type": "object", + "required": ["id", "type", "function"], + "properties": { + "function": { + "$ref": "#/$defs/ChatCompletionOutputFunctionDefinition" + }, + "id": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "title": "ChatCompletionOutputToolCall" + }, + "ChatCompletionOutputFunctionDefinition": { + "type": "object", + "required": ["name", "arguments"], + "properties": { + "arguments": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string" + } + }, + "title": "ChatCompletionOutputFunctionDefinition" + }, + "ChatCompletionOutputUsage": { + "type": "object", + "required": ["prompt_tokens", "completion_tokens", "total_tokens"], + "properties": { + "completion_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "prompt_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "total_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + }, + "title": "ChatCompletionOutputUsage" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/stream_output.json b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/stream_output.json new file mode 100644 index 0000000000000000000000000000000000000000..e5b382696b9ad141dd2628cbaa14905c7de2eda8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/chat-completion/spec/stream_output.json @@ -0,0 +1,220 @@ +{ + "$id": "/inference/schemas/chat-completion/stream_output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Chat Completion Stream Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "ChatCompletionStreamOutput", + "type": "object", + "required": ["id", "created", "model", "system_fingerprint", "choices"], + "properties": { + "choices": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionStreamOutputChoice" + } + }, + "created": { + "type": "integer", + "format": "int64", + "example": "1706270978", + "minimum": 0 + }, + "id": { + "type": "string" + }, + "model": { + "type": "string", + "example": "mistralai/Mistral-7B-Instruct-v0.2" + }, + "system_fingerprint": { + "type": "string" + }, + "usage": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionStreamOutputUsage" + } + ], + "nullable": true + } + }, + "$defs": { + "ChatCompletionStreamOutputChoice": { + "type": "object", + "required": ["index", "delta"], + "properties": { + "delta": { + "$ref": "#/$defs/ChatCompletionStreamOutputDelta" + }, + "finish_reason": { + "type": "string", + "nullable": true + }, + "index": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "logprobs": { + "allOf": [ + { + "$ref": "#/$defs/ChatCompletionStreamOutputLogprobs" + } + ], + "nullable": true + } + }, + "title": "ChatCompletionStreamOutputChoice" + }, + "ChatCompletionStreamOutputDelta": { + "oneOf": [ + { + "$ref": "#/$defs/ChatCompletionStreamOutputTextMessage" + }, + { + "$ref": "#/$defs/ChatCompletionStreamOutputToolCallDelta" + } + ], + "title": "ChatCompletionStreamOutputDelta" + }, + "ChatCompletionStreamOutputTextMessage": { + "type": "object", + "required": ["role", "content"], + "properties": { + "content": { + "type": "string", + "example": "My name is David and I" + }, + "role": { + "type": "string", + "example": "user" + }, + "tool_call_id": { + "type": "string", + "nullable": true + } + }, + "title": "ChatCompletionStreamOutputTextMessage" + }, + "ChatCompletionStreamOutputToolCallDelta": { + "type": "object", + "required": ["role", "tool_calls"], + "properties": { + "role": { + "type": "string", + "example": "assistant" + }, + "tool_calls": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionStreamOutputDeltaToolCall" + } + } + }, + "title": "ChatCompletionStreamOutputToolCallDelta" + }, + "ChatCompletionStreamOutputDeltaToolCall": { + "type": "object", + "required": ["index", "id", "type", "function"], + "properties": { + "function": { + "$ref": "#/$defs/ChatCompletionStreamOutputFunction" + }, + "id": { + "type": "string" + }, + "index": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "type": { + "type": "string" + } + }, + "title": "ChatCompletionStreamOutputDeltaToolCall" + }, + "ChatCompletionStreamOutputFunction": { + "type": "object", + "required": ["arguments"], + "properties": { + "arguments": { + "type": "string" + }, + "name": { + "type": "string", + "nullable": true + } + }, + "title": "ChatCompletionStreamOutputFunction" + }, + "ChatCompletionStreamOutputLogprobs": { + "type": "object", + "required": ["content"], + "properties": { + "content": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionStreamOutputLogprob" + } + } + }, + "title": "ChatCompletionStreamOutputLogprobs" + }, + "ChatCompletionStreamOutputLogprob": { + "type": "object", + "required": ["token", "logprob", "top_logprobs"], + "properties": { + "logprob": { + "type": "number", + "format": "float" + }, + "token": { + "type": "string" + }, + "top_logprobs": { + "type": "array", + "items": { + "$ref": "#/$defs/ChatCompletionStreamOutputTopLogprob" + } + } + }, + "title": "ChatCompletionStreamOutputLogprob" + }, + "ChatCompletionStreamOutputTopLogprob": { + "type": "object", + "required": ["token", "logprob"], + "properties": { + "logprob": { + "type": "number", + "format": "float" + }, + "token": { + "type": "string" + } + }, + "title": "ChatCompletionStreamOutputTopLogprob" + }, + "ChatCompletionStreamOutputUsage": { + "type": "object", + "required": ["prompt_tokens", "completion_tokens", "total_tokens"], + "properties": { + "completion_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "prompt_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "total_tokens": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + }, + "title": "ChatCompletionStreamOutputUsage" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/common-definitions.json b/node_modules/@huggingface/tasks/src/tasks/common-definitions.json new file mode 100644 index 0000000000000000000000000000000000000000..a9603fc067fb6623f47f3e2e32f7366c3013bbcc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/common-definitions.json @@ -0,0 +1,99 @@ +{ + "$id": "/inference/schemas/common-definitions.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "(Incomplete!) Common type definitions shared by several tasks", + "definitions": { + "ClassificationOutputTransform": { + "title": "ClassificationOutputTransform", + "type": "string", + "description": "The function to apply to the model outputs in order to retrieve the scores.", + "enum": ["sigmoid", "softmax", "none"] + }, + "ClassificationOutput": { + "title": "ClassificationOutput", + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The predicted class label." + }, + "score": { + "type": "number", + "description": "The corresponding probability." + } + }, + "required": ["label", "score"] + }, + "GenerationParameters": { + "title": "GenerationParameters", + "type": "object", + "properties": { + "temperature": { + "type": "number", + "description": "The value used to modulate the next token probabilities." + }, + "top_k": { + "type": "integer", + "description": "The number of highest probability vocabulary tokens to keep for top-k-filtering." + }, + "top_p": { + "type": "number", + "description": "If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation." + }, + "typical_p": { + "type": "number", + "description": " Local typicality measures how similar the conditional probability of predicting a target token next is to the expected conditional probability of predicting a random token next, given the partial text already generated. If set to float < 1, the smallest set of the most locally typical tokens with probabilities that add up to typical_p or higher are kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details." + }, + "epsilon_cutoff": { + "type": "number", + "description": "If set to float strictly between 0 and 1, only tokens with a conditional probability greater than epsilon_cutoff will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) for more details." + }, + "eta_cutoff": { + "type": "number", + "description": "Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between 0 and 1, a token is only considered if it is greater than either eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) for more details." + }, + "max_length": { + "type": "integer", + "description": "The maximum length (in tokens) of the generated text, including the input." + }, + "max_new_tokens": { + "type": "integer", + "description": "The maximum number of tokens to generate. Takes precedence over max_length." + }, + "min_length": { + "type": "integer", + "description": "The minimum length (in tokens) of the generated text, including the input." + }, + "min_new_tokens": { + "type": "integer", + "description": "The minimum number of tokens to generate. Takes precedence over min_length." + }, + "do_sample": { + "type": "boolean", + "description": "Whether to use sampling instead of greedy decoding when generating new tokens." + }, + "early_stopping": { + "type": ["boolean", "string"], + "description": "Controls the stopping condition for beam-based methods.", + "enum": ["never", true, false] + }, + "num_beams": { + "type": "integer", + "description": "Number of beams to use for beam search." + }, + "num_beam_groups": { + "type": "integer", + "description": "Number of groups to divide num_beams into in order to ensure diversity among different groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details." + }, + "penalty_alpha": { + "type": "number", + "description": "The value balances the model confidence and the degeneration penalty in contrastive search decoding." + }, + "use_cache": { + "type": "boolean", + "description": "Whether the model should use the past last key/values attentions to speed up decoding" + } + } + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/depth-estimation/about.md b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..37c7d85a0991522e3bc5e6d06986f671cdc874d1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/about.md @@ -0,0 +1,45 @@ +## Use Cases + +Depth estimation models can be used to estimate the depth of different objects present in an image. + +### Estimation of Volumetric Information +Depth estimation models are widely used to study volumetric formation of objects present inside an image. This is an important use case in the domain of computer graphics. + +### 3D Representation + +Depth estimation models can also be used to develop a 3D representation from a 2D image. + +## Depth Estimation Subtasks + +There are two depth estimation subtasks. + +- **Absolute depth estimation**: Absolute (or metric) depth estimation aims to provide exact depth measurements from the camera. Absolute depth estimation models output depth maps with real-world distances in meter or feet. + +- **Relative depth estimation**: Relative depth estimation aims to predict the depth order of objects or points in a scene without providing the precise measurements. + +## Inference + +With the `transformers` library, you can use the `depth-estimation` pipeline to infer with image classification models. You can initialize the pipeline with a model id from the Hub. If you do not provide a model id it will initialize with [Intel/dpt-large](https://huggingface.co/Intel/dpt-large) by default. When calling the pipeline you just need to specify a path, http link or an image loaded in PIL. Additionally, you can find a comprehensive list of various depth estimation models at [this link](https://huggingface.co/models?pipeline_tag=depth-estimation). + +```python +from transformers import pipeline + +estimator = pipeline(task="depth-estimation", model="Intel/dpt-large") +result = estimator(images="http://images.cocodataset.org/val2017/000000039769.jpg") +result + +# {'predicted_depth': tensor([[[ 6.3199, 6.3629, 6.4148, ..., 10.4104, 10.5109, 10.3847], +# [ 6.3850, 6.3615, 6.4166, ..., 10.4540, 10.4384, 10.4554], +# [ 6.3519, 6.3176, 6.3575, ..., 10.4247, 10.4618, 10.4257], +# ..., +# [22.3772, 22.4624, 22.4227, ..., 22.5207, 22.5593, 22.5293], +# [22.5073, 22.5148, 22.5114, ..., 22.6604, 22.6344, 22.5871], +# [22.5176, 22.5275, 22.5218, ..., 22.6282, 22.6216, 22.6108]]]), +# 'depth': } + +# You can visualize the result just by calling `result["depth"]`. +``` + +## Useful Resources + +- [Monocular depth estimation task guide](https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation) diff --git a/node_modules/@huggingface/tasks/src/tasks/depth-estimation/data.ts b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..a20ec9facdb8eeb18afe0d9601a90b99d0c236f9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/data.ts @@ -0,0 +1,70 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "NYU Depth V2 Dataset: Video dataset containing both RGB and depth sensor data.", + id: "sayakpaul/nyu_depth_v2", + }, + { + description: "Monocular depth estimation benchmark based without noise and errors.", + id: "depth-anything/DA-2K", + }, + ], + demo: { + inputs: [ + { + filename: "depth-estimation-input.jpg", + type: "img", + }, + ], + outputs: [ + { + filename: "depth-estimation-output.png", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "Cutting-edge depth estimation model.", + id: "depth-anything/Depth-Anything-V2-Large", + }, + { + description: "A strong monocular depth estimation model.", + id: "jingheya/lotus-depth-g-v1-0", + }, + { + description: "A depth estimation model that predicts depth in videos.", + id: "tencent/DepthCrafter", + }, + { + description: "A robust depth estimation model.", + id: "apple/DepthPro-hf", + }, + ], + spaces: [ + { + description: "An application that predicts the depth of an image and then reconstruct the 3D model as voxels.", + id: "radames/dpt-depth-estimation-3d-voxels", + }, + { + description: "An application for bleeding-edge depth estimation.", + id: "akhaliq/depth-pro", + }, + { + description: "An application on cutting-edge depth estimation in videos.", + id: "tencent/DepthCrafter", + }, + { + description: "A human-centric depth estimation application.", + id: "facebook/sapiens-depth", + }, + ], + summary: "Depth estimation is the task of predicting depth of the objects present in an image.", + widgetModels: [""], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/depth-estimation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e81e8de28c9ce934d9c1a534cc5c52b8a737f7b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/inference.ts @@ -0,0 +1,35 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Depth Estimation inference + */ +export interface DepthEstimationInput { + /** + * The input image data + */ + inputs: unknown; + /** + * Additional inference parameters for Depth Estimation + */ + parameters?: { + [key: string]: unknown; + }; + [property: string]: unknown; +} +/** + * Outputs of inference for the Depth Estimation task + */ +export interface DepthEstimationOutput { + /** + * The predicted depth as an image + */ + depth?: unknown; + /** + * The predicted depth as a tensor + */ + predicted_depth?: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..fb6c70bddab71a3166209fe0506fe37161fd3acb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/input.json @@ -0,0 +1,24 @@ +{ + "$id": "/inference/schemas/depth-estimation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Depth Estimation inference", + "title": "DepthEstimationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input image data" + }, + "parameters": { + "description": "Additional inference parameters for Depth Estimation", + "$ref": "#/$defs/DepthEstimationParameters" + } + }, + "$defs": { + "DepthEstimationParameters": { + "title": "DepthEstimationParameters", + "type": "object", + "properties": {} + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..85bc6ef103c28dbc13e114df5ddc00d1a32f8406 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/depth-estimation/spec/output.json @@ -0,0 +1,16 @@ +{ + "$id": "/inference/schemas/depth-estimation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Depth Estimation task", + "title": "DepthEstimationOutput", + + "type": "object", + "properties": { + "predicted_depth": { + "description": "The predicted depth as a tensor" + }, + "depth": { + "description": "The predicted depth as an image" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/document-question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..528c29ec917ace00387344b09671e9a90fcc6e06 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/about.md @@ -0,0 +1,53 @@ +## Use Cases + +Document Question Answering models can be used to answer natural language questions about documents. Typically, document QA models consider textual, layout and potentially visual information. This is useful when the question requires some understanding of the visual aspects of the document. +Nevertheless, certain document QA models can work without document images. Hence the task is not limited to visually-rich documents and allows users to ask questions based on spreadsheets, text PDFs, etc! + +### Document Parsing + +One of the most popular use cases of document question answering models is the parsing of structured documents. For example, you can extract the name, address, and other information from a form. You can also use the model to extract information from a table, or even a resume. + +### Invoice Information Extraction + +Another very popular use case is invoice information extraction. For example, you can extract the invoice number, the invoice date, the total amount, the VAT number, and the invoice recipient. + +## Inference + +You can infer with Document QA models with the 🤗 Transformers library using the [`document-question-answering` pipeline](https://huggingface.co/docs/transformers/en/main_classes/pipelines#transformers.DocumentQuestionAnsweringPipeline). If no model checkpoint is given, the pipeline will be initialized with [`impira/layoutlm-document-qa`](https://huggingface.co/impira/layoutlm-document-qa). This pipeline takes question(s) and document(s) as input, and returns the answer. +👉 Note that the question answering task solved here is extractive: the model extracts the answer from a context (the document). + +```python +from transformers import pipeline +from PIL import Image + +pipe = pipeline("document-question-answering", model="naver-clova-ix/donut-base-finetuned-docvqa") + +question = "What is the purchase amount?" +image = Image.open("your-document.png") + +pipe(image=image, question=question) + +## [{'answer': '20,000$'}] +``` + +## Useful Resources + +Would you like to learn more about Document QA? Awesome! Here are some curated resources that you may find helpful! + +- [Document Visual Question Answering (DocVQA) challenge](https://rrc.cvc.uab.es/?ch=17) +- [DocVQA: A Dataset for Document Visual Question Answering](https://arxiv.org/abs/2007.00398) (Dataset paper) +- [ICDAR 2021 Competition on Document Visual Question Answering](https://lilianweng.github.io/lil-log/2020/10/29/open-domain-question-answering.html) (Conference paper) +- [HuggingFace's Document Question Answering pipeline](https://huggingface.co/docs/transformers/en/main_classes/pipelines#transformers.DocumentQuestionAnsweringPipeline) +- [Github repo: DocQuery - Document Query Engine Powered by Large Language Models](https://github.com/impira/docquery) + +### Notebooks + +- [Fine-tuning Donut on DocVQA dataset](https://github.com/NielsRogge/Transformers-Tutorials/tree/0ea77f29d01217587d7e32a848f3691d9c15d6ab/Donut/DocVQA) +- [Fine-tuning LayoutLMv2 on DocVQA dataset](https://github.com/NielsRogge/Transformers-Tutorials/tree/1b4bad710c41017d07a8f63b46a12523bfd2e835/LayoutLMv2/DocVQA) +- [Accelerating Document AI](https://huggingface.co/blog/document-ai) + +### Documentation + +- [Document question answering task guide](https://huggingface.co/docs/transformers/tasks/document_question_answering) + +The contents of this page are contributed by [Eliott Zemour](https://huggingface.co/eliolio) and reviewed by [Kwadwo Agyapon-Ntra](https://huggingface.co/KayO) and [Ankur Goyal](https://huggingface.co/ankrgyl). diff --git a/node_modules/@huggingface/tasks/src/tasks/document-question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d40cfe613e81a87f8de7cb762df1dbc519809c10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/data.ts @@ -0,0 +1,85 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Largest document understanding dataset.", + id: "HuggingFaceM4/Docmatix", + }, + { + description: + "Dataset from the 2020 DocVQA challenge. The documents are taken from the UCSF Industry Documents Library.", + id: "eliolio/docvqa", + }, + ], + demo: { + inputs: [ + { + label: "Question", + content: "What is the idea behind the consumer relations efficiency team?", + type: "text", + }, + { + filename: "document-question-answering-input.png", + type: "img", + }, + ], + outputs: [ + { + label: "Answer", + content: "Balance cost efficiency with quality customer service", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "The evaluation metric for the DocVQA challenge is the Average Normalized Levenshtein Similarity (ANLS). This metric is flexible to character regognition errors and compares the predicted answer with the ground truth answer.", + id: "anls", + }, + { + description: + "Exact Match is a metric based on the strict character match of the predicted answer and the right answer. For answers predicted correctly, the Exact Match will be 1. Even if only one character is different, Exact Match will be 0", + id: "exact-match", + }, + ], + models: [ + { + description: "A robust document question answering model.", + id: "impira/layoutlm-document-qa", + }, + { + description: "A document question answering model specialized in invoices.", + id: "impira/layoutlm-invoices", + }, + { + description: "A special model for OCR-free document question answering.", + id: "microsoft/udop-large", + }, + { + description: "A powerful model for document question answering.", + id: "google/pix2struct-docvqa-large", + }, + ], + spaces: [ + { + description: "A robust document question answering application.", + id: "impira/docquery", + }, + { + description: "An application that can answer questions from invoices.", + id: "impira/invoices", + }, + { + description: "An application to compare different document question answering models.", + id: "merve/compare_docvqa_models", + }, + ], + summary: + "Document Question Answering (also known as Document Visual Question Answering) is the task of answering questions on document images. Document question answering models take a (document, question) pair as input and return an answer in natural language. Models usually rely on multi-modal features, combining text, position of words (bounding-boxes) and image.", + widgetModels: ["impira/layoutlm-invoices"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/document-question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ec6b58a01167ed1fdcc57d25e456ff51cde4ee2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/inference.ts @@ -0,0 +1,104 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Document Question Answering inference + */ +export interface DocumentQuestionAnsweringInput { + /** + * One (document, question) pair to answer + */ + inputs: DocumentQuestionAnsweringInputData; + /** + * Additional inference parameters for Document Question Answering + */ + parameters?: DocumentQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (document, question) pair to answer + */ +export interface DocumentQuestionAnsweringInputData { + /** + * The image on which the question is asked + */ + image: unknown; + /** + * A question to ask of the document + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Document Question Answering + */ +export interface DocumentQuestionAnsweringParameters { + /** + * If the words in the document are too long to fit with the question for the model, it will + * be split in several chunks with some overlap. This argument controls the size of that + * overlap. + */ + doc_stride?: number; + /** + * Whether to accept impossible as an answer + */ + handle_impossible_answer?: boolean; + /** + * Language to use while running OCR. Defaults to english. + */ + lang?: string; + /** + * The maximum length of predicted answers (e.g., only answers with a shorter length are + * considered). + */ + max_answer_len?: number; + /** + * The maximum length of the question after tokenization. It will be truncated if needed. + */ + max_question_len?: number; + /** + * The maximum length of the total sentence (context + question) in tokens of each chunk + * passed to the model. The context will be split in several chunks (using doc_stride as + * overlap) if needed. + */ + max_seq_len?: number; + /** + * The number of answers to return (will be chosen by order of likelihood). Can return less + * than top_k answers if there are not enough options available within the context. + */ + top_k?: number; + /** + * A list of words and bounding boxes (normalized 0->1000). If provided, the inference will + * skip the OCR step and use the provided bounding boxes instead. + */ + word_boxes?: WordBox[]; + [property: string]: unknown; +} +export type WordBox = number[] | string; +export type DocumentQuestionAnsweringOutput = DocumentQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Document Question Answering task + */ +export interface DocumentQuestionAnsweringOutputElement { + /** + * The answer to the question. + */ + answer: string; + /** + * The end word index of the answer (in the OCR’d version of the input or provided word + * boxes). + */ + end: number; + /** + * The probability associated to the answer. + */ + score: number; + /** + * The start word index of the answer (in the OCR’d version of the input or provided word + * boxes). + */ + start: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..3a8035f71e0abb324de3cb29db9003c71a86b6e6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/input.json @@ -0,0 +1,85 @@ +{ + "$id": "/inference/schemas/document-question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Document Question Answering inference", + "title": "DocumentQuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "description": "One (document, question) pair to answer", + "type": "object", + "title": "DocumentQuestionAnsweringInputData", + "properties": { + "image": { + "description": "The image on which the question is asked", + "comment": "type=binary" + }, + "question": { + "type": "string", + "description": "A question to ask of the document" + } + }, + "required": ["image", "question"] + }, + "parameters": { + "description": "Additional inference parameters for Document Question Answering", + "$ref": "#/$defs/DocumentQuestionAnsweringParameters" + } + }, + "$defs": { + "DocumentQuestionAnsweringParameters": { + "title": "DocumentQuestionAnsweringParameters", + "type": "object", + "properties": { + "doc_stride": { + "type": "integer", + "description": "If the words in the document are too long to fit with the question for the model, it will be split in several chunks with some overlap. This argument controls the size of that overlap." + }, + "handle_impossible_answer": { + "type": "boolean", + "description": "Whether to accept impossible as an answer" + }, + "lang": { + "type": "string", + "description": "Language to use while running OCR. Defaults to english." + }, + "max_answer_len": { + "type": "integer", + "description": "The maximum length of predicted answers (e.g., only answers with a shorter length are considered)." + }, + "max_seq_len": { + "type": "integer", + "description": "The maximum length of the total sentence (context + question) in tokens of each chunk passed to the model. The context will be split in several chunks (using doc_stride as overlap) if needed." + }, + "max_question_len": { + "type": "integer", + "description": "The maximum length of the question after tokenization. It will be truncated if needed." + }, + "top_k": { + "type": "integer", + "description": "The number of answers to return (will be chosen by order of likelihood). Can return less than top_k answers if there are not enough options available within the context." + }, + "word_boxes": { + "type": "array", + "description": "A list of words and bounding boxes (normalized 0->1000). If provided, the inference will skip the OCR step and use the provided bounding boxes instead.", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "number" + }, + "maxLength": 4, + "minLength": 4 + } + ] + } + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f8d0c20fee227973f53321eb97d3c0a0628d2af1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/document-question-answering/spec/output.json @@ -0,0 +1,29 @@ +{ + "$id": "/inference/schemas/document-question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Document Question Answering task", + "title": "DocumentQuestionAnsweringOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer to the question." + }, + "score": { + "type": "number", + "description": "The probability associated to the answer." + }, + "start": { + "type": "integer", + "description": "The start word index of the answer (in the OCR\u2019d version of the input or provided word boxes)." + }, + "end": { + "type": "integer", + "description": "The end word index of the answer (in the OCR\u2019d version of the input or provided word boxes)." + } + }, + "required": ["answer", "score", "start", "end"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/feature-extraction/about.md b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/about.md new file mode 100644 index 0000000000000000000000000000000000000000..1563acc655dd2ea06e42e8d4d3ca7498805c92e3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/about.md @@ -0,0 +1,72 @@ +## Use Cases + +### Transfer Learning + +Models trained on a specific dataset can learn features about the data. For instance, a model trained on an English poetry dataset learns English grammar at a very high level. This information can be transferred to a new model that is going to be trained on tweets. This process of extracting features and transferring to another model is called transfer learning. One can pass their dataset through a feature extraction pipeline and feed the result to a classifier. + +### Retrieval and Reranking + +Retrieval is the process of obtaining relevant documents or information based on a user's search query. In the context of NLP, retrieval systems aim to find relevant text passages or documents from a large corpus of data that match the user's query. The goal is to return a set of results that are likely to be useful to the user. On the other hand, reranking is a technique used to improve the quality of retrieval results by reordering them based on their relevance to the query. + +### Retrieval Augmented Generation + +Retrieval-augmented generation (RAG) is a technique in which user inputs to generative models are first queried through a knowledge base, and the most relevant information from the knowledge base is used to augment the prompt to reduce hallucinations during generation. Feature extraction models (primarily retrieval and reranking models) can be used in RAG to reduce model hallucinations and ground the model. + +## Inference + +You can infer feature extraction models using `pipeline` of transformers library. + +```python +from transformers import pipeline +checkpoint = "facebook/bart-base" +feature_extractor = pipeline("feature-extraction", framework="pt", model=checkpoint) +text = "Transformers is an awesome library!" + +#Reducing along the first dimension to get a 768 dimensional array +feature_extractor(text,return_tensors = "pt")[0].numpy().mean(axis=0) + +'''tensor([[[ 2.5834, 2.7571, 0.9024, ..., 1.5036, -0.0435, -0.8603], + [-1.2850, -1.0094, -2.0826, ..., 1.5993, -0.9017, 0.6426], + [ 0.9082, 0.3896, -0.6843, ..., 0.7061, 0.6517, 1.0550], + ..., + [ 0.6919, -1.1946, 0.2438, ..., 1.3646, -1.8661, -0.1642], + [-0.1701, -2.0019, -0.4223, ..., 0.3680, -1.9704, -0.0068], + [ 0.2520, -0.6869, -1.0582, ..., 0.5198, -2.2106, 0.4547]]])''' +``` + +A very popular library for training similarity and search models is called `sentence-transformers`.  To get started, install the library. + +```bash +pip install -U sentence-transformers +``` + +You can infer with `sentence-transformers` models as follows. + +```python +from sentence_transformers import SentenceTransformer + +model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") +sentences = [ + "The weather is lovely today.", + "It's so sunny outside!", + "He drove to the stadium.", +] + +embeddings = model.encode(sentences) +similarities = model.similarity(embeddings, embeddings) +print(similarities) +# tensor([[1.0000, 0.6660, 0.1046], +# [0.6660, 1.0000, 0.1411], +# [0.1046, 0.1411, 1.0000]]) +``` + +### Text Embedding Inference + +[Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference) is a toolkit to easily serve feature extraction models using few lines of code. + +## Useful resources + +- [Documentation for feature extraction task in 🤗Transformers](https://huggingface.co/docs/transformers/main_classes/feature_extractor) +- [Introduction to MTEB Benchmark](https://huggingface.co/blog/mteb) +- [Cookbook: Simple RAG for GitHub issues using Hugging Face Zephyr and LangChain](https://huggingface.co/learn/cookbook/rag_zephyr_langchain) +- [sentence-transformers organization on Hugging Face Hub](https://huggingface.co/sentence-transformers) diff --git a/node_modules/@huggingface/tasks/src/tasks/feature-extraction/data.ts b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..75f5d6f5ed3965e462c4e0205c90a148d336509d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/data.ts @@ -0,0 +1,57 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "Wikipedia dataset containing cleaned articles of all languages. Can be used to train `feature-extraction` models.", + id: "wikipedia", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "India, officially the Republic of India, is a country in South Asia.", + type: "text", + }, + ], + outputs: [ + { + table: [ + ["Dimension 1", "Dimension 2", "Dimension 3"], + ["2.583383083343506", "2.757075071334839", "0.9023529887199402"], + ["8.29393482208252", "1.1071064472198486", "2.03399395942688"], + ["-0.7754912972450256", "-1.647324562072754", "-0.6113331913948059"], + ["0.07087723910808563", "1.5942802429199219", "1.4610432386398315"], + ], + type: "tabular", + }, + ], + }, + metrics: [], + models: [ + { + description: "A powerful feature extraction model for natural language processing tasks.", + id: "thenlper/gte-large", + }, + { + description: "A strong feature extraction model for retrieval.", + id: "Alibaba-NLP/gte-Qwen1.5-7B-instruct", + }, + ], + spaces: [ + { + description: "A leaderboard to rank text feature extraction models based on a benchmark.", + id: "mteb/leaderboard", + }, + { + description: "A leaderboard to rank best feature extraction models based on human feedback.", + id: "mteb/arena", + }, + ], + summary: "Feature extraction is the task of extracting features learnt in a model.", + widgetModels: ["facebook/bart-base"], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/feature-extraction/inference.ts b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..f60bef611339dc786a7e179f9d80a0434452b4a2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/inference.ts @@ -0,0 +1,41 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +export type FeatureExtractionOutput = Array; +/** + * Feature Extraction Input. + * + * Auto-generated from TEI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts. + */ +export interface FeatureExtractionInput { + /** + * The text or list of texts to embed. + */ + inputs: FeatureExtractionInputs; + normalize?: boolean; + /** + * The name of the prompt that should be used by for encoding. If not set, no prompt + * will be applied. + * + * Must be a key in the `sentence-transformers` configuration `prompts` dictionary. + * + * For example if ``prompt_name`` is "query" and the ``prompts`` is {"query": "query: ", + * ...}, + * then the sentence "What is the capital of France?" will be encoded as + * "query: What is the capital of France?" because the prompt text will be prepended before + * any text to encode. + */ + prompt_name?: string; + truncate?: boolean; + truncation_direction?: FeatureExtractionInputTruncationDirection; + [property: string]: unknown; +} +/** + * The text or list of texts to embed. + */ +export type FeatureExtractionInputs = string[] | string; +export type FeatureExtractionInputTruncationDirection = "left" | "right"; diff --git a/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..1b386746f71ab88db1e1ab1c62343e7b72899d69 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/input.json @@ -0,0 +1,58 @@ +{ + "$id": "/inference/schemas/feature-extraction/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Feature Extraction Input.\n\nAuto-generated from TEI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts.", + "title": "FeatureExtractionInput", + "type": "object", + "required": ["inputs"], + "properties": { + "inputs": { + "title": "FeatureExtractionInputs", + "description": "The text or list of texts to embed.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "normalize": { + "type": "boolean", + "default": "true", + "example": "true" + }, + "prompt_name": { + "type": "string", + "description": "The name of the prompt that should be used by for encoding. If not set, no prompt\nwill be applied.\n\nMust be a key in the `sentence-transformers` configuration `prompts` dictionary.\n\nFor example if ``prompt_name`` is \"query\" and the ``prompts`` is {\"query\": \"query: \", ...},\nthen the sentence \"What is the capital of France?\" will be encoded as\n\"query: What is the capital of France?\" because the prompt text will be prepended before\nany text to encode.", + "default": "null", + "example": "null", + "nullable": true + }, + "truncate": { + "type": "boolean", + "default": "false", + "example": "false", + "nullable": true + }, + "truncation_direction": { + "allOf": [ + { + "$ref": "#/$defs/FeatureExtractionInputTruncationDirection" + } + ], + "default": "right" + } + }, + "$defs": { + "FeatureExtractionInputTruncationDirection": { + "type": "string", + "enum": ["left", "right"], + "title": "FeatureExtractionInputTruncationDirection" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..591fe9c64828712f67d579b5356a1ede5f23fdb9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/feature-extraction/spec/output.json @@ -0,0 +1,15 @@ +{ + "$id": "/inference/schemas/feature-extraction/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Feature Extraction Output.\n\nAuto-generated from TEI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts.", + "title": "FeatureExtractionOutput", + "type": "array", + "$defs": {}, + "items": { + "type": "array", + "items": { + "type": "number", + "format": "float" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/about.md b/node_modules/@huggingface/tasks/src/tasks/fill-mask/about.md new file mode 100644 index 0000000000000000000000000000000000000000..4fabd3cf6d06d8ba9e676eb1f637c5f688b456fb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/about.md @@ -0,0 +1,51 @@ +## Use Cases + +### Domain Adaptation 👩‍⚕️ + +Masked language models do not require labelled data! They are trained by masking a couple of words in sentences and the model is expected to guess the masked word. This makes it very practical! + +For example, masked language modeling is used to train large models for domain-specific problems. If you have to work on a domain-specific task, such as retrieving information from medical research papers, you can train a masked language model using those papers. 📄 + +The resulting model has a statistical understanding of the language used in medical research papers, and can be further trained in a process called fine-tuning to solve different tasks, such as [Text Classification](/tasks/text-classification) or [Question Answering](/tasks/question-answering) to build a medical research papers information extraction system. 👩‍⚕️ Pre-training on domain-specific data tends to yield better results (see [this paper](https://arxiv.org/abs/2007.15779) for an example). + +If you don't have the data to train a masked language model, you can also use an existing [domain-specific masked language model](https://huggingface.co/microsoft/BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext) from the Hub and fine-tune it with your smaller task dataset. That's the magic of Open Source and sharing your work! 🎉 + +## Inference with Fill-Mask Pipeline + +You can use the 🤗 Transformers library `fill-mask` pipeline to do inference with masked language models. If a model name is not provided, the pipeline will be initialized with [distilroberta-base](/distilroberta-base). You can provide masked text and it will return a list of possible mask values ​​ranked according to the score. + +```python +from transformers import pipeline + +classifier = pipeline("fill-mask") +classifier("Paris is the of France.") + +# [{'score': 0.7, 'sequence': 'Paris is the capital of France.'}, +# {'score': 0.2, 'sequence': 'Paris is the birthplace of France.'}, +# {'score': 0.1, 'sequence': 'Paris is the heart of France.'}] +``` + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that can be helpful to you! + +- [Course Chapter on Fine-tuning a Masked Language Model](https://huggingface.co/course/chapter7/3?fw=pt) +- [Workshop on Pretraining Language Models and CodeParrot](https://www.youtube.com/watch?v=ExUR7w6xe94) +- [BERT 101: State Of The Art NLP Model Explained](https://huggingface.co/blog/bert-101) +- [Nyströmformer: Approximating self-attention in linear time and memory via the Nyström method](https://huggingface.co/blog/nystromformer) + +### Notebooks + +- [Pre-training an MLM for JAX/Flax](https://github.com/huggingface/notebooks/blob/master/examples/masked_language_modeling_flax.ipynb) +- [Masked language modeling in TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling-tf.ipynb) +- [Masked language modeling in PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling) + +### Documentation + +- [Masked language modeling task guide](https://huggingface.co/docs/transformers/tasks/masked_language_modeling) diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/data.ts b/node_modules/@huggingface/tasks/src/tasks/fill-mask/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c38bf6be0f8ee8d84a7d2ca986fdbd53e0134bc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/data.ts @@ -0,0 +1,79 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A common dataset that is used to train models for many languages.", + id: "wikipedia", + }, + { + description: "A large English dataset with text crawled from the web.", + id: "c4", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "The barked at me", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "wolf", + score: 0.487, + }, + { + label: "dog", + score: 0.061, + }, + { + label: "cat", + score: 0.058, + }, + { + label: "fox", + score: 0.047, + }, + { + label: "squirrel", + score: 0.025, + }, + ], + }, + ], + }, + metrics: [ + { + description: + "Cross Entropy is a metric that calculates the difference between two probability distributions. Each probability distribution is the distribution of predicted words", + id: "cross_entropy", + }, + { + description: + "Perplexity is the exponential of the cross-entropy loss. It evaluates the probabilities assigned to the next word by the model. Lower perplexity indicates better performance", + id: "perplexity", + }, + ], + models: [ + { + description: "State-of-the-art masked language model.", + id: "answerdotai/ModernBERT-large", + }, + { + description: "A multilingual model trained on 100 languages.", + id: "FacebookAI/xlm-roberta-base", + }, + ], + spaces: [], + summary: + "Masked language modeling is the task of masking some of the words in a sentence and predicting which words should replace those masks. These models are useful when we want to get a statistical understanding of the language in which the model is trained in.", + widgetModels: ["distilroberta-base"], + youtubeId: "mqElG5QJWUg", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/inference.ts b/node_modules/@huggingface/tasks/src/tasks/fill-mask/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f48bb55ee981393d31e5a0d1146db673a6081d6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Fill Mask inference + */ +export interface FillMaskInput { + /** + * The text with masked tokens + */ + inputs: string; + /** + * Additional inference parameters for Fill Mask + */ + parameters?: FillMaskParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Fill Mask + */ +export interface FillMaskParameters { + /** + * When passed, the model will limit the scores to the passed targets instead of looking up + * in the whole vocabulary. If the provided targets are not in the model vocab, they will be + * tokenized and the first resulting token will be used (with a warning, and that might be + * slower). + */ + targets?: string[]; + /** + * When passed, overrides the number of predictions to return. + */ + top_k?: number; + [property: string]: unknown; +} +export type FillMaskOutput = FillMaskOutputElement[]; +/** + * Outputs of inference for the Fill Mask task + */ +export interface FillMaskOutputElement { + /** + * The corresponding probability + */ + score: number; + /** + * The corresponding input with the mask token prediction. + */ + sequence: string; + /** + * The predicted token id (to replace the masked one). + */ + token: number; + tokenStr: unknown; + /** + * The predicted token (to replace the masked one). + */ + token_str?: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ebaf13e16212e29df8ec3c552071fca7d6078c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json @@ -0,0 +1,37 @@ +{ + "$id": "/inference/schemas/fill-mask/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Fill Mask inference", + "title": "FillMaskInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text with masked tokens", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Fill Mask", + "$ref": "#/$defs/FillMaskParameters" + } + }, + "$defs": { + "FillMaskParameters": { + "title": "FillMaskParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "When passed, overrides the number of predictions to return." + }, + "targets": { + "description": "When passed, the model will limit the scores to the passed targets instead of looking up in the whole vocabulary. If the provided targets are not in the model vocab, they will be tokenized and the first resulting token will be used (with a warning, and that might be slower).", + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..0b613382e781cf0405c76df5c1f9f5091da6b196 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json @@ -0,0 +1,29 @@ +{ + "$id": "/inference/schemas/fill-mask/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Fill Mask task", + "title": "FillMaskOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "sequence": { + "type": "string", + "description": "The corresponding input with the mask token prediction." + }, + "score": { + "type": "number", + "description": "The corresponding probability" + }, + "token": { + "type": "integer", + "description": "The predicted token id (to replace the masked one)." + }, + "token_str": { + "type": "string", + "description": "The predicted token (to replace the masked one)." + } + }, + "required": ["sequence", "score", "token", "tokenStr"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..6d2b445fa62b8fcd88fb738820e0c18e327460be --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md @@ -0,0 +1,50 @@ +## Use Cases + +Image classification models can be used when we are not interested in specific instances of objects with location information or their shape. + +### Keyword Classification + +Image classification models are used widely in stock photography to assign each image a keyword. + +### Image Search + +Models trained in image classification can improve user experience by organizing and categorizing photo galleries on the phone or in the cloud, on multiple keywords or tags. + +## Inference + +With the `transformers` library, you can use the `image-classification` pipeline to infer with image classification models. You can initialize the pipeline with a model id from the Hub. If you do not provide a model id it will initialize with [google/vit-base-patch16-224](https://huggingface.co/google/vit-base-patch16-224) by default. When calling the pipeline you just need to specify a path, http link or an image loaded in PIL. You can also provide a `top_k` parameter which determines how many results it should return. + +```python +from transformers import pipeline +clf = pipeline("image-classification") +clf("path_to_a_cat_image") + +[{'label': 'tabby cat', 'score': 0.731}, +... +] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to classify images using models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageClassification({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "microsoft/resnet-50", +}); +``` + +## Useful Resources + +- [Let's Play Pictionary with Machine Learning!](https://www.youtube.com/watch?v=LS9Y2wDVI0k) +- [Fine-Tune ViT for Image Classification with 🤗Transformers](https://huggingface.co/blog/fine-tune-vit) +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [Computer Vision Study Group: Swin Transformer](https://www.youtube.com/watch?v=Ngikt-K1Ecc) +- [Computer Vision Study Group: Masked Autoencoders Paper Walkthrough](https://www.youtube.com/watch?v=Ngikt-K1Ecc) +- [Image classification task guide](https://huggingface.co/docs/transformers/tasks/image_classification) + +### Creating your own image classifier in just a few minutes + +With [HuggingPics](https://github.com/nateraw/huggingpics), you can fine-tune Vision Transformers for anything using images found on the web. This project downloads images of classes defined by you, trains a model, and pushes it to the Hub. You even get to try out the model directly with a working widget in the browser, ready to be shared with all your friends! diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..acdb201e3286a7aa3a73f1a77010e4f735696353 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts @@ -0,0 +1,87 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Benchmark dataset used for image classification with images that belong to 100 classes.", + id: "cifar100", + }, + { + // TODO write proper description + description: "Dataset consisting of images of garments.", + id: "fashion_mnist", + }, + ], + demo: { + inputs: [ + { + filename: "image-classification-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Egyptian cat", + score: 0.514, + }, + { + label: "Tabby cat", + score: 0.193, + }, + { + label: "Tiger cat", + score: 0.068, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "A strong image classification model.", + id: "google/vit-base-patch16-224", + }, + { + description: "A robust image classification model.", + id: "facebook/deit-base-distilled-patch16-224", + }, + { + description: "A strong image classification model.", + id: "facebook/convnext-large-224", + }, + ], + spaces: [ + { + description: "A leaderboard to evaluate different image classification models.", + id: "timm/leaderboard", + }, + ], + summary: + "Image classification is the task of assigning a label or class to an entire image. Images are expected to have only one class for each image. Image classification models take an image as input and return a prediction about which class the image belongs to.", + widgetModels: ["google/vit-base-patch16-224"], + youtubeId: "tjAIM7BOYhw", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..923fbfec0e7568e07918d9c650fc4dec73837b99 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Classification inference + */ +export interface ImageClassificationInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image Classification + */ + parameters?: ImageClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Classification + */ +export interface ImageClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type ImageClassificationOutput = ImageClassificationOutputElement[]; +/** + * Outputs of inference for the Image Classification task + */ +export interface ImageClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..4942226d2963287bb4fad878b8856d37e0dde36f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json @@ -0,0 +1,36 @@ +{ + "$id": "/inference/schemas/image-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Classification inference", + "title": "ImageClassificationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Classification", + "$ref": "#/$defs/ImageClassificationParameters" + } + }, + "$defs": { + "ImageClassificationParameters": { + "title": "ImageClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "ImageClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..3ababaf63d47baf941b1f290891367ce2f43794f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/image-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Classification task", + "title": "ImageClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9a968b106d527b16556f907c09e6cf67c610f7eb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md @@ -0,0 +1,23 @@ +## Use Cases + +### Transfer Learning + +Models trained on a specific dataset can learn features about the data. For instance, a model trained on a car classification dataset learns to recognize edges and curves on a very high level and car-specific features on a low level. This information can be transferred to a new model that is going to be trained on classifying trucks. This process of extracting features and transferring to another model is called transfer learning. + +### Similarity + +Features extracted from models contain semantically meaningful information about the world. These features can be used to detect the similarity between two images. Assume there are two images: a photo of a stray cat in a street setting and a photo of a cat at home. These images both contain cats, and the features will contain the information that there's a cat in the image. Thus, comparing the features of a stray cat photo to the features of a domestic cat photo will result in higher similarity compared to any other image that doesn't contain any cats. + +## Inference + +```python +import torch +from transformers import pipeline + +pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-384", framework="pt", pool=True) +pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/cats.png") + +feature_extractor(text,return_tensors = "pt")[0].numpy().mean(axis=0) + +'[[[0.21236686408519745, 1.0919708013534546, 0.8512550592422485, ...]]]' +``` diff --git a/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2565dec61e6b089fe5f62bd97f4abe36e008943 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts @@ -0,0 +1,64 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "ImageNet-1K is a image classification dataset in which images are used to train image-feature-extraction models.", + id: "imagenet-1k", + }, + ], + demo: { + inputs: [ + { + filename: "mask-generation-input.png", + type: "img", + }, + ], + outputs: [ + { + table: [ + ["Dimension 1", "Dimension 2", "Dimension 3"], + ["0.21236686408519745", "1.0919708013534546", "0.8512550592422485"], + ["0.809657871723175", "-0.18544459342956543", "-0.7851548194885254"], + ["1.3103108406066895", "-0.2479034662246704", "-0.9107287526130676"], + ["1.8536205291748047", "-0.36419737339019775", "0.09717650711536407"], + ], + type: "tabular", + }, + ], + }, + metrics: [], + models: [ + { + description: "A powerful image feature extraction model.", + id: "timm/vit_large_patch14_dinov2.lvd142m", + }, + { + description: "A strong image feature extraction model.", + id: "nvidia/MambaVision-T-1K", + }, + { + description: "A robust image feature extraction model.", + id: "facebook/dino-vitb16", + }, + { + description: "Cutting-edge image feature extraction model.", + id: "apple/aimv2-large-patch14-336-distilled", + }, + { + description: "Strong image feature extraction model that can be used on images and documents.", + id: "OpenGVLab/InternViT-6B-448px-V1-2", + }, + ], + spaces: [ + { + description: "A leaderboard to evaluate different image-feature-extraction models on classification performances", + id: "timm/leaderboard", + }, + ], + summary: "Image feature extraction is the task of extracting features learnt in a computer vision model.", + widgetModels: [], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..18af58ad8628bd12e4c16f9f3f17667fe1821414 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md @@ -0,0 +1,63 @@ +## Use Cases + +### Autonomous Driving + +Segmentation models are used to identify road patterns such as lanes and obstacles for safer driving. + +### Background Removal + +Image Segmentation models are used in cameras to erase the background of certain objects and apply filters to them. + +### Medical Imaging + +Image Segmentation models are used to distinguish organs or tissues, improving medical imaging workflows. Models are used to segment dental instances, analyze X-Ray scans or even segment cells for pathological diagnosis. This [dataset](https://github.com/v7labs/covid-19-xray-dataset) contains images of lungs of healthy patients and patients with COVID-19 segmented with masks. Another [segmentation dataset](https://ivdm3seg.weebly.com/data.html) contains segmented MRI data of the lower spine to analyze the effect of spaceflight simulation. + +## Task Variants + +### Semantic Segmentation + +Semantic Segmentation is the task of segmenting parts of an image that belong to the same class. Semantic Segmentation models make predictions for each pixel and return the probabilities of the classes for each pixel. These models are evaluated on Mean Intersection Over Union (Mean IoU). + +### Instance Segmentation + +Instance Segmentation is the variant of Image Segmentation where every distinct object is segmented, instead of one segment per class. + +### Panoptic Segmentation + +Panoptic Segmentation is the Image Segmentation task that segments the image both by instance and by class, assigning each pixel a different instance of the class. + +## Inference + +You can infer with Image Segmentation models using the `image-segmentation` pipeline. You need to install [timm](https://github.com/rwightman/pytorch-image-models) first. + +```python +!pip install timm +model = pipeline("image-segmentation") +model("cat.png") +#[{'label': 'cat', +# 'mask': mask_code, +# 'score': 0.999} +# ...] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image segmentation models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageSegmentation({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "facebook/mask2former-swin-base-coco-panoptic", +}); +``` + +## Useful Resources + +Would you like to learn more about image segmentation? Great! Here you can find some curated resources that you may find helpful! + +- [Fine-Tune a Semantic Segmentation Model with a Custom Dataset](https://huggingface.co/blog/fine-tune-segformer) +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [A Guide on Universal Image Segmentation with Mask2Former and OneFormer](https://huggingface.co/blog/mask2former) +- [Zero-shot image segmentation with CLIPSeg](https://huggingface.co/blog/clipseg-zero-shot) +- [Semantic segmentation task guide](https://huggingface.co/docs/transformers/tasks/semantic_segmentation) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c34481f9acf7c67ecd9cf6700a4858de83340c98 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts @@ -0,0 +1,99 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Scene segmentation dataset.", + id: "scene_parse_150", + }, + ], + demo: { + inputs: [ + { + filename: "image-segmentation-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-segmentation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Average Precision (AP) is the Area Under the PR Curve (AUC-PR). It is calculated for each semantic class separately", + id: "Average Precision", + }, + { + description: "Mean Average Precision (mAP) is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "Intersection over Union (IoU) is the overlap of segmentation masks. Mean IoU is the average of the IoU of all semantic classes", + id: "Mean Intersection over Union", + }, + { + description: "APα is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + // TO DO: write description + description: "Solid panoptic segmentation model trained on COCO.", + id: "tue-mps/coco_panoptic_eomt_large_640", + }, + { + description: "Background removal model.", + id: "briaai/RMBG-1.4", + }, + { + description: "A multipurpose image segmentation model for high resolution images.", + id: "ZhengPeng7/BiRefNet", + }, + { + description: "Powerful human-centric image segmentation model.", + id: "facebook/sapiens-seg-1b", + }, + { + description: "Panoptic segmentation model trained on the COCO (common objects) dataset.", + id: "facebook/mask2former-swin-large-coco-panoptic", + }, + ], + spaces: [ + { + description: "A semantic segmentation application that can predict unseen instances out of the box.", + id: "facebook/ov-seg", + }, + { + description: "One of the strongest segmentation applications.", + id: "jbrinkma/segment-anything", + }, + { + description: "A human-centric segmentation model.", + id: "facebook/sapiens-pose", + }, + { + description: "An instance segmentation application to predict neuronal cell types from microscopy images.", + id: "rashmi/sartorius-cell-instance-segmentation", + }, + { + description: "An application that segments videos.", + id: "ArtGAN/Segment-Anything-Video", + }, + { + description: "An panoptic segmentation application built for outdoor environments.", + id: "segments/panoptic-segment-anything", + }, + ], + summary: + "Image Segmentation divides an image into segments where each pixel in the image is mapped to an object. This task has multiple variants such as instance segmentation, panoptic segmentation and semantic segmentation.", + widgetModels: ["nvidia/segformer-b0-finetuned-ade-512-512"], + youtubeId: "dKE8SIt9C-w", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..72db730745c3ce37b2bfe38f211c5620c9feb8f8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts @@ -0,0 +1,67 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Segmentation inference + */ +export interface ImageSegmentationInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image Segmentation + */ + parameters?: ImageSegmentationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Segmentation + */ +export interface ImageSegmentationParameters { + /** + * Threshold to use when turning the predicted masks into binary values. + */ + mask_threshold?: number; + /** + * Mask overlap threshold to eliminate small, disconnected segments. + */ + overlap_mask_area_threshold?: number; + /** + * Segmentation task to be performed, depending on model capabilities. + */ + subtask?: ImageSegmentationSubtask; + /** + * Probability threshold to filter out predicted masks. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * Segmentation task to be performed, depending on model capabilities. + */ +export type ImageSegmentationSubtask = "instance" | "panoptic" | "semantic"; +export type ImageSegmentationOutput = ImageSegmentationOutputElement[]; +/** + * Outputs of inference for the Image Segmentation task + * + * A predicted mask / segment + */ +export interface ImageSegmentationOutputElement { + /** + * The label of the predicted segment. + */ + label: string; + /** + * The corresponding mask as a black-and-white image (base64-encoded). + */ + mask: string; + /** + * The score or confidence degree the model has. + */ + score?: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..afc40ad2db5c70d8234cfa8063be31669e9a4b7b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json @@ -0,0 +1,45 @@ +{ + "$id": "/inference/schemas/image-segmentation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Segmentation inference", + "title": "ImageSegmentationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Segmentation", + "$ref": "#/$defs/ImageSegmentationParameters" + } + }, + "$defs": { + "ImageSegmentationParameters": { + "title": "ImageSegmentationParameters", + "type": "object", + "properties": { + "mask_threshold": { + "type": "number", + "description": "Threshold to use when turning the predicted masks into binary values." + }, + "overlap_mask_area_threshold": { + "type": "number", + "description": "Mask overlap threshold to eliminate small, disconnected segments." + }, + "subtask": { + "title": "ImageSegmentationSubtask", + "type": "string", + "description": "Segmentation task to be performed, depending on model capabilities.", + "enum": ["instance", "panoptic", "semantic"] + }, + "threshold": { + "type": "number", + "description": "Probability threshold to filter out predicted masks." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..6fa5b0d8e83ad97a63f6dc2da6588ccc5bd58097 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json @@ -0,0 +1,26 @@ +{ + "$id": "/inference/schemas/image-segmentation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Segmentation task", + "title": "ImageSegmentationOutput", + "type": "array", + "items": { + "description": "A predicted mask / segment", + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The label of the predicted segment." + }, + "mask": { + "type": "string", + "description": "The corresponding mask as a black-and-white image (base64-encoded)." + }, + "score": { + "type": "number", + "description": "The score or confidence degree the model has." + } + }, + "required": ["label", "mask"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..c05a81fceaa340b66faf52732d1f4926a4e803e4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md @@ -0,0 +1,73 @@ +## Use Cases + +### Instruction-based Image Editing + +Image-text-to-image models can be used to edit images based on natural language instructions. For example, you can provide an image of a summer landscape and the instruction "Make it winter, add snow" to generate a winter version of the same scene. + +### Style Transfer + +These models can apply artistic styles or transformations to images based on text descriptions. For instance, you can transform a photo into a painting style by providing prompts like "Make it look like a Van Gogh painting" or "Convert to watercolor style." + +### Image Variations + +Generate variations of an existing image by providing different text prompts. This is useful for creative workflows where you want to explore different versions of the same image with specific modifications. + +### Guided Image Generation + +Use a reference image along with text prompts to guide the generation process. This allows for more controlled image generation compared to text-to-image models alone, as the reference image provides structural guidance. + +### Image Inpainting and Outpainting + +Fill in missing or masked parts of an image based on text descriptions, or extend an image beyond its original boundaries with text-guided generation. + +## Task Variants + +### Instruction-based Editing + +Models that follow natural language instructions to edit images, which can perform complex edits like object removal, color changes, and compositional modifications. + +### Reference-guided Generation + +Models that use a reference image to guide the generation process while incorporating text prompts to control specific attributes or modifications. + +### Conditional Image-to-Image + +Models that perform specific transformations based on text conditions, such as changing weather conditions, time of day, or seasonal variations. + +## Inference + +You can use the Diffusers library to interact with image-text-to-image models. + +```python +import torch +from diffusers import Flux2Pipeline +from diffusers.utils import load_image + +repo_id = "black-forest-labs/FLUX.2-dev" +device = "cuda:0" +torch_dtype = torch.bfloat16 + +pipe = Flux2Pipeline.from_pretrained( + repo_id, torch_dtype=torch_dtype +) +pipe.enable_model_cpu_offload() #no need to do cpu offload for >80G VRAM carts like H200, B200, etc. and do a `pipe.to(device)` instead + +prompt = "Realistic macro photograph of a hermit crab using a soda can as its shell, partially emerging from the can, captured with sharp detail and natural colors, on a sunlit beach with soft shadows and a shallow depth of field, with blurred ocean waves in the background. The can has the text `BFL Diffusers` on it and it has a color gradient that start with #FF5733 at the top and transitions to #33FF57 at the bottom." + +#cat_image = load_image("https://huggingface.co/spaces/zerogpu-aoti/FLUX.1-Kontext-Dev-fp8-dynamic/resolve/main/cat.png") +image = pipe( + prompt=prompt, + #image=[cat_image] #multi-image input + generator=torch.Generator(device=device).manual_seed(42), + num_inference_steps=50, + guidance_scale=4, +).images[0] + +image.save("flux2_output.png") +``` + +## Useful Resources + +- [FLUX.2 Model Card](https://huggingface.co/black-forest-labs/FLUX.2-dev) +- [Diffusers documentation on Image-to-Image](https://huggingface.co/docs/diffusers/using-diffusers/img2img) +- [ControlNet for Conditional Image Generation](https://huggingface.co/docs/diffusers/using-diffusers/controlnet) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..f45410e91cddf0bca75166f449d8b4c17317281d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts @@ -0,0 +1,54 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-image-input.jpeg", + type: "img", + }, + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-image-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: + "CLIP Score measures the similarity between the generated image and the text prompt using CLIP embeddings. A higher score indicates better alignment with the text prompt.", + id: "CLIP", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + spaces: [ + { + description: "An application for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + summary: + "Image-text-to-image models take an image and a text prompt as input and generate a new image based on the reference image and text instructions. These models are useful for image editing, style transfer, image variations, and guided image generation tasks.", + widgetModels: ["black-forest-labs/FLUX.2-dev"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..549b0f4118b8c142a22adfdb950d8947c4d3c4be --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts @@ -0,0 +1,75 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Image + */ + parameters?: ImageTextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Image + */ +export interface ImageTextToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Image task + */ +export interface ImageTextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..259353e337d7db9d6b479eb7e5f91f7df8364e2c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json @@ -0,0 +1,59 @@ +{ + "$id": "/inference/schemas/image-text-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters) must be provided, or both.", + "title": "ImageTextToImageInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload. Either this or prompt must be provided.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Text To Image", + "$ref": "#/$defs/ImageTextToImageParameters" + } + }, + "$defs": { + "ImageTextToImageParameters": { + "title": "ImageTextToImageParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the image generation. Either this or inputs (image) must be provided." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "target_size": { + "type": "object", + "description": "The size in pixels of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f5b782b6253ee6b9f35f1f4acc2d6513d03ce135 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-text-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Text To Image task", + "title": "ImageTextToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The generated image returned as raw bytes in the payload." + } + }, + "required": ["image"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..8595509bb4cc7f85bf3a7d91d668e79e3e41367c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md @@ -0,0 +1,94 @@ +## Different Types of Vision Language Models + +Vision language models come in three types: + +- **Base:** Pre-trained models that can be fine-tuned. A good example of base models is the [PaliGemma models family](https://huggingface.co/models?sort=trending&search=google%2Fpaligemma-3b-pt) by Google. +- **Instruction:** Base models fine-tuned on instruction datasets. A good example of instruction fine-tuned models is [idefics2-8b](https://huggingface.co/HuggingFaceM4/idefics2-8b). +- **Chatty/Conversational:** Base models fine-tuned on conversation datasets. A good example of chatty models is [deepseek-vl-7b-chat](https://huggingface.co/deepseek-ai/deepseek-vl-7b-chat). + +![VLM uses](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vlm/visual.jpg) + +## Use Cases + +### Multimodal Dialogue + +Vision language models can be used as multimodal assistants, keeping context about the conversation and keeping the image to have multiple-turn dialogues. + +### Zero-shot Object Detection, Image Segmentation and Localization + +Some vision language models can detect or segment a set of objects or describe the positions or relative positions of the objects. For example, one could prompt such a model to ask if one object is behind another. Such a model can also output bounding box coordination or segmentation masks directly in the text output, unlike the traditional models explicitly trained on only object detection or image segmentation. + +### Visual Question Answering + +Vision language models trained on image-text pairs can be used for visual question answering and generating captions for images. + +### Document Question Answering and Retrieval + +Documents often consist of different layouts, charts, tables, images, and more. Vision language models trained on formatted documents can extract information from them. This is an OCR-free approach; the inputs skip OCR, and documents are directly fed to vision language models. To find the relevant documents to be fed, models like [ColPali](https://huggingface.co/blog/manu/colpali) are used. An example workflow can be found [here](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb). + +### Image Recognition with Instructions + +Vision language models can recognize images through descriptions. When given detailed descriptions of specific entities, it can classify the entities in an image. + +### Computer Use + +Image-text-to-text models can be used to control computers with agentic workflows. Models like [ShowUI](https://huggingface.co/showlab/ShowUI-2B) and [OmniParser](https://huggingface.co/microsoft/OmniParser) are used to parse screenshots to later take actions on the computer autonomously. + +## Inference + +You can use the Transformers library to interact with [vision-language models](https://huggingface.co/models?pipeline_tag=image-text-to-text&transformers). Specifically, `pipeline` makes it easy to infer models. + +Initialize the pipeline first. + +```python +from transformers import pipeline + +pipe = pipeline("image-text-to-text", model="llava-hf/llava-interleave-qwen-0.5b-hf") +``` + +The model's built-in chat template will be used to format the conversational input. We can pass the image as an URL in the `content` part of the user message: + +```python +messages = [ + { + "role": "user", + "content": [ + { + "type": "image", + "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg", + }, + {"type": "text", "text": "Describe this image."}, + ], + } + ] + +``` + +We can now directly pass in the messages to the pipeline to infer. The `return_full_text` flag is used to return the full prompt in the response, including the user input. Here we pass `False` to only return the generated text. + +```python +outputs = pipe(text=messages, max_new_tokens=60, return_full_text=False) + +outputs[0]["generated_text"] +# The image captures a moment of tranquility in nature. At the center of the frame, a pink flower with a yellow center is in full bloom. The flower is surrounded by a cluster of red flowers, their vibrant color contrasting with the pink of the flower. \n\nA black and yellow bee is per +``` + +You can also use the Inference API to test image-text-to-text models. You need to use a [Hugging Face token](https://huggingface.co/settings/tokens) for authentication. + +```bash +curl https://router.huggingface.co/hf-inference/models/meta-llama/Llama-3.2-11B-Vision-Instruct \ + -X POST \ + -d '{"messages": [{"role": "user","content": [{"type": "image"}, {"type": "text", "text": "Can you describe the image?"}]}]}' \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer hf_***" +``` + +## Useful Resources + +- [Vision Language Models (Better, Faster, Stronger)](https://huggingface.co/blog/vlms-2025) +- [Vision Language Models Explained](https://huggingface.co/blog/vlms) +- [Welcome PaliGemma 2 – New vision language models by Google](https://huggingface.co/blog/paligemma2) +- [SmolVLM - small yet mighty Vision Language Model](https://huggingface.co/blog/smolvlm) +- [Multimodal RAG using ColPali and Qwen2-VL](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb) +- [Preference Optimization for Vision Language Models with TRL](https://huggingface.co/blog/dpo_vlm) +- [Image-text-to-text task guide](https://huggingface.co/docs/transformers/tasks/image_text_to_text) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1fbaed2dcf9c1fe15621f494e0814370ab281b6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts @@ -0,0 +1,86 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Instructions composed of image and text.", + id: "liuhaotian/LLaVA-Instruct-150K", + }, + { + description: "Collection of image-text pairs on scientific topics.", + id: "DAMO-NLP-SG/multimodal_textbook", + }, + { + description: "A collection of datasets made for model fine-tuning.", + id: "HuggingFaceM4/the_cauldron", + }, + { + description: "Screenshots of websites with their HTML/CSS codes.", + id: "HuggingFaceM4/WebSight", + }, + ], + demo: { + inputs: [ + { + filename: "image-text-to-text-input.png", + type: "img", + }, + { + label: "Text Prompt", + content: "Describe the position of the bee in detail.", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: + "The bee is sitting on a pink flower, surrounded by other flowers. The bee is positioned in the center of the flower, with its head and front legs sticking out.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Small and efficient yet powerful vision language model.", + id: "HuggingFaceTB/SmolVLM-Instruct", + }, + { + description: "Cutting-edge reasoning vision language model.", + id: "zai-org/GLM-4.5V", + }, + { + description: "Cutting-edge small vision language model to convert documents to text.", + id: "rednote-hilab/dots.ocr", + }, + { + description: "Small yet powerful model.", + id: "Qwen/Qwen2.5-VL-3B-Instruct", + }, + { + description: "Image-text-to-text model with agentic capabilities.", + id: "microsoft/Magma-8B", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate vision language models.", + id: "opencompass/open_vlm_leaderboard", + }, + { + description: "An application that compares object detection capabilities of different vision language models.", + id: "sergiopaniego/vlm_object_understanding", + }, + { + description: "An application to compare different OCR models.", + id: "prithivMLmods/Multimodal-OCR", + }, + ], + summary: + "Image-text-to-text models take in an image and text prompt and output text. These models are also called vision-language models, or VLMs. The difference from image-to-text models is that these models take an additional text input, not restricting the model to certain use cases like image captioning, and may also be trained to accept a conversation as input.", + widgetModels: ["zai-org/GLM-4.5V"], + youtubeId: "IoGaGfU1CIg", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..0119b6a5171c4b236778b70863ef8df81bf18408 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md @@ -0,0 +1,71 @@ +## Use Cases + +### Image Animation + +Image-text-to-video models can be used to animate still images based on text descriptions. For example, you can provide a landscape photo and the instruction "A camera pan from left to right" to create a video with camera movement. + +### Dynamic Content Creation + +Transform images into video by adding motion, transformations, or effects described in text prompts. This is useful for creating engaging social media content, presentations, or marketing materials. + +### Guided Video Generation + +Use a reference image with text prompts to guide the video generation process. This provides more control over the visual style and composition compared to text-to-video models alone. + +### Story Visualization + +Create video sequences from storyboards or concept art by providing scene descriptions. This can help filmmakers and animators visualize scenes before production. + +### Motion Control + +Generate videos with specific camera movements, object motions, or scene transitions by combining reference images with detailed motion descriptions. + +## Task Variants + +### Image-to-Video with Motion Control + +Models that generate videos from images while following specific motion instructions, such as camera movements, object animations, or scene dynamics. + +### Reference-guided Video Generation + +Models that use a reference image to guide the visual style and composition of the generated video while incorporating text prompts for motion and transformation control. + +### Conditional Video Synthesis + +Models that perform specific video transformations based on text conditions, such as adding weather effects, time-of-day changes, or environmental animations. + +## Inference + +You can use the Diffusers library to interact with image-text-to-video models. Here's example snippet to use `LTXImageToVideoPipeline`. + +```python +import torch +from diffusers import LTXImageToVideoPipeline +from diffusers.utils import export_to_video, load_image + +pipe = LTXImageToVideoPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16) +pipe.to("cuda") + +image = load_image( + "https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png" +) +prompt = "A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background. Flames engulf the structure, with smoke billowing into the air. Firefighters in protective gear rush to the scene, a fire truck labeled '38' visible behind them. The girl's neutral expression contrasts sharply with the chaos of the fire, creating a poignant and emotionally charged scene." +negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted" + +video = pipe( + image=image, + prompt=prompt, + negative_prompt=negative_prompt, + width=704, + height=480, + num_frames=161, + num_inference_steps=50, +).frames[0] +export_to_video(video, "output.mp4", fps=24) +``` + +## Useful Resources + +- [LTX-Video Model Card](https://huggingface.co/Lightricks/LTX-Video) +- [Text-to-Video: The Task, Challenges and the Current State](https://huggingface.co/blog/text-to-video) +- [Diffusers documentation on Video Generation](https://huggingface.co/docs/diffusers/using-diffusers/text-img2vid) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..ded013562dad10c8043ee4108d2f5a6ad9c006a4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts @@ -0,0 +1,54 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-video-input.jpg", + type: "img", + }, + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: + "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-video generation.", + id: "Lightricks/LTX-Video", + }, + ], + spaces: [ + { + description: "An application for image-text-to-video generation.", + id: "Lightricks/ltx-video-distilled", + }, + ], + summary: + "Image-text-to-video models take an reference image and a text instructions as and generate a video based on them. These models are useful for animating still images, creating dynamic content from static references, and generating videos with specific motion or transformation guidance.", + widgetModels: ["Lightricks/LTX-Video"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad048a7bc955b04fe119fd09461190eb4aa2a3df --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts @@ -0,0 +1,77 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Video + */ + parameters?: ImageTextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Video + */ +export interface ImageTextToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Video task + */ +export interface ImageTextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..3874073e48c9ac50c1ecd9c45c60fae9ac9a71f9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json @@ -0,0 +1,63 @@ +{ + "$id": "/inference/schemas/image-text-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters) must be provided, or both.", + "title": "ImageTextToVideoInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload. Either this or prompt must be provided.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Text To Video", + "$ref": "#/$defs/ImageTextToVideoParameters" + } + }, + "$defs": { + "ImageTextToVideoParameters": { + "title": "ImageTextToVideoParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the video generation. Either this or inputs (image) must be provided." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate videos closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "target_size": { + "type": "object", + "description": "The size in pixel of the output video frames.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..26a08e9be533d6a0770be2a6d084bc7941cd0f16 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-text-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Text To Video task", + "title": "ImageTextToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md new file mode 100644 index 0000000000000000000000000000000000000000..dca8e4708190708275de87ebf0b52aa2dc7f99c3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md @@ -0,0 +1,62 @@ +## Use Cases + +Image-to-3D models can be used in a wide variety of applications that require 3D, such as games, animation, design, architecture, engineering, marketing, and more. + +![Image-to-3D Thumbnail](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/image-to-3d/image-to-3d-thumbnail.png) + +### Generating Meshes + +Meshes are the standard representation of 3D in industry. + +### Generating Gaussian Splats + +[Gaussian Splatting](https://huggingface.co/blog/gaussian-splatting) is a rendering technique that represents scenes as fuzzy points. + +### Inference + +Inference for this task typically leverages the [Diffusers](https://huggingface.co/docs/diffusers/index) library for inference, using [Custom Pipelines](https://huggingface.co/docs/diffusers/v0.6.0/en/using-diffusers/custom_pipelines). + +These are unstandardized and depend on the model. More details can be found in each model repository. + +```python +import torch +import requests +import numpy as np +from io import BytesIO +from diffusers import DiffusionPipeline +from PIL import Image + +pipeline = DiffusionPipeline.from_pretrained( + "dylanebert/LGM-full", + custom_pipeline="dylanebert/LGM-full", + torch_dtype=torch.float16, + trust_remote_code=True, +).to("cuda") + +input_url = "https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg" +input_image = Image.open(BytesIO(requests.get(input_url).content)) +input_image = np.array(input_image, dtype=np.float32) / 255.0 +result = pipeline("", input_image) +result_path = "/tmp/output.ply" +pipeline.save_ply(result, result_path) +``` + +In the code above, we: + +1. Import the necessary libraries +2. Load the `LGM-full` model and custom pipeline +3. Load and preprocess the input image +4. Run the pipeline on the input image +5. Save the output to a file + +### Output Formats + +Meshes can be in `.obj`, `.glb`, `.stl`, or `.gltf` format. Other formats are allowed, but won't be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component. + +Splats can be in `.ply` or `.splat` format. They can be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component using the [gsplat.js](https://github.com/huggingface/gsplat.js) library. + +## Useful Resources + +- [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course) +- [3D Arena Leaderboard](https://huggingface.co/spaces/dylanebert/3d-arena) +- [gsplat.js](https://github.com/huggingface/gsplat.js) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..61e8e50c758ec13b640e989bc355d6fe0f76d542 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "A dataset of isolated object images for evaluating image-to-3D models.", + id: "dylanebert/iso3d", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-3d-image-input.png", + type: "img", + }, + ], + outputs: [ + { + label: "Result", + content: "image-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Fast image-to-3D mesh model by Tencent.", + id: "TencentARC/InstantMesh", + }, + { + description: "3D world generation model.", + id: "tencent/HunyuanWorld-1", + }, + { + description: "A scaled up image-to-3D mesh model derived from TripoSR.", + id: "hwjiang/Real3D", + }, + { + description: "Consistent image-to-3d generation model.", + id: "stabilityai/stable-point-aware-3d", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate image-to-3D models.", + id: "dylanebert/3d-arena", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "TencentARC/InstantMesh", + }, + { + description: "Image-to-3D demo.", + id: "stabilityai/stable-point-aware-3d", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "hwjiang/Real3D", + }, + { + description: "Image-to-3D demo with splat outputs.", + id: "dylanebert/LGM-mini", + }, + ], + summary: "Image-to-3D models take in image input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..b2e8b69131670c64ed5ea377418c5903dcafcbd7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md @@ -0,0 +1,129 @@ +Image-to-image pipelines can also be used in text-to-image tasks, to provide visual guidance to the text-guided generation process. + +## Use Cases + +### Image inpainting + +Image inpainting is widely used during photography editing to remove unwanted objects, such as poles, wires, or sensor dust. + +### Image colorization + +Old or black and white images can be brought up to life using an image colorization model. + +### Super Resolution + +Super-resolution models increase the resolution of an image, allowing for higher-quality viewing and printing. + +## Inference + +You can use pipelines for image-to-image in 🧨diffusers library to easily use image-to-image models. See an example for `StableDiffusionImg2ImgPipeline` below. + +```python +import torch +from diffusers import AutoPipelineForImage2Image +from diffusers.utils import make_image_grid, load_image + +pipeline = AutoPipelineForImage2Image.from_pretrained( + "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True +) + +# this helps us to reduce memory usage- since SDXL is a bit heavy, this could help by +# offloading the model to CPU w/o hurting performance. +pipeline.enable_model_cpu_offload() + +# prepare image +url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-sdxl-init.png" +init_image = load_image(url) + +prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" + +# pass prompt and image to pipeline +image = pipeline(prompt, image=init_image, strength=0.5).images[0] +make_image_grid([init_image, image], rows=1, cols=2) +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image-to-image models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageToImage({ + data: await (await fetch("image")).blob(), + model: "timbrooks/instruct-pix2pix", + parameters: { + prompt: "Deblur this image", + }, +}); +``` + +## Uses Cases for Text Guided Image Generation + +### Style Transfer + +One of the most popular use cases of image-to-image is style transfer. With style transfer models: + +- a regular photo can be transformed into a variety of artistic styles or genres, such as a watercolor painting, a comic book illustration and more. +- new images can be generated using a text prompt, in the style of a reference input image. + +See 🧨diffusers example for style transfer with `AutoPipelineForText2Image` below. + +```python +from diffusers import AutoPipelineForText2Image +from diffusers.utils import load_image +import torch + +# load pipeline +pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16).to("cuda") +pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin") + +# set the adapter and scales - this is a component that lets us add the style control from an image to the text-to-image model +scale = { + "down": {"block_2": [0.0, 1.0]}, + "up": {"block_0": [0.0, 1.0, 0.0]}, +} +pipeline.set_ip_adapter_scale(scale) + +style_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg") + +generator = torch.Generator(device="cpu").manual_seed(26) +image = pipeline( + prompt="a cat, masterpiece, best quality, high quality", + ip_adapter_image=style_image, + negative_prompt="text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry", + guidance_scale=5, + num_inference_steps=30, + generator=generator, +).images[0] +image +``` + +### ControlNet + +Controlling the outputs of diffusion models only with a text prompt is a challenging problem. ControlNet is a neural network model that provides image-based control to diffusion models. Control images can be edges or other landmarks extracted from a source image. +![Examples](https://huggingface.co/datasets/optimum/documentation-images/resolve/main/neuron/models/12-sdxl-text2img-controlnet.png) + +## Pix2Pix + +Pix2Pix is a popular model used for image-to-image translation tasks. It is based on a conditional-GAN (generative adversarial network) where instead of a noise vector a 2D image is given as input. More information about Pix2Pix can be retrieved from this [link](https://phillipi.github.io/pix2pix/) where the associated paper and the GitHub repository can be found. + +The images below show some examples extracted from the Pix2Pix paper. This model can be applied to various use cases. It is capable of relatively simpler things, e.g., converting a grayscale image to its colored version. But more importantly, it can generate realistic pictures from rough sketches (can be seen in the purse example) or from painting-like images (can be seen in the street and facade examples below). + +![Examples](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/image-to-image/pix2pix_examples.jpg) + +## Useful Resources + +- [Image-to-image guide with diffusers](https://huggingface.co/docs/diffusers/using-diffusers/img2img) +- Image inpainting: [inpainting with 🧨diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/inpaint#inpainting), [demo](https://huggingface.co/spaces/linoyts/Qwen-Image-Edit-Inpaint) +- Colorization: [demo](https://huggingface.co/spaces/modelscope/old_photo_restoration) +- Super resolution: [image upscaling with 🧨diffusers](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#super-resolution), [demo](https://huggingface.co/spaces/radames/Enhance-This-HiDiffusion-SDXL) +- [Style transfer and layout control with diffusers 🧨](https://huggingface.co/docs/diffusers/main/en/using-diffusers/ip_adapter#style--layout-control) +- [Train your ControlNet with diffusers 🧨](https://huggingface.co/blog/train-your-controlnet) +- [Ultra fast ControlNet with 🧨 Diffusers](https://huggingface.co/blog/controlnet) +- [List of ControlNets trained in the community JAX Diffusers sprint](https://huggingface.co/spaces/jax-diffusers-event/leaderboard) + +## References + +[1] P. Isola, J. -Y. Zhu, T. Zhou and A. A. Efros, "Image-to-Image Translation with Conditional Adversarial Networks," 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017, pp. 5967-5976, doi: 10.1109/CVPR.2017.632. + +This page was made possible thanks to the efforts of [Paul Gafton](https://github.com/Paul92) and [Osman Alenbey](https://huggingface.co/osman93). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0da0241e23d8b66032f395b04c9190f5dc2942a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts @@ -0,0 +1,96 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Synthetic dataset, for image relighting", + id: "VIDIT", + }, + { + description: "Multiple images of celebrities, used for facial expression translation", + id: "huggan/CelebA-faces", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-image-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-to-image-output.png", + type: "img", + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: + "Peak Signal to Noise Ratio (PSNR) is an approximation of the human perception, considering the ratio of the absolute intensity with respect to the variations. Measured in dB, a high value indicates a high fidelity.", + id: "PSNR", + }, + { + description: + "Structural Similarity Index (SSIM) is a perceptual metric which compares the luminance, contrast and structure of two images. The values of SSIM range between -1 and 1, and higher values indicate closer resemblance to the original image.", + id: "SSIM", + }, + { + description: + "Inception Score (IS) is an analysis of the labels predicted by an image classification model when presented with a sample of the generated images.", + id: "IS", + }, + ], + models: [ + { + description: "An image-to-image model to improve image resolution.", + id: "fal/AuraSR-v2", + }, + { + description: "Powerful image editing model.", + id: "black-forest-labs/FLUX.1-Kontext-dev", + }, + { + description: "Virtual try-on model.", + id: "yisol/IDM-VTON", + }, + { + description: "Image re-lighting model.", + id: "kontext-community/relighting-kontext-dev-lora-v3", + }, + { + description: "Strong model for inpainting and outpainting.", + id: "black-forest-labs/FLUX.1-Fill-dev", + }, + { + description: "Strong model for image editing using depth maps.", + id: "black-forest-labs/FLUX.1-Depth-dev-lora", + }, + ], + spaces: [ + { + description: "Image editing application.", + id: "black-forest-labs/FLUX.1-Kontext-Dev", + }, + { + description: "Image relighting application.", + id: "lllyasviel/iclight-v2-vary", + }, + { + description: "An application for image upscaling.", + id: "jasperai/Flux.1-dev-Controlnet-Upscaler", + }, + ], + summary: + "Image-to-image is the task of transforming an input image through a variety of possible manipulations and enhancements, such as super-resolution, image inpainting, colorization, and more.", + widgetModels: ["Qwen/Qwen-Image"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a681093ca15521e9c8a51bf1db042f094fff27f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts @@ -0,0 +1,68 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Image inference + */ +export interface ImageToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Image + */ + parameters?: ImageToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Image + */ +export interface ImageToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. + */ + prompt?: string; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Image task + */ +export interface ImageToImageOutput { + /** + * The output image returned as raw bytes in the payload. + */ + image?: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..49e8695c444db86328688df6df2119bfa1838587 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json @@ -0,0 +1,56 @@ +{ + "$id": "/inference/schemas/image-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Image inference", + "title": "ImageToImageInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Image", + "$ref": "#/$defs/ImageToImageParameters" + } + }, + "$defs": { + "ImageToImageParameters": { + "title": "ImageToImageParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the image generation." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "target_size": { + "type": "object", + "description": "The size in pixels of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..043544e7516fb38688967c0acf6dff933d3da64a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json @@ -0,0 +1,12 @@ +{ + "$id": "/inference/schemas/image-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Image task", + "title": "ImageToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The output image returned as raw bytes in the payload." + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..403dbdc41de67241bfab8f6535f3977e5a7a570e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md @@ -0,0 +1,61 @@ +## Use Cases + +### Image Captioning + +Image Captioning is the process of generating textual description of an image. +This can help the visually impaired people to understand what's happening in their surroundings. + +### Optical Character Recognition (OCR) + +OCR models convert the text present in an image, e.g. a scanned document, to text. + +## Inference + +### Image Captioning + +You can use the 🤗 Transformers library's `image-to-text` pipeline to generate caption for the Image input. + +```python +from transformers import pipeline + +captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base") +captioner("https://huggingface.co/datasets/Narsil/image_dummy/resolve/main/parrots.png") +## [{'generated_text': 'two birds are standing next to each other '}] +``` + +### OCR + +This code snippet uses Microsoft’s TrOCR, an encoder-decoder model consisting of an image Transformer encoder and a text Transformer decoder for state-of-the-art optical character recognition (OCR) on single-text line images. + +```python +from transformers import TrOCRProcessor, VisionEncoderDecoderModel + +processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten') +model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten') +pixel_values = processor(images="image.jpeg", return_tensors="pt").pixel_values + +generated_ids = model.generate(pixel_values) +generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] + +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image-to-text models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageToText({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "Salesforce/blip-image-captioning-base", +}); +``` + +## Useful Resources + +- [Image Captioning](https://huggingface.co/docs/transformers/main/en/tasks/image_captioning) +- [Image Captioning Use Case](https://blog.google/outreach-initiatives/accessibility/get-image-descriptions/) +- [Train Image Captioning model on your dataset](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/GIT/Fine_tune_GIT_on_an_image_captioning_dataset.ipynb) +- [Train OCR model on your dataset ](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/TrOCR) + +This page was made possible thanks to efforts of [Sukesh Perla](https://huggingface.co/hitchhiker3010) and [Johannes Kolbe](https://huggingface.co/johko). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2cda2e765f97fed36231bc8607febb7e483350bc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts @@ -0,0 +1,62 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Dataset from 12M image-text of Reddit", + id: "red_caps", + }, + { + // TODO write proper description + description: "Dataset from 3.3M images of Google", + id: "datasets/conceptual_captions", + }, + ], + demo: { + inputs: [ + { + filename: "savanna.jpg", + type: "img", + }, + ], + outputs: [ + { + label: "Detailed description", + content: "a herd of giraffes and zebras grazing in a field", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Strong OCR model.", + id: "allenai/olmOCR-7B-0725", + }, + { + description: "Powerful image captioning model.", + id: "fancyfeast/llama-joycaption-beta-one-hf-llava", + }, + ], + spaces: [ + { + description: "SVG generator app from images.", + id: "multimodalart/OmniSVG-3B", + }, + { + description: "An application that converts documents to markdown.", + id: "numind/NuMarkdown-8B-Thinking", + }, + { + description: "An application that can caption images.", + id: "fancyfeast/joy-caption-beta-one", + }, + ], + summary: + "Image to text models output a text from a given image. Image captioning or optical character recognition can be considered as the most common applications of image to text.", + widgetModels: ["Salesforce/blip-image-captioning-large"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c6bbe30c13bee2064c1e897c29a5945de8f7738 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts @@ -0,0 +1,134 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Text inference + */ +export interface ImageToTextInput { + /** + * The input image data + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Text + */ + parameters?: ImageToTextParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Text + */ +export interface ImageToTextParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + /** + * The amount of maximum tokens to generate. + */ + max_new_tokens?: number; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +/** + * Outputs of inference for the Image To Text task + */ +export interface ImageToTextOutput { + generatedText: unknown; + /** + * The generated text. + */ + generated_text?: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..26915b34a7511c7a0da959cb83382bd2bbba6efc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json @@ -0,0 +1,34 @@ +{ + "$id": "/inference/schemas/image-to-text/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Text inference", + "title": "ImageToTextInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input image data", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Text", + "$ref": "#/$defs/ImageToTextParameters" + } + }, + "$defs": { + "ImageToTextParameters": { + "title": "ImageToTextParameters", + "type": "object", + "properties": { + "max_new_tokens": { + "type": "integer", + "description": "The amount of maximum tokens to generate." + }, + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..388c3456f4e7f50b0c7b133725a2d951f152cb01 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/image-to-text/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Text task", + "title": "ImageToTextOutput", + "type": "object", + "properties": { + "generated_text": { + "type": "string", + "description": "The generated text." + } + }, + "required": ["generatedText"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..1b32dde6e61a0f96fb1372b3eaa31301eef1ade5 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md @@ -0,0 +1,51 @@ +## Use Cases + +Image-to-video models transform a static image into a video sequence. This can be used for a variety of creative and practical applications. + +### Animated Images + +Bring still photos to life by adding subtle motion or creating short animated clips. This is great for social media content or dynamic presentations. + +### Storytelling from a Single Frame + +Expand on the narrative of an image by generating a short video that imagines what happened before or after the moment captured in the photo. + +### Video Generation with Visual Consistency + +Use an input image as a strong visual anchor to guide the generation of a video, ensuring that the style, characters, or objects in the video remain consistent with the source image. + +### Controllable Motion + +Image-to-video models can be used to specify the direction or intensity of motion or camera control, giving more fine-grained control over the generated animation. + +## Inference + +Running the model Wan 2.1 T2V 1.3B with diffusers + +```py +import torch +from diffusers import AutoencoderKLWan, WanPipeline +from diffusers.utils import export_to_video + +model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers" +vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) +pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) +pipe.to("cuda") + +prompt = "A cat walks on the grass, realistic" +negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" + +output = pipe( + prompt=prompt, + negative_prompt=negative_prompt, + height=480, + width=832, + num_frames=81, + guidance_scale=5.0 +).frames[0] +export_to_video(output, "output.mp4", fps=15) +``` + +## Useful Resources + +To train image-to-video LoRAs check out [finetrainers](https://github.com/a-r-r-o-w/finetrainers) and [musubi trainer](https://github.com/kohya-ss/musubi-tuner). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..66ee4c1162ae40ea6caab24ee98eb7844d805414 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts @@ -0,0 +1,126 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A benchmark dataset for reference image controlled video generation.", + id: "ali-vilab/VACE-Benchmark", + }, + { + description: "A dataset of video generation style preferences.", + id: "Rapidata/sora-video-generation-style-likert-scoring", + }, + { + description: "A dataset with videos and captions throughout the videos.", + id: "BestWishYsh/ChronoMagic", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-video-input.jpg", + type: "img", + }, + { + label: "Optional Text Prompt", + content: "This penguin is dancing", + type: "text", + }, + ], + outputs: [ + { + filename: "image-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Fréchet Video Distance (FVD) measures the perceptual similarity between the distributions of generated videos and a set of real videos, assessing overall visual quality and temporal coherence of the video generated from an input image.", + id: "fvd", + }, + { + description: + "CLIP Score measures the semantic similarity between a textual prompt (if provided alongside the input image) and the generated video frames. It evaluates how well the video's generated content and motion align with the textual description, conditioned on the initial image.", + id: "clip_score", + }, + { + description: + "First Frame Fidelity, often measured using LPIPS (Learned Perceptual Image Patch Similarity), PSNR, or SSIM, quantifies how closely the first frame of the generated video matches the input conditioning image.", + id: "lpips", + }, + { + description: + "Identity Preservation Score measures the consistency of identity (e.g., a person's face or a specific object's characteristics) between the input image and throughout the generated video frames, often calculated using features from specialized models like face recognition (e.g., ArcFace) or re-identification models.", + id: "identity_preservation", + }, + { + description: + "Motion Score evaluates the quality, realism, and temporal consistency of motion in the video generated from a static image. This can be based on optical flow analysis (e.g., smoothness, magnitude), consistency of object trajectories, or specific motion plausibility assessments.", + id: "motion_score", + }, + ], + models: [ + { + description: "LTX-Video, a 13B parameter model for high quality video generation", + id: "Lightricks/LTX-Video-0.9.7-dev", + }, + { + description: "A 14B parameter model for reference image controlled video generation", + id: "Wan-AI/Wan2.1-VACE-14B", + }, + { + description: "An image-to-video generation model using FramePack F1 methodology with Hunyuan-DiT architecture", + id: "lllyasviel/FramePack_F1_I2V_HY_20250503", + }, + { + description: "A distilled version of the LTX-Video-0.9.7-dev model for faster inference", + id: "Lightricks/LTX-Video-0.9.7-distilled", + }, + { + description: "An image-to-video generation model by Skywork AI, 14B parameters, producing 720p videos.", + id: "Skywork/SkyReels-V2-I2V-14B-720P", + }, + { + description: "Image-to-video variant of Tencent's HunyuanVideo.", + id: "tencent/HunyuanVideo-I2V", + }, + { + description: "A 14B parameter model for 720p image-to-video generation by Wan-AI.", + id: "Wan-AI/Wan2.1-I2V-14B-720P", + }, + { + description: "A Diffusers version of the Wan2.1-I2V-14B-720P model for 720p image-to-video generation.", + id: "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers", + }, + ], + spaces: [ + { + description: "An application to generate videos fast.", + id: "Lightricks/ltx-video-distilled", + }, + { + description: "Generate videos with the FramePack-F1", + id: "linoyts/FramePack-F1", + }, + { + description: "Generate videos with the FramePack", + id: "lisonallen/framepack-i2v", + }, + { + description: "Wan2.1 with CausVid LoRA", + id: "multimodalart/wan2-1-fast", + }, + { + description: "A demo for Stable Video Diffusion", + id: "multimodalart/stable-video-diffusion", + }, + ], + summary: + "Image-to-video models take a still image as input and generate a video. These models can be guided by text prompts to influence the content and style of the output video.", + widgetModels: [], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b218eb05854db516320eabe19d7c33d70c0ec2c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts @@ -0,0 +1,74 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Video inference + */ +export interface ImageToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Video + */ + parameters?: ImageToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Video + */ +export interface ImageToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Video task + */ +export interface ImageToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..05178a700883087bda21ded761744f60c3d0c4d0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json @@ -0,0 +1,64 @@ +{ + "$id": "/inference/schemas/image-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Video inference", + "title": "ImageToVideoInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Video", + "$ref": "#/$defs/ImageToVideoParameters" + } + }, + "$defs": { + "ImageToVideoParameters": { + "title": "ImageToVideoParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the video generation." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate videos closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "target_size": { + "type": "object", + "description": "The size in pixel of the output video frames.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..ecd27522c3cdc4313fbc1b1a47239f6a9cd4f0f0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Video task", + "title": "ImageToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/index.ts b/node_modules/@huggingface/tasks/src/tasks/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d1c0284bc76ce1d1f722358d30834423458d7e6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/index.ts @@ -0,0 +1,341 @@ +import type { PipelineType } from "../pipelines.js"; +import { PIPELINE_DATA } from "../pipelines.js"; + +import anyToAny from "./any-to-any/data.js"; +import audioClassification from "./audio-classification/data.js"; +import audioTextToText from "./audio-text-to-text/data.js"; +import audioToAudio from "./audio-to-audio/data.js"; +import automaticSpeechRecognition from "./automatic-speech-recognition/data.js"; +import documentQuestionAnswering from "./document-question-answering/data.js"; +import featureExtraction from "./feature-extraction/data.js"; +import fillMask from "./fill-mask/data.js"; +import imageClassification from "./image-classification/data.js"; +import imageFeatureExtraction from "./image-feature-extraction/data.js"; +import imageToImage from "./image-to-image/data.js"; +import imageToText from "./image-to-text/data.js"; +import imageTextToText from "./image-text-to-text/data.js"; +import imageTextToImage from "./image-text-to-image/data.js"; +import imageTextToVideo from "./image-text-to-video/data.js"; +import imageSegmentation from "./image-segmentation/data.js"; +import imageToVideo from "./image-to-video/data.js"; +import maskGeneration from "./mask-generation/data.js"; +import objectDetection from "./object-detection/data.js"; +import depthEstimation from "./depth-estimation/data.js"; +import placeholder from "./placeholder/data.js"; +import reinforcementLearning from "./reinforcement-learning/data.js"; +import questionAnswering from "./question-answering/data.js"; +import sentenceSimilarity from "./sentence-similarity/data.js"; +import summarization from "./summarization/data.js"; +import tableQuestionAnswering from "./table-question-answering/data.js"; +import tabularClassification from "./tabular-classification/data.js"; +import tabularRegression from "./tabular-regression/data.js"; +import textToImage from "./text-to-image/data.js"; +import textToSpeech from "./text-to-speech/data.js"; +import tokenClassification from "./token-classification/data.js"; +import translation from "./translation/data.js"; +import textClassification from "./text-classification/data.js"; +import textGeneration from "./text-generation/data.js"; +import textRanking from "./text-ranking/data.js"; +import textToVideo from "./text-to-video/data.js"; +import unconditionalImageGeneration from "./unconditional-image-generation/data.js"; +import videoClassification from "./video-classification/data.js"; +import visualDocumentRetrieval from "./visual-document-retrieval/data.js"; +import visualQuestionAnswering from "./visual-question-answering/data.js"; +import zeroShotClassification from "./zero-shot-classification/data.js"; +import zeroShotImageClassification from "./zero-shot-image-classification/data.js"; +import zeroShotObjectDetection from "./zero-shot-object-detection/data.js"; +import imageTo3D from "./image-to-3d/data.js"; +import textTo3D from "./text-to-3d/data.js"; +import keypointDetection from "./keypoint-detection/data.js"; +import videoTextToText from "./video-text-to-text/data.js"; +import videoToVideo from "./video-to-video/data.js"; + +export type * from "./audio-classification/inference.js"; +export type * from "./automatic-speech-recognition/inference.js"; +export type { + ChatCompletionInput, + ChatCompletionInputMessage, + ChatCompletionInputMessageChunkType, + ChatCompletionOutput, + ChatCompletionOutputComplete, + ChatCompletionOutputMessage, + ChatCompletionStreamOutput, + ChatCompletionStreamOutputChoice, + ChatCompletionStreamOutputDelta, +} from "./chat-completion/inference.js"; +export type * from "./document-question-answering/inference.js"; +export type * from "./feature-extraction/inference.js"; +export type * from "./fill-mask/inference.js"; +export type { + ImageClassificationInput, + ImageClassificationOutput, + ImageClassificationOutputElement, + ImageClassificationParameters, +} from "./image-classification/inference.js"; +export type * from "./image-to-image/inference.js"; +export type { ImageToTextInput, ImageToTextOutput, ImageToTextParameters } from "./image-to-text/inference.js"; +export type * from "./image-segmentation/inference.js"; +export type { ImageToVideoInput, ImageToVideoOutput, ImageToVideoParameters } from "./image-to-video/inference.js"; +export type { + ImageTextToImageInput, + ImageTextToImageOutput, + ImageTextToImageParameters, +} from "./image-text-to-image/inference.js"; +export type { + ImageTextToVideoInput, + ImageTextToVideoOutput, + ImageTextToVideoParameters, +} from "./image-text-to-video/inference.js"; +export type * from "./object-detection/inference.js"; +export type * from "./depth-estimation/inference.js"; +export type * from "./question-answering/inference.js"; +export type * from "./sentence-similarity/inference.js"; +export type * from "./summarization/inference.js"; +export type * from "./table-question-answering/inference.js"; +export type { TextToImageInput, TextToImageOutput, TextToImageParameters } from "./text-to-image/inference.js"; +export type { TextToVideoParameters, TextToVideoOutput, TextToVideoInput } from "./text-to-video/inference.js"; +export type { TextToSpeechParameters, TextToSpeechInput, TextToSpeechOutput } from "./text-to-speech/inference.js"; +export type * from "./token-classification/inference.js"; +export type { TranslationInput, TranslationOutput } from "./translation/inference.js"; +export type { + ClassificationOutputTransform, + TextClassificationInput, + TextClassificationOutput, + TextClassificationOutputElement, + TextClassificationParameters, +} from "./text-classification/inference.js"; +export type { + TextGenerationOutputFinishReason, + TextGenerationOutputPrefillToken, + TextGenerationInput, + TextGenerationOutput, + TextGenerationOutputDetails, + TextGenerationInputGenerateParameters, + TextGenerationOutputBestOfSequence, + TextGenerationOutputToken, + TextGenerationStreamOutputStreamDetails, + TextGenerationStreamOutput, +} from "./text-generation/inference.js"; +export type * from "./video-classification/inference.js"; +export type * from "./visual-question-answering/inference.js"; +export type * from "./zero-shot-classification/inference.js"; +export type * from "./zero-shot-image-classification/inference.js"; +export type { + BoundingBox, + ZeroShotObjectDetectionInput, + ZeroShotObjectDetectionOutput, + ZeroShotObjectDetectionOutputElement, +} from "./zero-shot-object-detection/inference.js"; + +import type { ModelLibraryKey } from "../model-libraries.js"; +/** + * Model libraries compatible with each ML task + */ +export const TASKS_MODEL_LIBRARIES: Record = { + "audio-classification": ["speechbrain", "transformers", "transformers.js"], + "audio-to-audio": ["asteroid", "fairseq", "speechbrain"], + "automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"], + "audio-text-to-text": ["transformers"], + "depth-estimation": ["transformers", "transformers.js"], + "document-question-answering": ["transformers", "transformers.js"], + "feature-extraction": ["sentence-transformers", "transformers", "transformers.js"], + "fill-mask": ["transformers", "transformers.js"], + "graph-ml": ["transformers"], + "image-classification": ["keras", "timm", "transformers", "transformers.js"], + "image-feature-extraction": ["timm", "transformers"], + "image-segmentation": ["transformers", "transformers.js"], + "image-text-to-text": ["transformers"], + "image-text-to-image": ["diffusers"], + "image-text-to-video": ["diffusers"], + "image-to-image": ["diffusers", "transformers", "transformers.js"], + "image-to-text": ["transformers", "transformers.js"], + "image-to-video": ["diffusers"], + "keypoint-detection": ["transformers"], + "video-classification": ["transformers"], + "mask-generation": ["transformers"], + "multiple-choice": ["transformers"], + "object-detection": ["transformers", "transformers.js", "ultralytics"], + other: [], + "question-answering": ["adapter-transformers", "allennlp", "transformers", "transformers.js"], + robotics: [], + "reinforcement-learning": ["transformers", "stable-baselines3", "ml-agents", "sample-factory"], + "sentence-similarity": ["sentence-transformers", "spacy", "transformers.js"], + summarization: ["transformers", "transformers.js"], + "table-question-answering": ["transformers"], + "table-to-text": ["transformers"], + "tabular-classification": ["sklearn"], + "tabular-regression": ["sklearn"], + "tabular-to-text": ["transformers"], + "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"], + "text-generation": ["transformers", "transformers.js"], + "text-ranking": ["sentence-transformers", "transformers"], + "text-retrieval": [], + "text-to-image": ["diffusers"], + "text-to-speech": ["espnet", "tensorflowtts", "transformers", "transformers.js"], + "text-to-audio": ["transformers", "transformers.js"], + "text-to-video": ["diffusers"], + "time-series-forecasting": [], + "token-classification": [ + "adapter-transformers", + "flair", + "spacy", + "span-marker", + "stanza", + "transformers", + "transformers.js", + ], + translation: ["transformers", "transformers.js"], + "unconditional-image-generation": ["diffusers"], + "video-text-to-text": ["transformers"], + "visual-question-answering": ["transformers", "transformers.js"], + "voice-activity-detection": [], + "zero-shot-classification": ["transformers", "transformers.js"], + "zero-shot-image-classification": ["transformers", "transformers.js"], + "zero-shot-object-detection": ["transformers", "transformers.js"], + "text-to-3d": ["diffusers"], + "image-to-3d": ["diffusers"], + "any-to-any": ["transformers"], + "visual-document-retrieval": ["transformers"], + "video-to-video": ["diffusers"], +}; + +/** + * Return the whole TaskData object for a certain task. + * If the partialTaskData argument is left undefined, + * the default placeholder data will be used. + */ +function getData(type: PipelineType, partialTaskData: TaskDataCustom = placeholder): TaskData { + return { + ...partialTaskData, + id: type, + label: PIPELINE_DATA[type].name, + libraries: TASKS_MODEL_LIBRARIES[type], + }; +} + +// To make comparisons easier, task order is the same as in const.ts +// Tasks set to undefined won't have an associated task page. +// Tasks that call getData() without the second argument will +// have a "placeholder" page. +export const TASKS_DATA: Record = { + "any-to-any": getData("any-to-any", anyToAny), + "audio-classification": getData("audio-classification", audioClassification), + "audio-to-audio": getData("audio-to-audio", audioToAudio), + "audio-text-to-text": getData("audio-text-to-text", audioTextToText), + "automatic-speech-recognition": getData("automatic-speech-recognition", automaticSpeechRecognition), + "depth-estimation": getData("depth-estimation", depthEstimation), + "document-question-answering": getData("document-question-answering", documentQuestionAnswering), + "visual-document-retrieval": getData("visual-document-retrieval", visualDocumentRetrieval), + "feature-extraction": getData("feature-extraction", featureExtraction), + "fill-mask": getData("fill-mask", fillMask), + "graph-ml": undefined, + "image-classification": getData("image-classification", imageClassification), + "image-feature-extraction": getData("image-feature-extraction", imageFeatureExtraction), + "image-segmentation": getData("image-segmentation", imageSegmentation), + "image-to-image": getData("image-to-image", imageToImage), + "image-text-to-text": getData("image-text-to-text", imageTextToText), + "image-text-to-image": getData("image-text-to-image", imageTextToImage), + "image-text-to-video": getData("image-text-to-video", imageTextToVideo), + "image-to-text": getData("image-to-text", imageToText), + "image-to-video": getData("image-to-video", imageToVideo), + "keypoint-detection": getData("keypoint-detection", keypointDetection), + "mask-generation": getData("mask-generation", maskGeneration), + "multiple-choice": undefined, + "object-detection": getData("object-detection", objectDetection), + "video-classification": getData("video-classification", videoClassification), + other: undefined, + "question-answering": getData("question-answering", questionAnswering), + "reinforcement-learning": getData("reinforcement-learning", reinforcementLearning), + robotics: undefined, + "sentence-similarity": getData("sentence-similarity", sentenceSimilarity), + summarization: getData("summarization", summarization), + "table-question-answering": getData("table-question-answering", tableQuestionAnswering), + "table-to-text": undefined, + "tabular-classification": getData("tabular-classification", tabularClassification), + "tabular-regression": getData("tabular-regression", tabularRegression), + "tabular-to-text": undefined, + "text-classification": getData("text-classification", textClassification), + "text-generation": getData("text-generation", textGeneration), + "text-ranking": getData("text-ranking", textRanking), + "text-retrieval": undefined, + "text-to-image": getData("text-to-image", textToImage), + "text-to-speech": getData("text-to-speech", textToSpeech), + "text-to-audio": undefined, + "text-to-video": getData("text-to-video", textToVideo), + "time-series-forecasting": undefined, + "token-classification": getData("token-classification", tokenClassification), + translation: getData("translation", translation), + "unconditional-image-generation": getData("unconditional-image-generation", unconditionalImageGeneration), + "video-text-to-text": getData("video-text-to-text", videoTextToText), + "video-to-video": getData("video-to-video", videoToVideo), + "visual-question-answering": getData("visual-question-answering", visualQuestionAnswering), + "voice-activity-detection": undefined, + "zero-shot-classification": getData("zero-shot-classification", zeroShotClassification), + "zero-shot-image-classification": getData("zero-shot-image-classification", zeroShotImageClassification), + "zero-shot-object-detection": getData("zero-shot-object-detection", zeroShotObjectDetection), + "text-to-3d": getData("text-to-3d", textTo3D), + "image-to-3d": getData("image-to-3d", imageTo3D), +} as const; + +export interface ExampleRepo { + description: string; + id: string; +} + +export type TaskDemoEntry = + | { + filename: string; + type: "audio"; + } + | { + data: Array<{ + label: string; + score: number; + }>; + type: "chart"; + } + | { + filename: string; + type: "img"; + } + | { + table: string[][]; + type: "tabular"; + } + | { + content: string; + label: string; + type: "text"; + } + | { + text: string; + tokens: Array<{ + end: number; + start: number; + type: string; + }>; + type: "text-with-tokens"; + }; + +export interface TaskDemo { + inputs: TaskDemoEntry[]; + outputs: TaskDemoEntry[]; +} + +export interface TaskData { + datasets: ExampleRepo[]; + demo: TaskDemo; + id: PipelineType; + canonicalId?: PipelineType; + isPlaceholder?: boolean; + label: string; + libraries: ModelLibraryKey[]; + metrics: ExampleRepo[]; + models: ExampleRepo[]; + spaces: ExampleRepo[]; + summary: string; + widgetModels: string[]; + youtubeId?: string; +} + +export type TaskDataCustom = Omit; diff --git a/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..3758fdd831d23163ea1974842faf1330c7748c0a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md @@ -0,0 +1,57 @@ +## Task Variants + +### Pose Estimation + +Pose estimation is the process of determining the position and orientation of an object or a camera in a 3D space. It is a fundamental task in computer vision and is widely used in various applications such as robotics, augmented reality, and 3D reconstruction. + +## Use Cases for Keypoint Detection + +### Facial Landmark Estimation + +Keypoint detection models can be used to estimate the position of facial landmarks. Facial landmarks are points on the face such as the corners of the mouth, the outer corners of the eyes, and the tip of the nose. These landmarks can be used for a variety of applications, such as facial expression recognition, 3D face reconstruction, and cinematic animation. + +### Fitness Tracking + +Keypoint detection models can be used to track the movement of the human body, e.g. position of the joints in a 3D space. This can be used for a variety of applications, such as fitness tracking, sports analysis or virtual reality applications. + +## Inference Code + +Below you can find an example of how to use a keypoint detection model and how to visualize the results. + +```python +from transformers import AutoImageProcessor, SuperPointForKeypointDetection +import torch +import matplotlib.pyplot as plt +from PIL import Image +import requests + +url_image = "http://images.cocodataset.org/val2017/000000039769.jpg" +image = Image.open(requests.get(url_image_1, stream=True).raw) + +# initialize the model and processor +processor = AutoImageProcessor.from_pretrained("magic-leap-community/superpoint") +model = SuperPointForKeypointDetection.from_pretrained("magic-leap-community/superpoint") + +# infer +inputs = processor(image, return_tensors="pt").to(model.device, model.dtype) +outputs = model(**inputs) + +# postprocess +image_sizes = [(image.size[1], image.size[0])] +outputs = processor.post_process_keypoint_detection(model_outputs, image_sizes) +keypoints = outputs[0]["keypoints"].detach().numpy() +scores = outputs[0]["scores"].detach().numpy() +image_width, image_height = image.size + +# plot +plt.axis('off') +plt.imshow(image) +plt.scatter( + keypoints[:, 0], + keypoints[:, 1], + s=scores * 100, + c='cyan', + alpha=0.4 +) +plt.show() +``` diff --git a/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d6e3d6c25825ecf75ac60a9fe681940cc30a13a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts @@ -0,0 +1,58 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A dataset of hand keypoints of over 500k examples.", + id: "Vincent-luo/hagrid-mediapipe-hands", + }, + ], + demo: { + inputs: [ + { + filename: "keypoint-detection-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "keypoint-detection-output.png", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust keypoint detection model.", + id: "magic-leap-community/superpoint", + }, + { + description: "A robust keypoint matching model.", + id: "magic-leap-community/superglue_outdoor", + }, + { + description: "Strong keypoint detection model used to detect human pose.", + id: "qualcomm/RTMPose-Body2d", + }, + { + description: "Powerful keypoint matching model.", + id: "ETH-CVG/lightglue_disk", + }, + ], + spaces: [ + { + description: "An application that detects hand keypoints in real-time.", + id: "datasciencedojo/Hand-Keypoint-Detection-Realtime", + }, + { + description: "An application for keypoint detection and matching.", + id: "ETH-CVG/LightGlue", + }, + ], + summary: "Keypoint detection is the task of identifying meaningful distinctive points or features in an image.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a65d22a4be467172062f324248023bc7360a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md @@ -0,0 +1,75 @@ +## Use Cases + +### Filtering an Image + +When filtering for an image, the generated masks might serve as an initial filter to eliminate irrelevant information. For instance, when monitoring vegetation in satellite imaging, mask generation models identify green spots, highlighting the relevant region of the image. + +### Masked Image Modelling + +Generating masks can facilitate learning, especially in semi or unsupervised learning. For example, the [BEiT model](https://huggingface.co/docs/transformers/model_doc/beit) uses image-mask patches in the pre-training. + +### Human-in-the-loop Computer Vision Applications + +For applications where humans are in the loop, masks highlight certain regions of images for humans to validate. + +### Medical Imaging + +Mask generation models are used in medical imaging to aid in segmenting and analyzing specific regions. + +### Autonomous Vehicles + +Mask generation models are used to create segments and masks for obstacles and other objects in view. + +This page was made possible thanks to the efforts of [Raj Aryan](https://huggingface.co/thatrajaryan) and other contributors. + +## Task Variants + +### Segmentation + +Image Segmentation divides an image into segments where each pixel is mapped to an object. This task has multiple variants, such as instance segmentation, panoptic segmentation, and semantic segmentation. You can learn more about segmentation on its [task page](https://huggingface.co/tasks/image-segmentation). + +## Inference + +Mask generation models often work in two modes: segment everything or prompt mode. +The example below works in segment-everything-mode, where many masks will be returned. + +```python +from transformers import pipeline + +generator = pipeline("mask-generation", model="Zigeng/SlimSAM-uniform-50", points_per_batch=64, device="cuda") +image_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png" +outputs = generator(image_url) +outputs["masks"] +# array of multiple binary masks returned for each generated mask +``` + +Prompt mode takes in three types of prompts: + +- **Point prompt:** The user can select a point on the image, and a meaningful segment around the point will be returned. +- **Box prompt:** The user can draw a box on the image, and a meaningful segment within the box will be returned. +- **Text prompt:** The user can input a text, and the objects of that type will be segmented. Note that this capability has not yet been released and has only been explored in research. + +Below you can see how to use an input-point prompt. It also demonstrates direct model inference without the `pipeline` abstraction. The input prompt here is a nested list where the outermost list is the batch size (`1`), then the number of points (also `1` in this example), and the innermost list contains the actual coordinates of the point (`[450, 600]`). + +```python +from transformers import SamModel, SamProcessor +from PIL import Image +import requests + +model = SamModel.from_pretrained("Zigeng/SlimSAM-uniform-50").to("cuda") +processor = SamProcessor.from_pretrained("Zigeng/SlimSAM-uniform-50") + +raw_image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB") +# pointing to the car window +input_points = [[[450, 600]]] +inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to("cuda") +outputs = model(**inputs) +masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu()) +scores = outputs.iou_scores +``` + +## Useful Resources + +Would you like to learn more about mask generation? Great! Here you can find some curated resources that you may find helpful! + +- [Segment anything model](https://huggingface.co/docs/transformers/main/model_doc/sam) diff --git a/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc18380dbe2f37b4ad6d2587dd7b102d6fbef5f3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts @@ -0,0 +1,69 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple Vision tasks.", + id: "merve/coco2017", + }, + { + description: "Medical Imaging dataset of the Human Brain for segmentation and mask generating tasks", + id: "rocky93/BraTS_segmentation", + }, + ], + demo: { + inputs: [ + { + filename: "mask-generation-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "mask-generation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: "IoU is used to measure the overlap between predicted mask and the ground truth mask.", + id: "Intersection over Union (IoU)", + }, + ], + models: [ + { + description: "Small yet powerful mask generation model.", + id: "Zigeng/SlimSAM-uniform-50", + }, + { + description: "Very strong mask generation model.", + id: "facebook/sam2-hiera-large", + }, + ], + spaces: [ + { + description: + "An application that combines a mask generation model with a zero-shot object detection model for text-guided image segmentation.", + id: "merve/OWLSAM2", + }, + { + description: "An application that compares the performance of a large and a small mask generation model.", + id: "merve/slimsam", + }, + { + description: "An application based on an improved mask generation model.", + id: "SkalskiP/segment-anything-model-2", + }, + { + description: "An application to remove objects from videos using mask generation models.", + id: "SkalskiP/SAM_and_ProPainter", + }, + ], + summary: + "Mask generation is the task of generating masks that identify a specific object or region of interest in a given image. Masks are often used in segmentation tasks, where they provide a precise way to isolate the object of interest for further processing or analysis.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..4dda21224f937a27a5f56d40ee877ff03eaf1d09 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md @@ -0,0 +1,37 @@ +## Use Cases + +### Autonomous Driving + +Object Detection is widely used in computer vision for autonomous driving. Self-driving cars use Object Detection models to detect pedestrians, bicycles, traffic lights and road signs to decide which step to take. + +### Object Tracking in Matches + +Object Detection models are widely used in sports where the ball or a player is tracked for monitoring and refereeing during matches. + +### Image Search + +Object Detection models are widely used in image search. Smartphones use Object Detection models to detect entities (such as specific places or objects) and allow the user to search for the entity on the Internet. + +### Object Counting + +Object Detection models are used to count instances of objects in a given image, this can include counting the objects in warehouses or stores, or counting the number of visitors in a store. They are also used to manage crowds at events to prevent disasters. + +## Inference + +You can infer with Object Detection models through the `object-detection` pipeline. When calling the pipeline you just need to specify a path or http link to an image. + +```python +model = pipeline("object-detection") + +model("path_to_cat_image") + +# [{'label': 'blanket', +# 'mask': mask_string, +# 'score': 0.917}, +#...] +``` + +# Useful Resources + +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [Object detection task guide](https://huggingface.co/docs/transformers/tasks/object_detection) diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b962813340e659b93a3574844bcb3c11f070846 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts @@ -0,0 +1,90 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple vision tasks.", + id: "merve/coco2017", + }, + { + description: "Multi-task computer vision benchmark.", + id: "merve/pascal-voc", + }, + ], + demo: { + inputs: [ + { + filename: "object-detection-input.jpg", + type: "img", + }, + ], + outputs: [ + { + filename: "object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid object detection model pre-trained on the COCO 2017 dataset.", + id: "facebook/detr-resnet-50", + }, + { + description: "Accurate object detection model.", + id: "IDEA-Research/dab-detr-resnet-50", + }, + { + description: "Fast and accurate object detection model.", + id: "PekingU/rtdetr_v2_r50vd", + }, + { + description: "Object detection model for low-lying objects.", + id: "StephanST/WALDO30", + }, + ], + spaces: [ + { + description: "Real-time object detection demo.", + id: "Roboflow/RF-DETR", + }, + { + description: "An application that contains various object detection models to try from.", + id: "Gradio-Blocks/Object-Detection-With-DETR-and-YOLOS", + }, + { + description: "A cutting-edge object detection application.", + id: "sunsmarterjieleaf/yolov12", + }, + { + description: "An object tracking, segmentation and inpainting application.", + id: "VIPLab/Track-Anything", + }, + { + description: "Very fast object tracking application based on object detection.", + id: "merve/RT-DETR-tracking-coco", + }, + ], + summary: + "Object Detection models allow users to identify objects of certain defined classes. Object detection models receive an image as input and output the images with bounding boxes and labels on detected objects.", + widgetModels: ["facebook/detr-resnet-50"], + youtubeId: "WdAeKSOpxhw", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts b/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..58f330e681686e98f84dab3bb6cccffde197c79b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts @@ -0,0 +1,73 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Object Detection inference + */ +export interface ObjectDetectionInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Object Detection + */ + parameters?: ObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Object Detection + */ +export interface ObjectDetectionParameters { + /** + * The probability necessary to make a prediction. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + /** + * The x-coordinate of the bottom-right corner of the bounding box. + */ + xmax: number; + /** + * The x-coordinate of the top-left corner of the bounding box. + */ + xmin: number; + /** + * The y-coordinate of the bottom-right corner of the bounding box. + */ + ymax: number; + /** + * The y-coordinate of the top-left corner of the bounding box. + */ + ymin: number; + [property: string]: unknown; +} +export type ObjectDetectionOutput = ObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Object Detection task + */ +export interface ObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * The predicted label for the bounding box. + */ + label: string; + /** + * The associated score / probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..55df78f56bc0130af7b952de88be400ae62d9d98 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json @@ -0,0 +1,31 @@ +{ + "$id": "/inference/schemas/object-detection/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Object Detection inference", + "title": "ObjectDetectionInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Object Detection", + "$ref": "#/$defs/ObjectDetectionParameters" + } + }, + "$defs": { + "ObjectDetectionParameters": { + "title": "ObjectDetectionParameters", + "type": "object", + "properties": { + "threshold": { + "type": "number", + "description": "The probability necessary to make a prediction." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8d91f1078f664fff39eff78d0ff4bba00d9a0a79 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json @@ -0,0 +1,50 @@ +{ + "$id": "/inference/schemas/object-detection/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Object Detection task", + "title": "ObjectDetectionOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The predicted label for the bounding box." + }, + "score": { + "type": "number", + "description": "The associated score / probability." + }, + "box": { + "$ref": "#/$defs/BoundingBox", + "description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image." + } + }, + "required": ["box", "label", "score"] + }, + "$defs": { + "BoundingBox": { + "type": "object", + "title": "BoundingBox", + "properties": { + "xmin": { + "type": "integer", + "description": "The x-coordinate of the top-left corner of the bounding box." + }, + "xmax": { + "type": "integer", + "description": "The x-coordinate of the bottom-right corner of the bounding box." + }, + "ymin": { + "type": "integer", + "description": "The y-coordinate of the top-left corner of the bounding box." + }, + "ymax": { + "type": "integer", + "description": "The y-coordinate of the bottom-right corner of the bounding box." + } + }, + "required": ["xmin", "xmax", "ymin", "ymax"] + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md b/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md new file mode 100644 index 0000000000000000000000000000000000000000..fdb45584410dcd07e530607d469140038ede6b25 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md @@ -0,0 +1,15 @@ +## Use Cases + +You can contribute this area with common use cases of the task! + +## Task Variants + +This place can be filled with variants of this task if there's any. + +## Inference + +This section should have useful information about how to pull a model from Hugging Face Hub that is a part of a library specialized in a task and use it. + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts b/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c103e16a889e42b08a4987fb91a3c962cb1afb02 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts @@ -0,0 +1,21 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [], + outputs: [], + }, + isPlaceholder: true, + metrics: [], + models: [], + spaces: [], + summary: "", + widgetModels: [], + youtubeId: undefined, + /// If this is a subtask, link to the most general task ID + /// (eg, text-generation is the canonical ID of text-simplification) + canonicalId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..aab9dd1525b387db8aaaf2ef07d75ab355143d8d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json @@ -0,0 +1,34 @@ +{ + "$id": "/inference/schemas//input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for inference", + "title": "PlaceholderInput", + "type": "object", + "properties": { + "inputs": { + "description": "TODO: describe the input here. This must be model & framework agnostic.", + "type": "string" + }, + "parameters": { + "description": "TODO: describe additional parameters here.", + "$ref": "#/$defs/Parameters" + } + }, + "$defs": { + "Parameters": { + "title": "Parameters", + "type": "object", + "properties": { + "dummy_parameter_name": { + "type": "boolean", + "description": "TODO: describe the parameter here" + }, + "dummy_parameter_name2": { + "type": "integer", + "description": "TODO: describe the parameter here" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..a71a1ae149704cb6317fd35a539be343c454ef81 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json @@ -0,0 +1,17 @@ +{ + "$id": "/inference/schemas//output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs for inference", + "title": "PlaceholderOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "meaningful_output_name": { + "type": "string", + "description": "TODO: Describe what is outputted by the inference here" + } + }, + "required": ["meaningfulOutputName"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..d5934ee80c7ca32c53726ef5b9e715af54a0b5d6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md @@ -0,0 +1,56 @@ +## Use Cases + +### Frequently Asked Questions + +You can use Question Answering (QA) models to automate the response to frequently asked questions by using a knowledge base (documents) as context. Answers to customer questions can be drawn from those documents. + +⚡⚡ If you’d like to save inference time, you can first use [passage ranking models](/tasks/sentence-similarity) to see which document might contain the answer to the question and iterate over that document with the QA model instead. + +## Task Variants +There are different QA variants based on the inputs and outputs: + +- **Extractive QA:** The model **extracts** the answer from a context. The context here could be a provided text, a table or even HTML! This is usually solved with BERT-like models. +- **Open Generative QA:** The model **generates** free text directly based on the context. You can learn more about the Text Generation task in [its page](/tasks/text-generation). +- **Closed Generative QA:** In this case, no context is provided. The answer is completely generated by a model. + +The schema above illustrates extractive, open book QA. The model takes a context and the question and extracts the answer from the given context. + +You can also differentiate QA models depending on whether they are open-domain or closed-domain. Open-domain models are not restricted to a specific domain, while closed-domain models are restricted to a specific domain (e.g. legal, medical documents). + +## Inference + +You can infer with QA models with the 🤗 Transformers library using the `question-answering` pipeline. If no model checkpoint is given, the pipeline will be initialized with `distilbert-base-cased-distilled-squad`. This pipeline takes a question and a context from which the answer will be extracted and returned. + +```python +from transformers import pipeline + +qa_model = pipeline("question-answering") +question = "Where do I live?" +context = "My name is Merve and I live in İstanbul." +qa_model(question = question, context = context) +## {'answer': 'İstanbul', 'end': 39, 'score': 0.953, 'start': 31} +``` + +## Useful Resources + +Would you like to learn more about QA? Awesome! Here are some curated resources that you may find helpful! + +- [Course Chapter on Question Answering](https://huggingface.co/course/chapter7/7?fw=pt) +- [Question Answering Workshop](https://www.youtube.com/watch?v=Ihgk8kGLpIE&ab_channel=HuggingFace) +- [How to Build an Open-Domain Question Answering System?](https://lilianweng.github.io/lil-log/2020/10/29/open-domain-question-answering.html) +- [Blog Post: ELI5 A Model for Open Domain Long Form Question Answering](https://yjernite.github.io/lfqa.html) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/question_answering.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/main/examples/question_answering-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/question-answering) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/question-answering) + +### Documentation + +- [Question answering task guide](https://huggingface.co/docs/transformers/tasks/question_answering) diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf75dd3d7b9748e6670fef59497dd0feea6d4a6b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "A famous question answering dataset based on English articles from Wikipedia.", + id: "squad_v2", + }, + { + // TODO write proper description + description: "A dataset of aggregated anonymized actual queries issued to the Google search engine.", + id: "natural_questions", + }, + ], + demo: { + inputs: [ + { + label: "Question", + content: "Which name is also used to describe the Amazon rainforest in English?", + type: "text", + }, + { + label: "Context", + content: "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: "Amazonia", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Exact Match is a metric based on the strict character match of the predicted answer and the right answer. For answers predicted correctly, the Exact Match will be 1. Even if only one character is different, Exact Match will be 0", + id: "exact-match", + }, + { + description: + " The F1-Score metric is useful if we value both false positives and false negatives equally. The F1-Score is calculated on each word in the predicted sequence against the correct answer", + id: "f1", + }, + ], + models: [ + { + description: "A robust baseline model for most question answering domains.", + id: "deepset/roberta-base-squad2", + }, + { + description: "Small yet robust model that can answer questions.", + id: "distilbert/distilbert-base-cased-distilled-squad", + }, + { + description: "A special model that can answer questions from tables.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that can answer a long question from Wikipedia.", + id: "deepset/wikipedia-assistant", + }, + ], + summary: + "Question Answering models can retrieve the answer to a question from a given text, which is useful for searching for an answer in a document. Some question answering models can generate answers without context!", + widgetModels: ["deepset/roberta-base-squad2"], + youtubeId: "ajPx5LwJD-I", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd478276bdd8e9c8473aa73d562a32845a93a968 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts @@ -0,0 +1,97 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Question Answering inference + */ +export interface QuestionAnsweringInput { + /** + * One (context, question) pair to answer + */ + inputs: QuestionAnsweringInputData; + /** + * Additional inference parameters for Question Answering + */ + parameters?: QuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (context, question) pair to answer + */ +export interface QuestionAnsweringInputData { + /** + * The context to be used for answering the question + */ + context: string; + /** + * The question to be answered + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Question Answering + */ +export interface QuestionAnsweringParameters { + /** + * Attempts to align the answer to real words. Improves quality on space separated + * languages. Might hurt on non-space-separated languages (like Japanese or Chinese) + */ + align_to_words?: boolean; + /** + * If the context is too long to fit with the question for the model, it will be split in + * several chunks with some overlap. This argument controls the size of that overlap. + */ + doc_stride?: number; + /** + * Whether to accept impossible as an answer. + */ + handle_impossible_answer?: boolean; + /** + * The maximum length of predicted answers (e.g., only answers with a shorter length are + * considered). + */ + max_answer_len?: number; + /** + * The maximum length of the question after tokenization. It will be truncated if needed. + */ + max_question_len?: number; + /** + * The maximum length of the total sentence (context + question) in tokens of each chunk + * passed to the model. The context will be split in several chunks (using docStride as + * overlap) if needed. + */ + max_seq_len?: number; + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type QuestionAnsweringOutput = QuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Question Answering task + */ +export interface QuestionAnsweringOutputElement { + /** + * The answer to the question. + */ + answer: string; + /** + * The character position in the input where the answer ends. + */ + end: number; + /** + * The probability associated to the answer. + */ + score: number; + /** + * The character position in the input where the answer begins. + */ + start: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..266b329df3c3d27637bab119a70cf9394b77a16f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json @@ -0,0 +1,66 @@ +{ + "$id": "/inference/schemas/question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Question Answering inference", + "title": "QuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "title": "QuestionAnsweringInputData", + "description": "One (context, question) pair to answer", + "type": "object", + "properties": { + "context": { + "type": "string", + "description": "The context to be used for answering the question" + }, + "question": { + "type": "string", + "description": "The question to be answered" + } + }, + "required": ["question", "context"] + }, + "parameters": { + "description": "Additional inference parameters for Question Answering", + "$ref": "#/$defs/QuestionAnsweringParameters" + } + }, + "$defs": { + "QuestionAnsweringParameters": { + "title": "QuestionAnsweringParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "The number of answers to return (will be chosen by order of likelihood). Note that we return less than topk answers if there are not enough options available within the context." + }, + "doc_stride": { + "type": "integer", + "description": "If the context is too long to fit with the question for the model, it will be split in several chunks with some overlap. This argument controls the size of that overlap." + }, + "max_answer_len": { + "type": "integer", + "description": "The maximum length of predicted answers (e.g., only answers with a shorter length are considered)." + }, + "max_seq_len": { + "type": "integer", + "description": "The maximum length of the total sentence (context + question) in tokens of each chunk passed to the model. The context will be split in several chunks (using docStride as overlap) if needed." + }, + "max_question_len": { + "type": "integer", + "description": "The maximum length of the question after tokenization. It will be truncated if needed." + }, + "handle_impossible_answer": { + "type": "boolean", + "description": "Whether to accept impossible as an answer." + }, + "align_to_words": { + "type": "boolean", + "description": "Attempts to align the answer to real words. Improves quality on space separated languages. Might hurt on non-space-separated languages (like Japanese or Chinese)" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..9da8f988ad21668db65d18e22cb105a0da96a63d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json @@ -0,0 +1,29 @@ +{ + "$id": "/inference/schemas/question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "QuestionAnsweringOutput", + "description": "Outputs of inference for the Question Answering task", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer to the question." + }, + "score": { + "type": "number", + "description": "The probability associated to the answer." + }, + "start": { + "type": "integer", + "description": "The character position in the input where the answer begins." + }, + "end": { + "type": "integer", + "description": "The character position in the input where the answer ends." + } + }, + "required": ["answer", "score", "start", "end"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md new file mode 100644 index 0000000000000000000000000000000000000000..286fba9296b04b6389e3bcbb20bf7770f1bc982c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md @@ -0,0 +1,167 @@ +## Use Cases + +### Gaming + +Reinforcement learning is known for its application to video games. Since the games provide a safe environment for the agent to be trained in the sense that it is perfectly defined and controllable, this makes them perfect candidates for experimentation and will help a lot to learn about the capabilities and limitations of various RL algorithms. + +There are many videos on the Internet where a game-playing reinforcement learning agent starts with a terrible gaming strategy due to random initialization of its settings, but over iterations, the agent gets better and better with each episode of the training. This [paper](https://arxiv.org/abs/1912.10944) mainly investigates the performance of RL in popular games such as Minecraft or Dota2. The agent's performance can exceed a human player's, although there are still some challenges mainly related to efficiency in constructing the gaming policy of the reinforcement learning agent. + +### Trading and Finance + +Reinforcement learning is the science to train computers to make decisions and thus has a novel use in trading and finance. All time-series models are helpful in predicting prices, volume and future sales of a product or a stock. Reinforcement based automated agents can decide to sell, buy or hold a stock. It shifts the impact of AI in this field to real time decision making rather than just prediction of prices. The glossary given below will clear some parameters to as to how we can train a model to take these decisions. + +## Task Variants + +### Model Based RL + +In model based reinforcement learning techniques intend to create a model of the environment, learn the state transition probabilities and the reward function, to find the optimal action. Some typical examples for model based reinforcement learning algorithms are dynamic programming, value iteration and policy iteration. + +### Model Free RL + +In model free reinforcement learning, agent decides on optimal actions based on its experience in the environment and the reward it collects from it. This is one of the most commonly used algorithms beneficial in complex environments, where modeling of state transition probabilities and reward functions are difficult. Some of the examples of model free reinforcement learning are SARSA, Q-Learning, actor-critic and proximal policy optimization (PPO) algorithms. + +## Glossary + + + +**Agent:** The learner and the decision maker. + +**Environment:** The part of the world the agent interacts, comprising everything outside the agent. + +Observations and states are the information our agent gets from the environment. In the case of a video game, it can be a frame (a screenshot). In the case of the trading agent, it can be the value of a certain stock. + +**State:** Complete description of the state of the environment with no hidden information. + +**Observation:** Partial description of the state, in a partially observed environment. + +**Action:** The decision taken by the agent. + +**Reward:** The numerical feedback signal that the agent receives from the environment based on the chosen action. + +**Return:** Cumulative Reward. In the simplest case, the return is the sum of the rewards. + +**Episode:** For some applications there is a natural notion of final time step. In this case, there is a starting point and an ending point (a terminal state). This creates an episode: a list of States, Actions, Rewards, and new States. For instance, think about Chess: an episode begins at the initial board position and ends when the game is over. + +**Policy:** The Policy is the brain of the Agent, it’s the function that tells what action to take given the state. So it defines the agent’s behavior at a given time. Reinforcement learning methods specify how the agent’s policy is changed as a result of its experience. + +## Inference + +Inference in reinforcement learning differs from other modalities, in which there's a model and test data. In reinforcement learning, once you have trained an agent in an environment, you try to run the trained agent for additional steps to get the average reward. + +A typical training cycle consists of gathering experience from the environment, training the agent, and running the agent on a test environment to obtain average reward. Below there's a snippet on how you can interact with the environment using the `gymnasium` library, train an agent using `stable-baselines3`, evaluate the agent on test environment and infer actions from the trained agent. + +```python +# Here we are running 20 episodes of CartPole-v1 environment, taking random actions +import gymnasium as gym + +env = gym.make("CartPole-v1") +observation, info = env.reset() + +for _ in range(20): + action = env.action_space.sample() # samples random action from action sample space + + # the agent takes the action + observation, reward, terminated, truncated, info = env.step(action) + + +# if the agent reaches terminal state, we reset the environment +if terminated or truncated: + + print("Environment is reset") + observation = env.reset() + +env.close() +``` + +Below snippet shows how to train a PPO model on LunarLander-v2 environment using `stable-baselines3` library and saving the model + +```python +from stable_baselines3 import PPO + +# initialize the environment + +env = gym.make("LunarLander-v2") + +# initialize the model + +model = PPO(policy = "MlpPolicy", + env = env, + n_steps = 1024, + batch_size = 64, + n_epochs = 4, + verbose = 1) + +# train the model for 1000 time steps +model.learn(total_timesteps = 1000) + +# Saving the model in desired directory +model_name = "PPO-LunarLander-v2" +model.save(model_name) +``` + +Below code shows how to evaluate an agent trained using `stable-baselines3` + +```python +# Loading a saved model and evaluating the model for 10 episodes +from stable_baselines3.common.evaluation import evaluate_policy +from stable_baselines3 import PPO + + +env = gym.make("LunarLander-v2") +# Loading the saved model +model = PPO.load("PPO-LunarLander-v2",env=env) + +# Initializing the evaluation environment +eval_env = gym.make("LunarLander-v2") + +# Running the trained agent on eval_env for 10 time steps and getting the mean reward +mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes = 10, + deterministic=True) + +print(f"mean_reward={mean_reward:.2f} +/- {std_reward}") +``` + +Below code snippet shows how to infer actions from an agent trained using `stable-baselines3` + +```python +from stable_baselines3.common.evaluation import evaluate_policy +from stable_baselines3 import PPO + +# Loading the saved model +model = PPO.load("PPO-LunarLander-v2",env=env) + +# Getting the environment from the trained agent +env = model.get_env() + +obs = env.reset() +for i in range(1000): + # getting action predictions from the trained agent + action, _states = model.predict(obs, deterministic=True) + + # taking the predicted action in the environment to observe next state and rewards + obs, rewards, dones, info = env.step(action) +``` + +For more information, you can check out the documentations of the respective libraries. + +[Gymnasium Documentation](https://gymnasium.farama.org/) +[Stable Baselines Documentation](https://stable-baselines3.readthedocs.io/en/master/) + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [HuggingFace Deep Reinforcement Learning Class](https://github.com/huggingface/deep-rl-class) +- [Introduction to Deep Reinforcement Learning](https://huggingface.co/blog/deep-rl-intro) +- [Stable Baselines Integration with HuggingFace](https://huggingface.co/blog/sb3) +- Learn how reinforcement learning is used in conversational agents in this blog: [Illustrating Reinforcement Learning from Human Feedback (RLHF)](https://huggingface.co/blog/rlhf) +- [Reinforcement Learning from Human Feedback From Zero to ChatGPT](https://www.youtube.com/watch?v=EAd4oQtEJOM) +- [Guide on Multi-Agent Competition Systems](https://huggingface.co/blog/aivsai) + +### Notebooks + +- [Train a Deep Reinforcement Learning lander agent to land correctly on the Moon 🌕 using Stable-Baselines3](https://github.com/huggingface/deep-rl-class/blob/main/notebooks/unit1/unit1.ipynb) +- [Introduction to Unity MLAgents](https://github.com/huggingface/deep-rl-class/blob/main/notebooks/unit5/unit5.ipynb) +- [Training Decision Transformers with 🤗 transformers](https://github.com/huggingface/blog/blob/main/notebooks/101_train-decision-transformers.ipynb) + +This page was made possible thanks to the efforts of [Ram Ananth](https://huggingface.co/RamAnanth1), [Emilio Lehoucq](https://huggingface.co/emiliol), [Sagar Mathpal](https://huggingface.co/sagarmathpal) and [Osman Alenbey](https://huggingface.co/osman93). diff --git a/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..231ecabda2c346cc1a681ac6f99f585086d202b7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A curation of widely used datasets for Data Driven Deep Reinforcement Learning (D4RL)", + id: "edbeeching/decision_transformer_gym_replay", + }, + ], + demo: { + inputs: [ + { + label: "State", + content: "Red traffic light, pedestrians are about to pass.", + type: "text", + }, + ], + outputs: [ + { + label: "Action", + content: "Stop the car.", + type: "text", + }, + { + label: "Next State", + content: "Yellow light, pedestrians have crossed.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Accumulated reward across all time steps discounted by a factor that ranges between 0 and 1 and determines how much the agent optimizes for future relative to immediate rewards. Measures how good is the policy ultimately found by a given algorithm considering uncertainty over the future.", + id: "Discounted Total Reward", + }, + { + description: + "Average return obtained after running the policy for a certain number of evaluation episodes. As opposed to total reward, mean reward considers how much reward a given algorithm receives while learning.", + id: "Mean Reward", + }, + { + description: + "Measures how good a given algorithm is after a predefined time. Some algorithms may be guaranteed to converge to optimal behavior across many time steps. However, an agent that reaches an acceptable level of optimality after a given time horizon may be preferable to one that ultimately reaches optimality but takes a long time.", + id: "Level of Performance After Some Time", + }, + ], + models: [ + { + description: "A Reinforcement Learning model trained on expert data from the Gym Hopper environment", + + id: "edbeeching/decision-transformer-gym-hopper-expert", + }, + { + description: "A PPO agent playing seals/CartPole-v0 using the stable-baselines3 library and the RL Zoo.", + id: "HumanCompatibleAI/ppo-seals-CartPole-v0", + }, + ], + spaces: [ + { + description: "An application for a cute puppy agent learning to catch a stick.", + id: "ThomasSimonini/Huggy", + }, + { + description: "An application to play Snowball Fight with a reinforcement learning agent.", + id: "ThomasSimonini/SnowballFight", + }, + ], + summary: + "Reinforcement learning is the computational approach of learning from action by interacting with an environment through trial and error and receiving rewards (negative or positive) as feedback", + widgetModels: [], + youtubeId: "q0BiUn5LiBc", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md new file mode 100644 index 0000000000000000000000000000000000000000..160d35d8185f68ab0da5f09093495cb0896ea7d6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md @@ -0,0 +1,97 @@ +## Use Cases 🔍 + +### Information Retrieval + +You can extract information from documents using Sentence Similarity models. The first step is to rank documents using Passage Ranking models. You can then get to the top ranked document and search it with Sentence Similarity models by selecting the sentence that has the most similarity to the input query. + +## The Sentence Transformers library + +The [Sentence Transformers](https://www.sbert.net/) library is very powerful for calculating embeddings of sentences, paragraphs, and entire documents. An embedding is just a vector representation of a text and is useful for finding how similar two texts are. + +You can find and use [thousands of Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using Inference Endpoints. + +## Task Variants + +### Passage Ranking + +Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Mean Reciprocal Rank. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄 + +You can infer with Passage Ranking models using [Inference Endpoints](https://huggingface.co/inference-endpoints). The Passage Ranking model inputs are a query for which we look for relevancy in the documents and the documents we want to search. The model will return scores according to the relevancy of these documents for the query. + +```python +import json +import requests + +API_URL = "https://router.huggingface.co/hf-inference/models/sentence-transformers/msmarco-distilbert-base-tas-b" +headers = {"Authorization": f"Bearer {api_token}"} + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response.json() + +data = query( + { + "inputs": { + "source_sentence": "That is a happy person", + "sentences": [ + "That is a happy dog", + "That is a very happy person", + "Today is a sunny day" + ] + } + } +## [0.853, 0.981, 0.655] +``` + +### Semantic Textual Similarity + +Semantic Textual Similarity is the task of evaluating how similar two texts are in terms of meaning. These models take a source sentence and a list of sentences in which we will look for similarities and will return a list of similarity scores. The benchmark dataset is the [Semantic Textual Similarity Benchmark](http://ixa2.si.ehu.eus/stswiki/index.php/STSbenchmark). The task is evaluated on Pearson’s Rank Correlation. + +```python +import json +import requests + +API_URL = "https://router.huggingface.co/hf-inference/models/sentence-transformers/all-MiniLM-L6-v2" +headers = {"Authorization": f"Bearer {api_token}"} + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response.json() + +data = query( + { + "inputs": { + "source_sentence": "I'm very happy", + "sentences":["I'm filled with happiness", "I'm happy"] + } + }) + +## [0.605, 0.894] +``` + +You can also infer with the models in the Hub using Sentence Transformer models. + +```python +pip install -U sentence-transformers + +from sentence_transformers import SentenceTransformer, util +sentences = ["I'm happy", "I'm full of happiness"] + +model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') + +# Compute embedding for both lists +embedding_1 = model.encode(sentences[0], convert_to_tensor=True) +embedding_2 = model.encode(sentences[1], convert_to_tensor=True) + +util.pytorch_cos_sim(embedding_1, embedding_2) +## tensor([[0.6003]]) +``` + +## Useful Resources + +Would you like to learn more about Sentence Transformers and Sentence Similarity? Awesome! Here you can find some curated resources that you may find helpful! + +- [Sentence Transformers Documentation](https://www.sbert.net/) +- [Sentence Transformers in the Hub](https://huggingface.co/blog/sentence-transformers-in-the-hub) +- [Building a Playlist Generator with Sentence Transformers](https://huggingface.co/blog/playlist-generator) +- [Getting Started With Embeddings](https://huggingface.co/blog/getting-started-with-embeddings) diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..4cad5c918cac065bb6c73ff29e30ce1f1fec02c3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts @@ -0,0 +1,105 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 0.623, + }, + { + label: "This is so difficult, like rocket science.", + score: 0.413, + }, + { + label: "I can't believe how much I struggled with this.", + score: 0.256, + }, + ], + }, + ], + }, + metrics: [ + { + description: + "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: + "The similarity of the embeddings is evaluated mainly on cosine similarity. It is calculated as the cosine of the angle between two vectors. It is particularly useful when your texts are not the same length", + id: "Cosine Similarity", + }, + ], + models: [ + { + description: + "This model works well for sentences and paragraphs and can be used for clustering/grouping and semantic searches.", + id: "sentence-transformers/all-mpnet-base-v2", + }, + { + description: "A multilingual robust sentence similarity model.", + id: "BAAI/bge-m3", + }, + { + description: "A robust sentence similarity model.", + id: "HIT-TMG/KaLM-embedding-multilingual-mini-instruct-v1.5", + }, + ], + spaces: [ + { + description: "An application that leverages sentence similarity to answer questions from YouTube videos.", + id: "Gradio-Blocks/Ask_Questions_To_YouTube_Videos", + }, + { + description: + "An application that retrieves relevant PubMed abstracts for a given online article which can be used as further references.", + id: "Gradio-Blocks/pubmed-abstract-retriever", + }, + { + description: "An application that leverages sentence similarity to summarize text.", + id: "nickmuchi/article-text-summarizer", + }, + { + description: "A guide that explains how Sentence Transformers can be used for semantic search.", + id: "sentence-transformers/Sentence_Transformers_for_semantic_search", + }, + ], + summary: + "Sentence Similarity is the task of determining how similar two texts are. Sentence similarity models convert input texts into vectors (embeddings) that capture semantic information and calculate how close (similar) they are between them. This task is particularly useful for information retrieval and clustering/grouping.", + widgetModels: ["sentence-transformers/all-MiniLM-L6-v2"], + youtubeId: "VCZq5AkbNEU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..c589124bdfa372c8974d177032485a3054d3cb94 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts @@ -0,0 +1,31 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +export type SentenceSimilarityOutput = number[]; +/** + * Inputs for Sentence similarity inference + */ +export interface SentenceSimilarityInput { + inputs: SentenceSimilarityInputData; + /** + * Additional inference parameters for Sentence Similarity + */ + parameters?: { + [key: string]: unknown; + }; + [property: string]: unknown; +} +export interface SentenceSimilarityInputData { + /** + * A list of strings which will be compared against the source_sentence. + */ + sentences: string[]; + /** + * The string that you wish to compare the other strings with. This can be a phrase, + * sentence, or longer passage, depending on the model being used. + */ + source_sentence: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..d724af588d3f57d9535e8f7e81a5e24d34e750d3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json @@ -0,0 +1,39 @@ +{ + "$id": "/inference/schemas/sentence-similarity/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Sentence similarity inference", + "title": "SentenceSimilarityInput", + "type": "object", + "properties": { + "inputs": { + "title": "SentenceSimilarityInputData", + "type": "object", + "properties": { + "source_sentence": { + "description": "The string that you wish to compare the other strings with. This can be a phrase, sentence, or longer passage, depending on the model being used.", + "type": "string" + }, + "sentences": { + "type": "array", + "description": "A list of strings which will be compared against the source_sentence.", + "items": { + "type": "string" + } + } + }, + "required": ["source_sentence", "sentences"] + }, + "parameters": { + "description": "Additional inference parameters for Sentence Similarity", + "$ref": "#/$defs/SentenceSimilarityParameters" + } + }, + "$defs": { + "SentenceSimilarityParameters": { + "title": "SentenceSimilarityParameters", + "type": "object", + "properties": {} + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..ca13d98bd5f55bd581e99c8cc4d970b9b7735512 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json @@ -0,0 +1,12 @@ +{ + "$id": "/inference/schemas/sentence-similarity/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "SentenceSimilarityOutput", + "description": "Outputs of inference for the Sentence Similarity task", + "type": "array", + "items": { + "description": "The associated similarity score for each of the given sentences", + "type": "number", + "title": "SentenceSimilarityScore" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/about.md b/node_modules/@huggingface/tasks/src/tasks/summarization/about.md new file mode 100644 index 0000000000000000000000000000000000000000..44c8d2a4a0e12aaf91562977f447edf214d894c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/about.md @@ -0,0 +1,58 @@ +## Use Cases + +### Research Paper Summarization 🧐 + +Research papers can be summarized to allow researchers to spend less time selecting which articles to read. There are several approaches you can take for a task like this: + +1. Use an existing extractive summarization model on the Hub to do inference. +2. Pick an existing language model trained for academic papers. This model can then be trained in a process called fine-tuning so it can solve the summarization task. +3. Use a sequence-to-sequence model like [T5](https://huggingface.co/docs/transformers/model_doc/t5) for abstractive text summarization. + +## Inference + +You can use the 🤗 Transformers library `summarization` pipeline to infer with existing Summarization models. If no model name is provided the pipeline will be initialized with [sshleifer/distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6). + +```python +from transformers import pipeline + +classifier = pipeline("summarization") +classifier("Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017.") +## [{ "summary_text": " Paris is the capital and most populous city of France..." }] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer summarization models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +const inputs = + "Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017."; + +await inference.summarization({ + model: "sshleifer/distilbart-cnn-12-6", + inputs, +}); +``` + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Summarization](https://huggingface.co/course/chapter7/5?fw=pt) +- [Distributed Training: Train BART/T5 for Summarization using 🤗 Transformers and Amazon SageMaker](https://huggingface.co/blog/sagemaker-distributed-training-seq2seq) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/summarization.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/summarization-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/summarization) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/summarization) + +### Documentation + +- [Summarization task guide](https://huggingface.co/docs/transformers/tasks/summarization) diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts b/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..744503ece07e487fb1463bb6f764cb64a6633a05 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts @@ -0,0 +1,76 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-generation", + datasets: [ + { + description: + "News articles in five different languages along with their summaries. Widely used for benchmarking multilingual summarization models.", + id: "mlsum", + }, + { + description: "English conversations and their summaries. Useful for benchmarking conversational agents.", + id: "samsum", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: + "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. It was the first structure to reach a height of 300 metres. Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: + "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building. It was the first structure to reach a height of 300 metres.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "The generated sequence is compared against its summary, and the overlap of tokens are counted. ROUGE-N refers to overlap of N subsequent tokens, ROUGE-1 refers to overlap of single tokens and ROUGE-2 is the overlap of two subsequent tokens.", + id: "rouge", + }, + ], + models: [ + { + description: + "A strong summarization model trained on English news articles. Excels at generating factual summaries.", + id: "facebook/bart-large-cnn", + }, + { + description: "A summarization model trained on medical articles.", + id: "Falconsai/medical_summarization", + }, + ], + spaces: [ + { + description: "An application that can summarize long paragraphs.", + id: "pszemraj/summarize-long-text", + }, + { + description: "A much needed summarization application for terms and conditions.", + id: "ml6team/distilbart-tos-summarizer-tosdr", + }, + { + description: "An application that summarizes long documents.", + id: "pszemraj/document-summarization", + }, + { + description: "An application that can detect errors in abstractive summarization.", + id: "ml6team/post-processing-summarization", + }, + ], + summary: + "Summarization is the task of producing a shorter version of a document while preserving its important information. Some models can extract text from the original input, while other models can generate entirely new text.", + widgetModels: ["facebook/bart-large-cnn"], + youtubeId: "yHnr5Dk2zCI", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts b/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed28c5632f713eda38f6c4b669c5843c5845e073 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Summarization inference + */ +export interface SummarizationInput { + /** + * The input text to summarize. + */ + inputs: string; + /** + * Additional inference parameters for summarization. + */ + parameters?: SummarizationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for summarization. + */ +export interface SummarizationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The truncation strategy to use. + */ + truncation?: SummarizationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type SummarizationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Summarization task + */ +export interface SummarizationOutput { + /** + * The summarized text. + */ + summary_text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..c2d7aebaf578bab13eff197aea6d51dff2bb5d4a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json @@ -0,0 +1,41 @@ +{ + "$id": "/inference/schemas/summarization/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Summarization inference", + "title": "SummarizationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text to summarize.", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for summarization.", + "$ref": "#/$defs/SummarizationParameters" + } + }, + "$defs": { + "SummarizationParameters": { + "title": "SummarizationParameters", + "type": "object", + "properties": { + "clean_up_tokenization_spaces": { + "type": "boolean", + "description": "Whether to clean up the potential extra spaces in the text output." + }, + "truncation": { + "title": "SummarizationTruncationStrategy", + "type": "string", + "description": "The truncation strategy to use.", + "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"] + }, + "generate_parameters": { + "title": "generateParameters", + "type": "object", + "description": "Additional parametrization of the text generation algorithm." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..dfa307b642213451b0aa7e8b88d1bfdaf6f77598 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/summarization/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Summarization task", + "title": "SummarizationOutput", + "type": "object", + "properties": { + "summary_text": { + "type": "string", + "description": "The summarized text." + } + }, + "required": ["summary_text"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..62cdb44ad25d94249ea6c4953a054b60c4021057 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md @@ -0,0 +1,43 @@ +## Use Cases + +### SQL execution + +You can use the Table Question Answering models to simulate SQL execution by inputting a table. + +### Table Question Answering + +Table Question Answering models are capable of answering questions based on a table. + +## Task Variants + +This place can be filled with variants of this task if there's any. + +## Inference + +You can infer with TableQA models using the 🤗 Transformers library. + +```python +from transformers import pipeline +import pandas as pd + +# prepare table + question +data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]} +table = pd.DataFrame.from_dict(data) +question = "how many movies does Leonardo Di Caprio have?" + +# pipeline model +# Note: you must to install torch-scatter first. +tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq") + +# result + +print(tqa(table=table, query=question)['cells'][0]) +#53 + +``` + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. + +This task page is complete thanks to the efforts of [Hao Kim Tieu](https://huggingface.co/haotieu). 🦸 diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5f161a4ca80310e591d20d96ea53d33ffe49d10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts @@ -0,0 +1,59 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "The WikiTableQuestions dataset is a large-scale dataset for the task of question answering on semi-structured tables.", + id: "wikitablequestions", + }, + { + description: + "WikiSQL is a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia.", + id: "wikisql", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Rank", "Name", "No.of reigns", "Combined days"], + ["1", "lou Thesz", "3", "3749"], + ["2", "Ric Flair", "8", "3103"], + ["3", "Harley Race", "7", "1799"], + ], + type: "tabular", + }, + + { label: "Question", content: "What is the number of reigns for Harley Race?", type: "text" }, + ], + outputs: [{ label: "Result", content: "7", type: "text" }], + }, + metrics: [ + { + description: "Checks whether the predicted answer(s) is the same as the ground-truth answer(s).", + id: "Denotation Accuracy", + }, + ], + models: [ + { + description: + "A table question answering model that is capable of neural SQL execution, i.e., employ TAPEX to execute a SQL query on a given table.", + id: "microsoft/tapex-base", + }, + { + description: "A robust table question answering model.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that answers questions based on table CSV files.", + id: "katanaml/table-query", + }, + ], + summary: "Table Question Answering (Table QA) is the answering a question about an information on a given table.", + widgetModels: ["google/tapas-base-finetuned-wtq"], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..18339e033180ad689aae33ccc671cc14c157f0b8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts @@ -0,0 +1,83 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Table Question Answering inference + */ +export interface TableQuestionAnsweringInput { + /** + * One (table, question) pair to answer + */ + inputs: TableQuestionAnsweringInputData; + /** + * Additional inference parameters for Table Question Answering + */ + parameters?: TableQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (table, question) pair to answer + */ +export interface TableQuestionAnsweringInputData { + /** + * The question to be answered about the table + */ + question: string; + /** + * The table to serve as context for the questions + */ + table: { + [key: string]: string[]; + }; + [property: string]: unknown; +} +/** + * Additional inference parameters for Table Question Answering + */ +export interface TableQuestionAnsweringParameters { + /** + * Activates and controls padding. + */ + padding?: Padding; + /** + * Whether to do inference sequentially or as a batch. Batching is faster, but models like + * SQA require the inference to be done sequentially to extract relations within sequences, + * given their conversational nature. + */ + sequential?: boolean; + /** + * Activates and controls truncation. + */ + truncation?: boolean; + [property: string]: unknown; +} +/** + * Activates and controls padding. + */ +export type Padding = "do_not_pad" | "longest" | "max_length"; +export type TableQuestionAnsweringOutput = TableQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Table Question Answering task + */ +export interface TableQuestionAnsweringOutputElement { + /** + * If the model has an aggregator, this returns the aggregator. + */ + aggregator?: string; + /** + * The answer of the question given the table. If there is an aggregator, the answer will be + * preceded by `AGGREGATOR >`. + */ + answer: string; + /** + * List of strings made up of the answer cell values. + */ + cells: string[]; + /** + * Coordinates of the cells of the answers. + */ + coordinates: Array; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..67cc18eae986d8d392c4b5842cf9ecd7aec4309c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json @@ -0,0 +1,60 @@ +{ + "$id": "/inference/schemas/table-question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Table Question Answering inference", + "title": "TableQuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "description": "One (table, question) pair to answer", + "title": "TableQuestionAnsweringInputData", + "type": "object", + "properties": { + "table": { + "description": "The table to serve as context for the questions", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "question": { + "description": "The question to be answered about the table", + "type": "string" + } + }, + "required": ["table", "question"] + }, + "parameters": { + "description": "Additional inference parameters for Table Question Answering", + "$ref": "#/$defs/TableQuestionAnsweringParameters" + } + }, + "$defs": { + "TableQuestionAnsweringParameters": { + "title": "TableQuestionAnsweringParameters", + "type": "object", + "properties": { + "padding": { + "type": "string", + "default": "do_not_pad", + "description": "Activates and controls padding.", + "enum": ["do_not_pad", "longest", "max_length"] + }, + "sequential": { + "type": "boolean", + "default": "false", + "description": "Whether to do inference sequentially or as a batch. Batching is faster, but models like SQA require the inference to be done sequentially to extract relations within sequences, given their conversational nature." + }, + "truncation": { + "type": "boolean", + "default": "false", + "description": "Activates and controls truncation." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..9b43026ea12299dc83110c99d3983841a8d30c6e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json @@ -0,0 +1,40 @@ +{ + "$id": "/inference/schemas/table-question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Table Question Answering task", + "title": "TableQuestionAnsweringOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer of the question given the table. If there is an aggregator, the answer will be preceded by `AGGREGATOR >`." + }, + "coordinates": { + "type": "array", + "description": "Coordinates of the cells of the answers.", + "items": { + "type": "array", + "items": { + "type": "integer" + }, + "minLength": 2, + "maxLength": 2 + } + }, + "cells": { + "type": "array", + "description": "List of strings made up of the answer cell values.", + "items": { + "type": "string" + } + }, + "aggregator": { + "type": "string", + "description": "If the model has an aggregator, this returns the aggregator." + } + }, + "required": ["answer", "cells", "coordinates"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..d46a48976c894b8a5d99dda14a893261c49e6d41 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md @@ -0,0 +1,65 @@ +## About the Task + +Tabular classification is the task of assigning a label or class given a limited number of attributes. For example, the input can be data related to a customer (balance of the customer, the time being a customer, or more) and the output can be whether the customer will churn from the service or not. +There are three types of categorical variables: + +- Binary variables: Variables that can take two values, like yes or no, open or closed. The task of predicting binary variables is called binary classification. +- Ordinal variables: Variables with a ranking relationship, e.g., good, insignificant, and bad product reviews. The task of predicting ordinal variables is called ordinal classification. +- Nominal variables: Variables with no ranking relationship among them, e.g., predicting an animal from their weight and height, where categories are cat, dog, or bird. The task of predicting nominal variables is called multinomial classification. + +## Use Cases + +### Fraud Detection +Tabular classification models can be used in detecting fraudulent credit card transactions, where the features could be the amount of the transaction and the account balance, and the target to predict could be whether the transaction is fraudulent or not. This is an example of binary classification. + +### Churn Prediction +Tabular classification models can be used in predicting customer churn in telecommunication. An example dataset for the task is hosted [here](https://huggingface.co/datasets/scikit-learn/churn-prediction). + +# Model Hosting and Inference + +You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can: + +- Easily use Inference Endpoints +- Build neat UIs with one line of code, +- Programmatically create model cards, +- Securely serialize your scikit-learn model. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).) + +You can push your model as follows: + +```python +from skops import hub_utils +# initialize a repository with a trained model +local_repo = "/path_to_new_repo" +hub_utils.init(model, dst=local_repo) +# push to Hub! +hub_utils.push("username/my-awesome-model", source=local_repo) +``` + +Once the model is pushed, you can infer easily. + +```python +import skops.hub_utils as hub_utils +import pandas as pd +data = pd.DataFrame(your_data) +# Load the model from the Hub +res = hub_utils.get_model_output("username/my-awesome-model", data) +``` + +You can launch a UI for your model with only one line of code! + +```python +import gradio as gr +gr.Interface.load("huggingface/username/my-awesome-model").launch() +``` + +## Useful Resources + +- Check out the [scikit-learn organization](https://huggingface.co/scikit-learn) to learn more about different algorithms used for this task. +- [Skops documentation](https://skops.readthedocs.io/en/latest/) +- [Skops announcement blog](https://huggingface.co/blog/skops) +- [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops) +- Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio. + +### Training your own model in just a few seconds + +We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model. diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..80dbe57d20a127d16e3ddecaeae5afe5e888cde1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts @@ -0,0 +1,68 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Glucose", "Blood Pressure ", "Skin Thickness", "Insulin", "BMI"], + ["148", "72", "35", "0", "33.6"], + ["150", "50", "30", "0", "35.1"], + ["141", "60", "29", "1", "39.2"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["Diabetes"], ["1"], ["1"], ["0"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "Breast cancer prediction model based on decision trees.", + id: "scikit-learn/cancer-prediction-trees", + }, + ], + spaces: [ + { + description: "An application that can predict defective products on a production line.", + id: "scikit-learn/tabular-playground", + }, + { + description: "An application that compares various tabular classification techniques on different datasets.", + id: "scikit-learn/classification", + }, + ], + summary: "Tabular classification is the task of classifying a target category (a group) based on set of attributes.", + widgetModels: ["scikit-learn/tabular-playground"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md new file mode 100644 index 0000000000000000000000000000000000000000..4a6d9d302cc484c9b8b642d8bdba4e4f626a2e13 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md @@ -0,0 +1,86 @@ +## About the Task + +Tabular regression is the task of predicting a numerical value given a set of attributes/features. _Tabular_ meaning that data is stored in a table (like an excel sheet), and each sample is contained in its own row. The features used to predict our target can be both numerical and categorical. However, including categorical features often requires additional preprocessing/feature engineering (a few models do accept categorical features directly, like [CatBoost](https://catboost.ai/)). An example of tabular regression would be predicting the weight of a fish given its' species and length. + +## Use Cases + +### Sales Prediction: a Use Case for Predicting a Continuous Target Variable + +Here the objective is to predict a continuous variable based on a set of input variable(s). For example, predicting `sales` of an ice cream shop based on `temperature` of weather and `duration of hours` shop was open. Here we can build a regression model with `temperature` and `duration of hours` as input variable and `sales` as target variable. + +### Missing Value Imputation for Other Tabular Tasks +In real-world applications, due to human error or other reasons, some of the input values can be missing or there might not be any recorded data. Considering the example above, say the shopkeeper's watch was broken and they forgot to calculate the `hours` for which the shop was open. This will lead to a missing value in their dataset. In this case, missing values could be replaced it with zero, or average hours for which the shop is kept open. Another approach we can try is to use `temperature` and `sales` variables to predict the `hours` variable here. + +## Model Training + +A simple regression model can be created using `sklearn` as follows: + +```python +#set the input features +X = data[["Feature 1", "Feature 2", "Feature 3"]] +#set the target variable +y = data["Target Variable"] +#initialize the model +model = LinearRegression() +#Fit the model +model.fit(X, y) +``` + +# Model Hosting and Inference + +You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can: + +- Easily use Inference Endpoints, +- Build neat UIs with one line of code, +- Programmatically create model cards, +- Securely serialize your models. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).) + +You can push your model as follows: + +```python +from skops import hub_utils +# initialize a repository with a trained model +local_repo = "/path_to_new_repo" +hub_utils.init(model, dst=local_repo) +# push to Hub! +hub_utils.push("username/my-awesome-model", source=local_repo) +``` + +Once the model is pushed, you can infer easily. + +```python +import skops.hub_utils as hub_utils +import pandas as pd +data = pd.DataFrame(your_data) +# Load the model from the Hub +res = hub_utils.get_model_output("username/my-awesome-model", data) +``` + +You can launch a UI for your model with only one line of code! + +```python +import gradio as gr +gr.Interface.load("huggingface/username/my-awesome-model").launch() +``` + +## Useful Resources + +- [Skops documentation](https://skops.readthedocs.io/en/stable/index.html) + +- Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio. +- [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops) + +- For starting with tabular regression: + - Doing [Exploratory Data Analysis](https://neptune.ai/blog/exploratory-data-analysis-for-tabular-data) for tabular data. + - The data considered here consists of details of Olympic athletes and medal results from Athens 1896 to Rio 2016. + - Here you can learn more about how to explore and analyse the data and visualize them in order to get a better understanding of dataset. + - Building your [first ML model](https://www.kaggle.com/code/dansbecker/your-first-machine-learning-model). + +- Intermediate level tutorials on tabular regression: + - [A Short Chronology of Deep Learning for Tabular Data](https://sebastianraschka.com/blog/2022/deep-learning-for-tabular-data.html) by Sebastian Raschka. + +### Training your own model in just a few seconds + +We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model. + +This page was made possible thanks to efforts of [Brenden Connors](https://huggingface.co/brendenc) and [Ayush Bihani](https://huggingface.co/hsuyab). diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4c0b6d018687d90a46654c90e8c3e5c9773816a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts @@ -0,0 +1,57 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Car Name", "Horsepower", "Weight"], + ["ford torino", "140", "3,449"], + ["amc hornet", "97", "2,774"], + ["toyota corolla", "65", "1,773"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["MPG (miles per gallon)"], ["17"], ["18"], ["31"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "mse", + }, + { + description: + "Coefficient of determination (or R-squared) is a measure of how well the model fits the data. Higher R-squared is considered a better fit.", + id: "r-squared", + }, + ], + models: [ + { + description: "Fish weight prediction based on length measurements and species.", + id: "scikit-learn/Fish-Weight", + }, + ], + spaces: [ + { + description: "An application that can predict weight of a fish based on set of attributes.", + id: "scikit-learn/fish-weight-prediction", + }, + ], + summary: "Tabular regression is the task of predicting a numerical value given a set of attributes.", + widgetModels: ["scikit-learn/Fish-Weight"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..dc0bfdf4709bb7a6b06529b2a6e18a1099738d14 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md @@ -0,0 +1,173 @@ +## Use Cases + +### Sentiment Analysis on Customer Reviews + +You can track the sentiments of your customers from the product reviews using sentiment analysis models. This can help understand churn and retention by grouping reviews by sentiment, to later analyze the text and make strategic decisions based on this knowledge. + +## Task Variants + +### Natural Language Inference (NLI) + +In NLI the model determines the relationship between two given texts. Concretely, the model takes a premise and a hypothesis and returns a class that can either be: + +- **entailment**, which means the hypothesis is true. +- **contraction**, which means the hypothesis is false. +- **neutral**, which means there's no relation between the hypothesis and the premise. + +The benchmark dataset for this task is GLUE (General Language Understanding Evaluation). NLI models have different variants, such as Multi-Genre NLI, Question NLI and Winograd NLI. + +### Multi-Genre NLI (MNLI) + +MNLI is used for general NLI. Here are som examples: + +``` +Example 1: + Premise: A man inspects the uniform of a figure in some East Asian country. + Hypothesis: The man is sleeping. + Label: Contradiction + +Example 2: + Premise: Soccer game with multiple males playing. + Hypothesis: Some men are playing a sport. + Label: Entailment +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with NLI models. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "roberta-large-mnli") +classifier("A soccer game with multiple males playing. Some men are playing a sport.") +## [{'label': 'ENTAILMENT', 'score': 0.98}] +``` + +### Question Natural Language Inference (QNLI) + +QNLI is the task of determining if the answer to a certain question can be found in a given document. If the answer can be found the label is “entailment”. If the answer cannot be found the label is “not entailment". + +``` +Question: What percentage of marine life died during the extinction? +Sentence: It is also known as the “Great Dying” because it is considered the largest mass extinction in the Earth’s history. +Label: not entailment + +Question: Who was the London Weekend Television’s Managing Director? +Sentence: The managing director of London Weekend Television (LWT), Greg Dyke, met with the representatives of the "big five" football clubs in England in 1990. +Label: entailment +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with QNLI models. The model returns the label and the confidence. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "cross-encoder/qnli-electra-base") +classifier("Where is the capital of France?, Paris is the capital of France.") +## [{'label': 'entailment', 'score': 0.997}] +``` + +### Sentiment Analysis + +In Sentiment Analysis, the classes can be polarities like positive, negative, neutral, or sentiments such as happiness or anger. + +#### Inference + +You can use the 🤗 Transformers library with the `sentiment-analysis` pipeline to infer with Sentiment Analysis models. The model returns the label with the score. + +```python +from transformers import pipeline + +classifier = pipeline("sentiment-analysis") +classifier("I loved Star Wars so much!") +## [{'label': 'POSITIVE', 'score': 0.99} +``` + +### Quora Question Pairs + +Quora Question Pairs models assess whether two provided questions are paraphrases of each other. The model takes two questions and returns a binary value, with 0 being mapped to “not paraphrase” and 1 to “paraphrase". The benchmark dataset is [Quora Question Pairs](https://huggingface.co/datasets/glue/viewer/qqp/test) inside the [GLUE benchmark](https://huggingface.co/datasets/glue). The dataset consists of question pairs and their labels. + +``` +Question1: “How can I increase the speed of my internet connection while using a VPN?” +Question2: How can Internet speed be increased by hacking through DNS? +Label: Not paraphrase + +Question1: “What can make Physics easy to learn?” +Question2: “How can you make physics easy to learn?” +Label: Paraphrase +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with QQPI models. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "textattack/bert-base-uncased-QQP") +classifier("Which city is the capital of France?, Where is the capital of France?") +## [{'label': 'paraphrase', 'score': 0.998}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text classification models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.conversational({ + model: "distilbert-base-uncased-finetuned-sst-2-english", + inputs: "I love this movie!", +}); +``` + +### Grammatical Correctness + +Linguistic Acceptability is the task of assessing the grammatical acceptability of a sentence. The classes in this task are “acceptable” and “unacceptable”. The benchmark dataset used for this task is [Corpus of Linguistic Acceptability (CoLA)](https://huggingface.co/datasets/glue/viewer/cola/test). The dataset consists of texts and their labels. + +``` +Example: Books were sent to each other by the students. +Label: Unacceptable + +Example: She voted for herself. +Label: Acceptable. +``` + +#### Inference + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "textattack/distilbert-base-uncased-CoLA") +classifier("I will walk to home when I went through the bus.") +## [{'label': 'unacceptable', 'score': 0.95}] +``` + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit](https://huggingface.co/blog/setfit-absa) +- [Course Chapter on Fine-tuning a Text Classification Model](https://huggingface.co/course/chapter3/1?fw=pt) +- [Getting Started with Sentiment Analysis using Python](https://huggingface.co/blog/sentiment-analysis-python) +- [Sentiment Analysis on Encrypted Data with Homomorphic Encryption](https://huggingface.co/blog/sentiment-analysis-fhe) +- [Leveraging Hugging Face for complex text classification use cases](https://huggingface.co/blog/classification-use-cases) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/text_classification.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/text_classification-tf.ipynb) +- [Flax](https://github.com/huggingface/notebooks/blob/master/examples/text_classification_flax.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-classification) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/text-classification) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/text-classification) + +### Documentation + +- [Text classification task guide](https://huggingface.co/docs/transformers/tasks/sequence_classification) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ba1506e9bc6379d2226a64f5cdd24e2c629d881 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts @@ -0,0 +1,103 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: "A text classification dataset used to benchmark natural language inference models", + id: "stanfordnlp/snli", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love Hugging Face!", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "POSITIVE", + score: 0.9, + }, + { + label: "NEUTRAL", + score: 0.1, + }, + { + label: "NEGATIVE", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: + "The F1 metric is the harmonic mean of the precision and recall. It can be calculated as: F1 = 2 * (precision * recall) / (precision + recall)", + id: "f1", + }, + ], + models: [ + { + description: "A robust model trained for sentiment analysis.", + id: "distilbert/distilbert-base-uncased-finetuned-sst-2-english", + }, + { + description: "A sentiment analysis model specialized in financial sentiment.", + id: "ProsusAI/finbert", + }, + { + description: "A sentiment analysis model specialized in analyzing tweets.", + id: "cardiffnlp/twitter-roberta-base-sentiment-latest", + }, + { + description: "A model that can classify languages.", + id: "papluca/xlm-roberta-base-language-detection", + }, + { + description: "A model that can classify text generation attacks.", + id: "meta-llama/Prompt-Guard-86M", + }, + ], + spaces: [ + { + description: "An application that can classify financial sentiment.", + id: "IoannisTr/Tech_Stocks_Trading_Assistant", + }, + { + description: "A dashboard that contains various text classification tasks.", + id: "miesnerjacob/Multi-task-NLP", + }, + { + description: "An application that analyzes user reviews in healthcare.", + id: "spacy/healthsea-demo", + }, + ], + summary: + "Text Classification is the task of assigning a label or class to a given text. Some use cases are sentiment analysis, natural language inference, and assessing grammatical correctness.", + widgetModels: ["distilbert/distilbert-base-uncased-finetuned-sst-2-english"], + youtubeId: "leNG9fN9FQU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..84d6a80fe35f1257534d89aff2ed66101cdfc50a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts @@ -0,0 +1,52 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text Classification inference + */ +export interface TextClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Text Classification + */ + parameters?: TextClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text Classification + */ +export interface TextClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type TextClassificationOutput = TextClassificationOutputElement[]; +/** + * Outputs of inference for the Text Classification task + */ +export interface TextClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..468f865dd598af5a8ee581f7a1b8245770d65662 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json @@ -0,0 +1,35 @@ +{ + "$id": "/inference/schemas/text-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text Classification inference", + "title": "TextClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to classify", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text Classification", + "$ref": "#/$defs/TextClassificationParameters" + } + }, + "$defs": { + "TextClassificationParameters": { + "title": "TextClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "TextClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..2bf3def357d3cfd65e9ca7f4f2fdc191ded633db --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/text-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text Classification task", + "title": "TextClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..ee8cdeadcff207f6c1b7e5c1faa8d6cbf3ab4023 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md @@ -0,0 +1,154 @@ +This task covers guides on both [text-generation](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads) and [text-to-text generation](https://huggingface.co/models?other=text2text-generation&sort=downloads) models. Popular large language models that are used for chats or following instructions are also covered in this task. You can find the list of selected open-source large language models [here](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), ranked by their performance scores. + +## Use Cases + +### Instruction Models + +A model trained for text generation can be later adapted to follow instructions. You can try some of the most powerful instruction-tuned open-access models like Mixtral 8x7B, Cohere Command R+, and Meta Llama3 70B [at Hugging Chat](https://huggingface.co/chat). + +### Code Generation + +A Text Generation model, also known as a causal language model, can be trained on code from scratch to help the programmers in their repetitive coding tasks. One of the most popular open-source models for code generation is StarCoder, which can generate code in 80+ languages. You can try it [here](https://huggingface.co/spaces/bigcode/bigcode-playground). + +### Stories Generation + +A story generation model can receive an input like "Once upon a time" and proceed to create a story-like text based on those first words. You can try [this application](https://huggingface.co/spaces/mosaicml/mpt-7b-storywriter) which contains a model trained on story generation, by MosaicML. + +If your generative model training data is different than your use case, you can train a causal language model from scratch. Learn how to do it in the free transformers [course](https://huggingface.co/course/chapter7/6?fw=pt)! + +## Task Variants + +### Completion Generation Models + +A popular variant of Text Generation models predicts the next word given a bunch of words. Word by word a longer text is formed that results in for example: + +- Given an incomplete sentence, complete it. +- Continue a story given the first sentences. +- Provided a code description, generate the code. + +The most popular models for this task are GPT-based models, [Mistral](mistralai/Mistral-7B-v0.1) or [Llama series](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf). These models are trained on data that has no labels, so you just need plain text to train your own model. You can train text generation models to generate a wide variety of documents, from code to stories. + +### Text-to-Text Generation Models + +These models are trained to learn the mapping between a pair of texts (e.g. translation from one language to another). The most popular variants of these models are [NLLB](facebook/nllb-200-distilled-600M), [FLAN-T5](https://huggingface.co/google/flan-t5-xxl), and [BART](https://huggingface.co/docs/transformers/model_doc/bart). Text-to-Text models are trained with multi-tasking capabilities, they can accomplish a wide range of tasks, including summarization, translation, and text classification. + +## Language Model Variants + +When it comes to text generation, the underlying language model can come in several types: + +- **Base models:** refers to plain language models like [Mistral 7B](https://huggingface.co/mistralai/Mistral-7B-v0.3) and [Meta Llama-3-70b](https://huggingface.co/meta-llama/Meta-Llama-3-70B). These models are good for fine-tuning and few-shot prompting. + +- **Instruction-trained models:** these models are trained in a multi-task manner to follow a broad range of instructions like "Write me a recipe for chocolate cake". Models like [Qwen 2 7B](https://huggingface.co/Qwen/Qwen2-7B-Instruct), [Yi 1.5 34B Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat), and [Meta Llama 70B Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct) are examples of instruction-trained models. In general, instruction-trained models will produce better responses to instructions than base models. + +- **Human feedback models:** these models extend base and instruction-trained models by incorporating human feedback that rates the quality of the generated text according to criteria like [helpfulness, honesty, and harmlessness](https://arxiv.org/abs/2112.00861). The human feedback is then combined with an optimization technique like reinforcement learning to align the original model to be closer with human preferences. The overall methodology is often called [Reinforcement Learning from Human Feedback](https://huggingface.co/blog/rlhf), or RLHF for short. [Zephyr ORPO 141B A35B](https://huggingface.co/HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1) is an open-source model aligned through human feedback. + +## Text Generation from Image and Text + +There are language models that can input both text and image and output text, called vision language models. [IDEFICS 2](https://huggingface.co/HuggingFaceM4/idefics2-8b) and [MiniCPM Llama3 V](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5) are good examples. They accept the same generation parameters as other language models. However, since they also take images as input, you have to use them with the `image-to-text` pipeline. You can find more information about this in the [image-to-text task page](https://huggingface.co/tasks/image-to-text). + +## Inference + +You can use the 🤗 Transformers library `text-generation` pipeline to do inference with Text Generation models. It takes an incomplete text and returns multiple outputs with which the text can be completed. + +```python +from transformers import pipeline +generator = pipeline('text-generation', model = 'HuggingFaceH4/zephyr-7b-beta') +generator("Hello, I'm a language model", max_length = 30, num_return_sequences=3) +## [{'generated_text': "Hello, I'm a language modeler. So while writing this, when I went out to meet my wife or come home she told me that my"}, +## {'generated_text': "Hello, I'm a language modeler. I write and maintain software in Python. I love to code, and that includes coding things that require writing"}, ... +``` + +[Text-to-Text generation models](https://huggingface.co/models?other=text2text-generation&sort=downloads) have a separate pipeline called `text2text-generation`. This pipeline takes an input containing the sentence including the task and returns the output of the accomplished task. + +```python +from transformers import pipeline + +text2text_generator = pipeline("text2text-generation") +text2text_generator("question: What is 42 ? context: 42 is the answer to life, the universe and everything") +[{'generated_text': 'the answer to life, the universe and everything'}] + +text2text_generator("translate from English to French: I'm very happy") +[{'generated_text': 'Je suis très heureux'}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text classification models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.conversational({ + model: "distilbert-base-uncased-finetuned-sst-2-english", + inputs: "I love this movie!", +}); +``` + +## Text Generation Inference + +[Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is an open-source toolkit for serving LLMs tackling challenges such as response time. TGI powers inference solutions like [Inference Endpoints](https://huggingface.co/inference-endpoints) and [Hugging Chat](https://huggingface.co/chat/), as well as multiple community projects. You can use it to deploy any supported open-source large language model of your choice. + +## ChatUI Spaces + +Hugging Face Spaces includes templates to easily deploy your own instance of a specific application. [ChatUI](https://github.com/huggingface/chat-ui) is an open-source interface that enables serving conversational interface for large language models and can be deployed with few clicks at Spaces. TGI powers these Spaces under the hood for faster inference. Thanks to the template, you can deploy your own instance based on a large language model with only a few clicks and customize it. Learn more about it [here](https://huggingface.co/docs/hub/spaces-sdks-docker-chatui) and create your large language model instance [here](https://huggingface.co/new-space?template=huggingchat/chat-ui-template). + +![ChatUI](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/os_llms/docker_chat.png) + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +### Tools within Hugging Face Ecosystem + +- You can use [PEFT](https://github.com/huggingface/peft) to adapt large language models in efficient way. +- [ChatUI](https://github.com/huggingface/chat-ui) is the open-source interface to conversate with Large Language Models. +- [text-generation-inference](https://github.com/huggingface/text-generation-inference) +- [HuggingChat](https://huggingface.co/chat/) is a chat interface powered by Hugging Face to chat with powerful models like Meta Llama 3 70B, Mixtral 8x7B, etc. + +### Documentation + +- [PEFT documentation](https://huggingface.co/docs/peft/index) +- [ChatUI Docker Spaces](https://huggingface.co/docs/hub/spaces-sdks-docker-chatui) +- [Causal language modeling task guide](https://huggingface.co/docs/transformers/tasks/language_modeling) +- [Text generation strategies](https://huggingface.co/docs/transformers/generation_strategies) +- [Course chapter on training a causal language model from scratch](https://huggingface.co/course/chapter7/6?fw=pt) + +### Model Inference & Deployment + +- [Optimizing your LLM in production](https://huggingface.co/blog/optimize-llm) +- [Open-Source Text Generation & LLM Ecosystem at Hugging Face](https://huggingface.co/blog/os-llms) +- [Introducing RWKV - An RNN with the advantages of a transformer](https://huggingface.co/blog/rwkv) +- [Llama 2 is at Hugging Face](https://huggingface.co/blog/llama2) +- [Guiding Text Generation with Constrained Beam Search in 🤗 Transformers](https://huggingface.co/blog/constrained-beam-search) +- [Code generation with Hugging Face](https://huggingface.co/spaces/codeparrot/code-generation-models) +- [Assisted Generation: a new direction toward low-latency text generation](https://huggingface.co/blog/assisted-generation) +- [How to generate text: using different decoding methods for language generation with Transformers](https://huggingface.co/blog/how-to-generate) +- [Faster Text Generation with TensorFlow and XLA](https://huggingface.co/blog/tf-xla-generate) + +### Model Fine-tuning/Training + +- [Non-engineers guide: Train a LLaMA 2 chatbot](https://huggingface.co/blog/Llama2-for-non-engineers) +- [Training CodeParrot 🦜 from Scratch](https://huggingface.co/blog/codeparrot) +- [Creating a Coding Assistant with StarCoder](https://huggingface.co/blog/starchat-alpha) + +### Advanced Concepts Explained Simply + +- [Mixture of Experts Explained](https://huggingface.co/blog/moe) + +### Advanced Fine-tuning/Training Recipes + +- [Fine-tuning Llama 2 70B using PyTorch FSDP](https://huggingface.co/blog/ram-efficient-pytorch-fsdp) +- [The N Implementation Details of RLHF with PPO](https://huggingface.co/blog/the_n_implementation_details_of_rlhf_with_ppo) +- [Preference Tuning LLMs with Direct Preference Optimization Methods](https://huggingface.co/blog/pref-tuning) +- [Fine-tune Llama 2 with DPO](https://huggingface.co/blog/dpo-trl) + +### Notebooks + +- [Training a CLM in Flax](https://github.com/huggingface/notebooks/blob/master/examples/causal_language_modeling_flax.ipynb) +- [Training a CLM in TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling_from_scratch-tf.ipynb) +- [Training a CLM in PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling_from_scratch.ipynb) + +### Scripts for training + +- [Training a CLM in PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling) +- [Training a CLM in TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling) +- [Text Generation in PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-generation) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..a43fb437027db6b2b73e985342945ee17d10f058 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts @@ -0,0 +1,130 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Multilingual dataset used to evaluate text generation models.", + id: "CohereForAI/Global-MMLU", + }, + { + description: "High quality multilingual data used to train text-generation models.", + id: "HuggingFaceFW/fineweb-2", + }, + { + description: "Truly open-source, curated and cleaned dialogue dataset.", + id: "HuggingFaceH4/ultrachat_200k", + }, + { + description: "A reasoning dataset.", + id: "open-r1/OpenThoughts-114k-math", + }, + { + description: "A multilingual instruction dataset with preference ratings on responses.", + id: "allenai/tulu-3-sft-mixture", + }, + { + description: "A large synthetic dataset for alignment of text generation models.", + id: "HuggingFaceTB/smoltalk", + }, + { + description: "A dataset made for training text generation models solving math questions.", + id: "HuggingFaceTB/finemath", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Once upon a time,", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: + "Once upon a time, we knew that our ancestors were on the verge of extinction. The great explorers and poets of the Old World, from Alexander the Great to Chaucer, are dead and gone. A good many of our ancient explorers and poets have", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Cross Entropy is a metric that calculates the difference between two probability distributions. Each probability distribution is the distribution of predicted words", + id: "Cross Entropy", + }, + { + description: + "The Perplexity metric is the exponential of the cross-entropy loss. It evaluates the probabilities assigned to the next word by the model. Lower perplexity indicates better performance", + id: "Perplexity", + }, + ], + models: [ + { description: "A text-generation model trained to follow instructions.", id: "google/gemma-2-2b-it" }, + { + description: "Powerful text generation model for coding.", + id: "Qwen/Qwen3-Coder-480B-A35B-Instruct", + }, + { + description: "Great text generation model with top-notch tool calling capabilities.", + id: "openai/gpt-oss-120b", + }, + { + description: "Powerful text generation model.", + id: "zai-org/GLM-4.5", + }, + { + description: "A powerful small model with reasoning capabilities.", + id: "Qwen/Qwen3-4B-Thinking-2507", + }, + { + description: "Strong conversational model that supports very long instructions.", + id: "Qwen/Qwen2.5-7B-Instruct-1M", + }, + { + description: "Text generation model used to write code.", + id: "Qwen/Qwen2.5-Coder-32B-Instruct", + }, + { + description: "Powerful reasoning based open large language model.", + id: "deepseek-ai/DeepSeek-R1", + }, + ], + spaces: [ + { + description: "An application that writes and executes code from text instructions and supports many models.", + id: "akhaliq/anycoder", + }, + { + description: "An application that builds websites from natural language prompts.", + id: "enzostvs/deepsite", + }, + { + description: "A leaderboard for comparing chain-of-thought performance of models.", + id: "logikon/open_cot_leaderboard", + }, + { + description: "An text generation based application based on a very powerful LLaMA2 model.", + id: "ysharma/Explore_llamav2_with_TGI", + }, + { + description: "An text generation based application to converse with Zephyr model.", + id: "HuggingFaceH4/zephyr-chat", + }, + { + description: "A leaderboard that ranks text generation models based on blind votes from people.", + id: "lmsys/chatbot-arena-leaderboard", + }, + { + description: "An chatbot to converse with a very powerful text generation model.", + id: "mlabonne/phixtral-chat", + }, + ], + summary: + "Generating text is the task of generating new text given another text. These models can, for example, fill in incomplete text or paraphrase.", + widgetModels: ["mistralai/Mistral-Nemo-Instruct-2407"], + youtubeId: "e9gNEAlsOvU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..f77c1a60505f1a1a961b36d9d9aaea2e39454b7c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts @@ -0,0 +1,187 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Text Generation Input. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationInput { + inputs: string; + parameters?: TextGenerationInputGenerateParameters; + stream?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGenerateParameters { + /** + * Lora adapter id + */ + adapter_id?: string; + /** + * Generate best_of sequences and return the one if the highest token logprobs. + */ + best_of?: number; + /** + * Whether to return decoder input token logprobs and ids. + */ + decoder_input_details?: boolean; + /** + * Whether to return generation details. + */ + details?: boolean; + /** + * Activate logits sampling. + */ + do_sample?: boolean; + /** + * The parameter for frequency penalty. 1.0 means no penalty + * Penalize new tokens based on their existing frequency in the text so far, + * decreasing the model's likelihood to repeat the same line verbatim. + */ + frequency_penalty?: number; + grammar?: TextGenerationInputGrammarType; + /** + * Maximum number of tokens to generate. + */ + max_new_tokens?: number; + /** + * The parameter for repetition penalty. 1.0 means no penalty. + * See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details. + */ + repetition_penalty?: number; + /** + * Whether to prepend the prompt to the generated text + */ + return_full_text?: boolean; + /** + * Random sampling seed. + */ + seed?: number; + /** + * Stop generating tokens if a member of `stop` is generated. + */ + stop?: string[]; + /** + * The value used to module the logits distribution. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-n-filtering. + */ + top_n_tokens?: number; + /** + * Top-p value for nucleus sampling. + */ + top_p?: number; + /** + * Truncate inputs tokens to the given size. + */ + truncate?: number; + /** + * Typical Decoding mass + * See [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) + * for more information. + */ + typical_p?: number; + /** + * Watermarking with [A Watermark for Large Language + * Models](https://arxiv.org/abs/2301.10226). + */ + watermark?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGrammarType { + type: Type; + /** + * A string that represents a [JSON Schema](https://json-schema.org/). + * + * JSON Schema is a declarative language that allows to annotate JSON documents + * with types and descriptions. + */ + value: unknown; + [property: string]: unknown; +} +export type Type = "json" | "regex" | "json_schema"; +/** + * Text Generation Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationOutput { + details?: TextGenerationOutputDetails; + generated_text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputDetails { + best_of_sequences?: TextGenerationOutputBestOfSequence[]; + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export interface TextGenerationOutputBestOfSequence { + finish_reason: TextGenerationOutputFinishReason; + generated_text: string; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export type TextGenerationOutputFinishReason = "length" | "eos_token" | "stop_sequence"; +export interface TextGenerationOutputPrefillToken { + id: number; + logprob: number; + text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} +/** + * Text Generation Stream Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationStreamOutput { + details?: TextGenerationStreamOutputStreamDetails; + generated_text?: string; + index: number; + token: TextGenerationStreamOutputToken; + top_tokens?: TextGenerationStreamOutputToken[]; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputStreamDetails { + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + input_length: number; + seed?: number; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..e734be1d5074605ba8525b1216ac214a259ca7cf --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json @@ -0,0 +1,247 @@ +{ + "$id": "/inference/schemas/text-generation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Input.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationInput", + "type": "object", + "required": ["inputs"], + "properties": { + "inputs": { + "type": "string", + "example": "My name is Olivier and I" + }, + "parameters": { + "$ref": "#/$defs/TextGenerationInputGenerateParameters" + }, + "stream": { + "type": "boolean", + "default": "false" + } + }, + "$defs": { + "TextGenerationInputGenerateParameters": { + "type": "object", + "properties": { + "adapter_id": { + "type": "string", + "description": "Lora adapter id", + "default": "null", + "example": "null", + "nullable": true + }, + "best_of": { + "type": "integer", + "description": "Generate best_of sequences and return the one if the highest token logprobs.", + "default": "null", + "example": 1, + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "decoder_input_details": { + "type": "boolean", + "description": "Whether to return decoder input token logprobs and ids.", + "default": "false" + }, + "details": { + "type": "boolean", + "description": "Whether to return generation details.", + "default": "true" + }, + "do_sample": { + "type": "boolean", + "description": "Activate logits sampling.", + "default": "false", + "example": true + }, + "frequency_penalty": { + "type": "number", + "format": "float", + "description": "The parameter for frequency penalty. 1.0 means no penalty\nPenalize new tokens based on their existing frequency in the text so far,\ndecreasing the model's likelihood to repeat the same line verbatim.", + "default": "null", + "example": 0.1, + "nullable": true, + "exclusiveMinimum": -2 + }, + "grammar": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationInputGrammarType" + } + ], + "default": "null", + "nullable": true + }, + "max_new_tokens": { + "type": "integer", + "format": "int32", + "description": "Maximum number of tokens to generate.", + "default": "1024", + "example": "20", + "nullable": true, + "minimum": 0 + }, + "repetition_penalty": { + "type": "number", + "format": "float", + "description": "The parameter for repetition penalty. 1.0 means no penalty.\nSee [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.", + "default": "null", + "example": 1.03, + "nullable": true, + "exclusiveMinimum": 0 + }, + "return_full_text": { + "type": "boolean", + "description": "Whether to prepend the prompt to the generated text", + "default": "null", + "example": false, + "nullable": true + }, + "seed": { + "type": "integer", + "format": "int64", + "description": "Random sampling seed.", + "default": "null", + "example": "null", + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "stop": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Stop generating tokens if a member of `stop` is generated.", + "example": ["photographer"], + "maxItems": 4 + }, + "temperature": { + "type": "number", + "format": "float", + "description": "The value used to module the logits distribution.", + "default": "null", + "example": 0.5, + "nullable": true, + "exclusiveMinimum": 0 + }, + "top_k": { + "type": "integer", + "format": "int32", + "description": "The number of highest probability vocabulary tokens to keep for top-k-filtering.", + "default": "null", + "example": 10, + "nullable": true, + "exclusiveMinimum": 0 + }, + "top_n_tokens": { + "type": "integer", + "format": "int32", + "description": "The number of highest probability vocabulary tokens to keep for top-n-filtering.", + "default": "null", + "example": 5, + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "top_p": { + "type": "number", + "format": "float", + "description": "Top-p value for nucleus sampling.", + "default": "null", + "example": 0.95, + "nullable": true, + "maximum": 1, + "exclusiveMinimum": 0 + }, + "truncate": { + "type": "integer", + "description": "Truncate inputs tokens to the given size.", + "default": "null", + "example": "null", + "nullable": true, + "minimum": 0 + }, + "typical_p": { + "type": "number", + "format": "float", + "description": "Typical Decoding mass\nSee [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) for more information.", + "default": "null", + "example": 0.95, + "nullable": true, + "maximum": 1, + "exclusiveMinimum": 0 + }, + "watermark": { + "type": "boolean", + "description": "Watermarking with [A Watermark for Large Language Models](https://arxiv.org/abs/2301.10226).", + "default": "false", + "example": true + } + }, + "title": "TextGenerationInputGenerateParameters" + }, + "TextGenerationInputGrammarType": { + "oneOf": [ + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json"] + }, + "value": { + "description": "A string that represents a [JSON Schema](https://json-schema.org/).\n\nJSON Schema is a declarative language that allows to annotate JSON documents\nwith types and descriptions." + } + } + }, + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["regex"] + }, + "value": { + "type": "string" + } + } + }, + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json_schema"] + }, + "value": { + "$ref": "#/$defs/TextGenerationInputJsonSchemaConfig" + } + } + } + ], + "discriminator": { + "propertyName": "type" + }, + "title": "TextGenerationInputGrammarType" + }, + "TextGenerationInputJsonSchemaConfig": { + "type": "object", + "required": ["schema"], + "properties": { + "name": { + "type": "string", + "description": "Optional name identifier for the schema", + "nullable": true + }, + "schema": { + "description": "The actual JSON schema definition" + } + }, + "title": "TextGenerationInputJsonSchemaConfig" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..cb6ef3f99694ae4ed5eb6a05b8f3ea18e1da8a60 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json @@ -0,0 +1,179 @@ +{ + "$id": "/inference/schemas/text-generation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationOutput", + "type": "object", + "required": ["generated_text"], + "properties": { + "details": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationOutputDetails" + } + ], + "nullable": true + }, + "generated_text": { + "type": "string", + "example": "test" + } + }, + "$defs": { + "TextGenerationOutputDetails": { + "type": "object", + "required": ["finish_reason", "generated_tokens", "prefill", "tokens"], + "properties": { + "best_of_sequences": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputBestOfSequence" + }, + "nullable": true + }, + "finish_reason": { + "$ref": "#/$defs/TextGenerationOutputFinishReason" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "prefill": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputPrefillToken" + } + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + }, + "tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + }, + "top_tokens": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + } + } + }, + "title": "TextGenerationOutputDetails" + }, + "TextGenerationOutputBestOfSequence": { + "type": "object", + "required": ["generated_text", "finish_reason", "generated_tokens", "prefill", "tokens"], + "properties": { + "finish_reason": { + "$ref": "#/$defs/TextGenerationOutputFinishReason" + }, + "generated_text": { + "type": "string", + "example": "test" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "prefill": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputPrefillToken" + } + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + }, + "tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + }, + "top_tokens": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + } + } + }, + "title": "TextGenerationOutputBestOfSequence" + }, + "TextGenerationOutputFinishReason": { + "type": "string", + "enum": ["length", "eos_token", "stop_sequence"], + "example": "Length", + "title": "TextGenerationOutputFinishReason" + }, + "TextGenerationOutputPrefillToken": { + "type": "object", + "required": ["id", "text", "logprob"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationOutputPrefillToken" + }, + "TextGenerationOutputToken": { + "type": "object", + "required": ["id", "text", "logprob", "special"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "special": { + "type": "boolean", + "example": "false" + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationOutputToken" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json new file mode 100644 index 0000000000000000000000000000000000000000..fc566c6fe003eb445269af3668a941b403eb3549 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json @@ -0,0 +1,103 @@ +{ + "$id": "/inference/schemas/text-generation/stream_output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Stream Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationStreamOutput", + "type": "object", + "required": ["index", "token"], + "properties": { + "details": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationStreamOutputStreamDetails" + } + ], + "default": "null", + "nullable": true + }, + "generated_text": { + "type": "string", + "default": "null", + "example": "test", + "nullable": true + }, + "index": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "token": { + "$ref": "#/$defs/TextGenerationStreamOutputToken" + }, + "top_tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationStreamOutputToken" + } + } + }, + "$defs": { + "TextGenerationStreamOutputStreamDetails": { + "type": "object", + "required": ["finish_reason", "generated_tokens", "input_length"], + "properties": { + "finish_reason": { + "$ref": "#/$defs/TextGenerationStreamOutputFinishReason" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "input_length": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + } + }, + "title": "TextGenerationStreamOutputStreamDetails" + }, + "TextGenerationStreamOutputFinishReason": { + "type": "string", + "enum": ["length", "eos_token", "stop_sequence"], + "example": "Length", + "title": "TextGenerationStreamOutputFinishReason" + }, + "TextGenerationStreamOutputToken": { + "type": "object", + "required": ["id", "text", "logprob", "special"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "special": { + "type": "boolean", + "example": "false" + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationStreamOutputToken" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md b/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md new file mode 100644 index 0000000000000000000000000000000000000000..cd5986c5de759601815701bdb2cfb507d62e40ae --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md @@ -0,0 +1,74 @@ +## Use Cases 🔍 + +### Information Retrieval + +You can improve Information Retrieval search stacks by applying a Text Ranking model as a Reranker in the common "[Retrieve and Rerank pipeline](https://sbert.net/examples/applications/retrieve_rerank/README.html)". First, you can use a [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) or [Feature Extraction](https://huggingface.co/tasks/feature-extraction) model as a Retriever to find the (for example) 100 most relevant documents for a query. Afterwards, you can rerank each of these 100 documents with a Text Ranking model to select an updated top 10. Often times, this results in improved retrieval performance than only using a Retriever model. + +## The Sentence Transformers library + +The [Sentence Transformers](https://www.sbert.net/) library is very powerful for using and training both Sentence Transformer (a.k.a. embedding or retriever) models as well as Cross Encoder (a.k.a. reranker) models. + +You can find and use [Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using Inference Endpoints. + +## Task Variants + +### Passage Ranking + +Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Normalized Discounted Cumulative Gain, Mean Reciprocal Rank, or Mean Average Precision. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄 + +You can use it via the [Sentence Transformers library](https://sbert.net/docs/cross_encoder/usage/usage.html) like so: + +```python +from sentence_transformers import CrossEncoder + +# 1. Load a pre-trained CrossEncoder model +model = CrossEncoder("cross-encoder/ms-marco-MiniLM-L6-v2") + +query = "How many people live in Berlin?" +passages = [ + "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.", + "Berlin is well known for its museums.", + "In 2014, the city state Berlin had 37,368 live births (+6.6%), a record number since 1991.", + "The urban area of Berlin comprised about 4.1 million people in 2014, making it the seventh most populous urban area in the European Union.", + "The city of Paris had a population of 2,165,423 people within its administrative city limits as of January 1, 2019", + "An estimated 300,000-420,000 Muslims reside in Berlin, making up about 8-11 percent of the population.", + "Berlin is subdivided into 12 boroughs or districts (Bezirke).", + "In 2015, the total labour force in Berlin was 1.85 million.", + "In 2013 around 600,000 Berliners were registered in one of the more than 2,300 sport and fitness clubs.", + "Berlin has a yearly total of about 135 million day visitors, which puts it in third place among the most-visited city destinations in the European Union.", +] + +# 2a. Either: predict scores for all pairs of sentences involved in the query +scores = model.predict([(query, passage) for passage in passages]) +# => [ 8.607138 -4.320077 7.5978117 8.915804 -4.237982 8.2359 0.33119553 3.4510403 6.352979 5.416662 ] + +# 2b. Or rank a list of passages for a query +ranks = model.rank(query, passages, return_documents=True) + +# Print the reranked passages +print("Query:", query) +for rank in ranks: + print(f"- #{rank['corpus_id']} ({rank['score']:.2f}): {rank['text']}") +""" +Query: How many people live in Berlin? +- #3 (8.92): The urban area of Berlin comprised about 4.1 million people in 2014, making it the seventh most populous urban area in the European Union. +- #0 (8.61): Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers. +- #5 (8.24): An estimated 300,000-420,000 Muslims reside in Berlin, making up about 8-11 percent of the population. +- #2 (7.60): In 2014, the city state Berlin had 37,368 live births (+6.6%), a record number since 1991. +- #8 (6.35): In 2013 around 600,000 Berliners were registered in one of the more than 2,300 sport and fitness clubs. +- #9 (5.42): Berlin has a yearly total of about 135 million day visitors, which puts it in third place among the most-visited city destinations in the European Union. +- #7 (3.45): In 2015, the total labour force in Berlin was 1.85 million. +- #6 (0.33): Berlin is subdivided into 12 boroughs or districts (Bezirke). +- #4 (-4.24): The city of Paris had a population of 2,165,423 people within its administrative city limits as of January 1, 2019 +- #1 (-4.32): Berlin is well known for its museums. +""" +``` + +Rerankers often outperform [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) or [Feature Extraction](https://huggingface.co/tasks/feature-extraction) models, but they're too slow to rank a query against all documents. This is why they're commonly used to perform a final reranking of the top documents from a retriever: you can get the efficiency of a retriever model with the performance of a reranker. + +## Useful Resources + +Would you like to learn more about Text Ranking? Here is a curated resource that you may find helpful! + +- [Sentence Transformers > Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html) +- [Sentence Transformers > Usage > Retrieve & Re-Rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..265adc88fe6e78763410f79289440d872e036dfd --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts @@ -0,0 +1,91 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 2.2006407, + }, + { + label: "This is so difficult, like rocket science.", + score: -6.2634873, + }, + { + label: "I can't believe how much I struggled with this.", + score: -10.251488, + }, + ], + }, + ], + }, + metrics: [ + { + description: + "Discounted Cumulative Gain (DCG) measures the gain, or usefulness, of search results discounted by their position. The normalization is done by dividing the DCG by the ideal DCG, which is the DCG of the perfect ranking.", + id: "Normalized Discounted Cumulative Gain", + }, + { + description: + "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: + "Mean Average Precision (mAP) is the overall average of the Average Precision (AP) values, where AP is the Area Under the PR Curve (AUC-PR)", + id: "Mean Average Precision", + }, + ], + models: [ + { + description: "An extremely efficient text ranking model trained on a web search dataset.", + id: "cross-encoder/ms-marco-MiniLM-L6-v2", + }, + { + description: "A strong multilingual text reranker model.", + id: "Alibaba-NLP/gte-multilingual-reranker-base", + }, + { + description: "An efficient text ranking model that punches above its weight.", + id: "Alibaba-NLP/gte-reranker-modernbert-base", + }, + ], + spaces: [], + summary: + "Text Ranking is the task of ranking a set of texts based on their relevance to a query. Text ranking models are trained on large datasets of queries and relevant documents to learn how to rank documents based on their relevance to the query. This task is particularly useful for search engines and information retrieval systems.", + widgetModels: ["cross-encoder/ms-marco-MiniLM-L6-v2"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9f76ba3e4ddee504215bf676dc9bc28926c98fef --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md @@ -0,0 +1,62 @@ +## Use Cases + +Text-to-3D models can be used in a wide variety of applications that require 3D, such as games, animation, design, architecture, engineering, marketing, and more. + +![Text-to-3D Thumbnail](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/text-to-3d/text-to-3d-thumbnail.png) + +This task is similar to the [image-to-3d](https://huggingface.co/tasks/image-to-3d) task, but takes text input instead of image input. In practice, this is often equivalent to a combination of [text-to-image](https://huggingface.co/tasks/text-to-image) and [image-to-3d](https://huggingface.co/tasks/image-to-3d). That is, the text is first converted to an image, then the image is converted to 3D. + +### Generating Meshes + +Meshes are the standard representation of 3D in industry. + +### Generating Gaussian Splats + +[Gaussian Splatting](https://huggingface.co/blog/gaussian-splatting) is a rendering technique that represents scenes as fuzzy points. + +### Inference + +Inference for this task typically leverages the [Diffusers](https://huggingface.co/docs/diffusers/index) library for inference, using [Custom Pipelines](https://huggingface.co/docs/diffusers/v0.6.0/en/using-diffusers/custom_pipelines). + +These are unstandardized and depend on the model. More details can be found in each model repository. + +```python +import torch +import requests +import numpy as np +from io import BytesIO +from diffusers import DiffusionPipeline +from PIL import Image + +pipeline = DiffusionPipeline.from_pretrained( + "dylanebert/LGM-full", + custom_pipeline="dylanebert/LGM-full", + torch_dtype=torch.float16, + trust_remote_code=True, +).to("cuda") + +input_prompt = "a cat statue" +result = pipeline(input_prompt, None) +result_path = "/tmp/output.ply" +pipeline.save_ply(result, result_path) +``` + +In the code above, we: + +1. Import the necessary libraries +2. Load the `LGM-full` model and custom pipeline +3. Define the input prompt +4. Run the pipeline on the input prompt +5. Save the output to a file + +### Output Formats + +Meshes can be in `.obj`, `.glb`, `.stl`, or `.gltf` format. Other formats are allowed, but won't be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component. + +Splats can be in `.ply` or `.splat` format. They can be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component using the [gsplat.js](https://github.com/huggingface/gsplat.js) library. + +## Useful Resources + +- [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course) +- [3D Arena Leaderboard](https://huggingface.co/spaces/dylanebert/3d-arena) +- [gsplat.js](https://github.com/huggingface/gsplat.js) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..30f3aefc49bc00b9ec37b6ee18bc520d82b88b20 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts @@ -0,0 +1,56 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "Descriptive captions for 3D objects in Objaverse.", + id: "tiange/Cap3D", + }, + ], + demo: { + inputs: [ + { + label: "Prompt", + content: "a cat statue", + type: "text", + }, + ], + outputs: [ + { + label: "Result", + content: "text-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Text-to-3D mesh model by OpenAI", + id: "openai/shap-e", + }, + { + description: "Generative 3D gaussian splatting model.", + id: "ashawkey/LGM", + }, + ], + spaces: [ + { + description: "Text-to-3D demo with mesh outputs.", + id: "hysts/Shap-E", + }, + { + description: "Text/image-to-3D demo with splat outputs.", + id: "ashawkey/LGM", + }, + ], + summary: "Text-to-3D models take in text input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a4101944814a62d082edbd1e1aaa14cac389e09 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts @@ -0,0 +1,133 @@ +/** + * Outputs of inference for the Text To Audio task + */ +export interface TextToAudioOutput { + /** + * The generated audio waveform. + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Audio inference + */ +export interface TextToAudioInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Audio + */ + parameters?: TextToAudioParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Audio + */ +export interface TextToAudioParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a836c53d56e71e2117ed9e6909744461e23cfe17 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json @@ -0,0 +1,30 @@ +{ + "$id": "/inference/schemas/text-to-audio/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Audio inference", + "title": "TextToAudioInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Audio", + "$ref": "#/$defs/TextToAudioParameters" + } + }, + "$defs": { + "TextToAudioParameters": { + "title": "TextToAudioParameters", + "type": "object", + "properties": { + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8d39db79c1b8bdf1ee4ab42c2a977fd9bde03eb7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json @@ -0,0 +1,18 @@ +{ + "$id": "/inference/schemas/text-to-audio/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Audio task", + "title": "TextToAudioOutput", + "type": "object", + "properties": { + "audio": { + "description": "The generated audio waveform.", + "comment": "type=binary" + }, + "sampling_rate": { + "type": "number", + "description": "The sampling rate of the generated audio waveform." + } + }, + "required": ["audio", "sampling_rate"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9cb11798ece00cde3707664cfcc27d8a9c04c530 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md @@ -0,0 +1,96 @@ +## Use Cases + +### Data Generation + +Businesses can generate data for their use cases by inputting text and getting image outputs. + +### Immersive Conversational Chatbots + +Chatbots can be made more immersive if they provide contextual images based on the input provided by the user. + +### Creative Ideas for Fashion Industry + +Different patterns can be generated to obtain unique pieces of fashion. Text-to-image models make creations easier for designers to conceptualize their design before actually implementing it. + +### Architecture Industry + +Architects can utilise the models to construct an environment based out on the requirements of the floor plan. This can also include the furniture that has to be placed in that environment. + +## Task Variants + +### Image Editing + +Image editing with text-to-image models involves modifying an image following edit instructions provided in a text prompt. + +- **Synthetic image editing**: Adjusting images that were initially created using an input prompt while preserving the overall meaning or context of the original image. + + ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/edit_p2p.png) + _Figure taken from ["InstructPix2Pix: Learning to Follow Image Editing Instructions"](https://www.timothybrooks.com/instruct-pix2pix)_ + +- **Real image editing**: Similar to synthetic image editing, except we're using real photos/images. This task is usually more complex. + + ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/pix2pix.jpeg) + _Figure taken from ["Prompt-to-Prompt Image Editing with Cross-Attention Control"](https://prompt-to-prompt.github.io)_ + +### Personalization + +Personalization refers to techniques used to customize text-to-image models. We introduce new subjects or concepts to the model, which the model can then generate when we refer to them with a text prompt. + +For example, you can use these techniques to generate images of your dog in imaginary settings, after you have taught the model using a few reference images of the subject (or just one in some cases). Teaching the model a new concept can be achieved through fine-tuning, or by using training-free techniques. + +## Inference + +You can use diffusers pipelines to infer with `text-to-image` models. + +```python +from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler + +model_id = "stabilityai/stable-diffusion-2" +scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler") +pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16) +pipe = pipe.to("cuda") + +prompt = "a photo of an astronaut riding a horse on mars" +image = pipe(prompt).images[0] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text-to-image models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.textToImage({ + model: "stabilityai/stable-diffusion-2", + inputs: "award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]", + parameters: { + negative_prompt: "blurry", + }, +}); +``` + +## Useful Resources + +### Model Inference + +- [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class) +- [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index) +- [Text-to-Image Generation](https://huggingface.co/docs/diffusers/using-diffusers/conditional_image_generation) +- [Using Stable Diffusion with Core ML on Apple Silicon](https://huggingface.co/blog/diffusers-coreml) +- [A guide on Vector Quantized Diffusion](https://huggingface.co/blog/vq-diffusion) +- [🧨 Stable Diffusion in JAX/Flax](https://huggingface.co/blog/stable_diffusion_jax) +- [Running IF with 🧨 diffusers on a Free Tier Google Colab](https://huggingface.co/blog/if) +- [Introducing Würstchen: Fast Diffusion for Image Generation](https://huggingface.co/blog/wuerstchen) +- [Efficient Controllable Generation for SDXL with T2I-Adapters](https://huggingface.co/blog/t2i-sdxl-adapters) +- [Welcome aMUSEd: Efficient Text-to-Image Generation](https://huggingface.co/blog/amused) +- Image Editing Demos: [LEDITS++](https://huggingface.co/spaces/editing-images/leditsplusplus), [Turbo Edit](https://huggingface.co/spaces/turboedit/turbo_edit), [InstructPix2Pix](https://huggingface.co/spaces/timbrooks/instruct-pix2pix), [CosXL](https://huggingface.co/spaces/multimodalart/cosxl) +- Training free Personalization Demos: [Face-to-All](https://huggingface.co/spaces/multimodalart/face-to-all), [InstantStyle](https://huggingface.co/spaces/InstantX/InstantStyle), [RB-modulation](https://huggingface.co/spaces/fffiloni/RB-Modulation), [Photomaker v2](https://huggingface.co/spaces/TencentARC/PhotoMaker-V2) + +### Model Fine-tuning + +- [Finetune Stable Diffusion Models with DDPO via TRL](https://huggingface.co/blog/pref-tuning) +- [LoRA training scripts of the world, unite!](https://huggingface.co/blog/sdxl_lora_advanced_script) +- [Using LoRA for Efficient Stable Diffusion Fine-Tuning](https://huggingface.co/blog/lora) +- LoRA fine tuning Spaces: [FLUX.1 finetuning](https://huggingface.co/spaces/autotrain-projects/train-flux-lora-ease), [SDXL finetuning](https://huggingface.co/spaces/multimodalart/lora-ease) + +This page was made possible thanks to the efforts of [Ishan Dutta](https://huggingface.co/ishandutta), [Enrique Elias Ubaldo](https://huggingface.co/herrius) and [Oğuz Akif](https://huggingface.co/oguzakif). diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a1fcc80992c86ff61a9f7736ec0155554ab8ebf --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts @@ -0,0 +1,104 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "RedCaps is a large-scale dataset of 12M image-text pairs collected from Reddit.", + id: "red_caps", + }, + { + description: "Conceptual Captions is a dataset consisting of ~3.3M images annotated with captions.", + id: "conceptual_captions", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Inception Score (IS) measure assesses diversity and meaningfulness. It uses a generated image sample to predict its label. A higher score signifies more diverse and meaningful images.", + id: "IS", + }, + { + description: + "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: + "R-precision assesses how the generated image aligns with the provided text description. It uses the generated images as queries to retrieve relevant text descriptions. The top 'r' relevant descriptions are selected and used to calculate R-precision as r/R, where 'R' is the number of ground truth descriptions associated with the generated images. A higher R-precision value indicates a better model.", + id: "R-Precision", + }, + ], + models: [ + { + description: "One of the most powerful image generation models that can generate realistic outputs.", + id: "black-forest-labs/FLUX.1-Krea-dev", + }, + { + description: "A powerful image generation model.", + id: "Qwen/Qwen-Image", + }, + { + description: "Powerful and fast image generation model.", + id: "ByteDance/SDXL-Lightning", + }, + { + description: "A powerful text-to-image model.", + id: "ByteDance/Hyper-SD", + }, + ], + spaces: [ + { + description: "A powerful text-to-image application.", + id: "stabilityai/stable-diffusion-3-medium", + }, + { + description: "A text-to-image application to generate comics.", + id: "jbilcke-hf/ai-comic-factory", + }, + { + description: "An application to match multiple custom image generation models.", + id: "multimodalart/flux-lora-lab", + }, + { + description: "A powerful yet very fast image generation application.", + id: "latent-consistency/lcm-lora-for-sdxl", + }, + { + description: "A gallery to explore various text-to-image models.", + id: "multimodalart/LoraTheExplorer", + }, + { + description: "An application for `text-to-image`, `image-to-image` and image inpainting.", + id: "ArtGAN/Stable-Diffusion-ControlNet-WebUI", + }, + { + description: "An application to generate realistic images given photos of a person and a prompt.", + id: "InstantX/InstantID", + }, + ], + summary: + "Text-to-image is the task of generating images from input text. These pipelines can also be used to modify and edit images based on text prompts.", + widgetModels: ["black-forest-labs/FLUX.1-dev"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bdc8a34036010c2d1764570cd2b81e9999205c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts @@ -0,0 +1,65 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Image inference + */ +export interface TextToImageInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Image + */ + parameters?: TextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Image + */ +export interface TextToImageParameters { + /** + * A higher guidance scale value encourages the model to generate images closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * The height in pixels of the output image + */ + height?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Override the scheduler with a compatible one. + */ + scheduler?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The width in pixels of the output image + */ + width?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Image task + */ +export interface TextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..f94e0bbc3ea7fa723bfaab85be1c4d65385e2c7b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json @@ -0,0 +1,54 @@ +{ + "$id": "/inference/schemas/text-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Image inference", + "title": "TextToImageInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data (sometimes called \"prompt\")", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Image", + "$ref": "#/$defs/TextToImageParameters" + } + }, + "$defs": { + "TextToImageParameters": { + "title": "TextToImageParameters", + "type": "object", + "properties": { + "guidance_scale": { + "type": "number", + "description": "A higher guidance scale value encourages the model to generate images closely linked to the text prompt, but values too high may cause saturation and other artifacts." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "width": { + "type": "integer", + "description": "The width in pixels of the output image" + }, + "height": { + "type": "integer", + "description": "The height in pixels of the output image" + }, + "scheduler": { + "type": "string", + "description": "Override the scheduler with a compatible one." + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f90a1eee18655cc5febb99cba38a3d784994261d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/text-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Image task", + "title": "TextToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The generated image returned as raw bytes in the payload." + } + }, + "required": ["image"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md new file mode 100644 index 0000000000000000000000000000000000000000..c241d63df680c9c8e8cf9ae12763f611a58e3789 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md @@ -0,0 +1,63 @@ +## Use Cases + +Text-to-Speech (TTS) models can be used in any speech-enabled application that requires converting text to speech imitating human voice. + +### Voice Assistants + +TTS models are used to create voice assistants on smart devices. These models are a better alternative compared to concatenative methods where the assistant is built by recording sounds and mapping them, since the outputs in TTS models contain elements in natural speech such as emphasis. + +### Announcement Systems + +TTS models are widely used in airport and public transportation announcement systems to convert the announcement of a given text into speech. + +## Inference Endpoints + +The Hub contains over [1500 TTS models](https://huggingface.co/models?pipeline_tag=text-to-speech&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using Inference Endpoints. Here is a simple code snippet to get you started: + +```python +import json +import requests + +headers = {"Authorization": f"Bearer {API_TOKEN}"} +API_URL = "https://router.huggingface.co/hf-inference/models/microsoft/speecht5_tts" + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response + +output = query({"text_inputs": "Max is the best doggo."}) +``` + +You can also use libraries such as [espnet](https://huggingface.co/models?library=espnet&pipeline_tag=text-to-speech&sort=downloads) or [transformers](https://huggingface.co/models?pipeline_tag=text-to-speech&library=transformers&sort=trending) if you want to handle the Inference directly. + +## Direct Inference + +Now, you can also use the Text-to-Speech pipeline in Transformers to synthesise high quality voice. + +```python +from transformers import pipeline + +synthesizer = pipeline("text-to-speech", "suno/bark") + +synthesizer("Look I am generating speech in three lines of code!") +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer summarization models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.textToSpeech({ + model: "facebook/mms-tts", + inputs: "text to generate speech from", +}); +``` + +## Useful Resources + +- [Hugging Face Audio Course](https://huggingface.co/learn/audio-course/chapter6/introduction) +- [ML for Audio Study Group - Text to Speech Deep Dive](https://www.youtube.com/watch?v=aLBedWj-5CQ) +- [Speech Synthesis, Recognition, and More With SpeechT5](https://huggingface.co/blog/speecht5) +- [Optimizing a Text-To-Speech model using 🤗 Transformers](https://huggingface.co/blog/optimizing-bark) +- [Train your own TTS models with Parler-TTS](https://github.com/huggingface/parler-tts) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d85cd1e24adf3484c43273850a9ca2431b755032 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts @@ -0,0 +1,86 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-to-audio", + datasets: [ + { + description: "10K hours of multi-speaker English dataset.", + id: "parler-tts/mls_eng_10k", + }, + { + description: "Multi-speaker English dataset.", + id: "mythicinfinity/libritts_r", + }, + { + description: "Multi-lingual dataset.", + id: "facebook/multilingual_librispeech", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love audio models on the Hub!", + type: "text", + }, + ], + outputs: [ + { + filename: "audio.wav", + type: "audio", + }, + ], + }, + metrics: [ + { + description: "The Mel Cepstral Distortion (MCD) metric is used to calculate the quality of generated speech.", + id: "mel cepstral distortion", + }, + ], + models: [ + { + description: "Small yet powerful TTS model.", + id: "KittenML/kitten-tts-nano-0.1", + }, + { + description: "Bleeding edge TTS model.", + id: "ResembleAI/chatterbox", + }, + { + description: "A massively multi-lingual TTS model.", + id: "fishaudio/fish-speech-1.5", + }, + { + description: "A text-to-dialogue model.", + id: "nari-labs/Dia-1.6B-0626", + }, + ], + spaces: [ + { + description: "An application for generate high quality speech in different languages.", + id: "hexgrad/Kokoro-TTS", + }, + { + description: "A multilingual text-to-speech application.", + id: "fishaudio/fish-speech-1", + }, + { + description: "Performant TTS application.", + id: "ResembleAI/Chatterbox", + }, + { + description: "An application to compare different TTS models.", + id: "TTS-AGI/TTS-Arena-V2", + }, + { + description: "An application that generates podcast episodes.", + id: "ngxson/kokoro-podcast-generator", + }, + ], + summary: + "Text-to-Speech (TTS) is the task of generating natural sounding speech given text input. TTS models can be extended to have a single model that generates speech for multiple speakers and multiple languages.", + widgetModels: ["suno/bark"], + youtubeId: "NW62DpzJ274", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..4515de301a8b4dc044b0d7a7f45f3729e4f4662f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts @@ -0,0 +1,133 @@ +/** + * Outputs of inference for the Text To Speech task + */ +export interface TextToSpeechOutput { + /** + * The generated audio + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate?: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Speech inference + */ +export interface TextToSpeechInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Speech + */ + parameters?: TextToSpeechParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Speech + */ +export interface TextToSpeechParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a643f2d7c7e659ff79e02f3c77334031b38a36d1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json @@ -0,0 +1,30 @@ +{ + "$id": "/inference/schemas/text-to-speech/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Speech inference", + "title": "TextToSpeechInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Speech", + "$ref": "#/$defs/TextToSpeechParameters" + } + }, + "$defs": { + "TextToSpeechParameters": { + "title": "TextToSpeechParameters", + "type": "object", + "properties": { + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..4836ed246fa23f7f83b64f6522695f1adb399c83 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json @@ -0,0 +1,18 @@ +{ + "$id": "/inference/schemas/text-to-speech/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Speech task", + "title": "TextToSpeechOutput", + "type": "object", + "properties": { + "audio": { + "description": "The generated audio", + "comment": "type=binary" + }, + "sampling_rate": { + "type": "number", + "description": "The sampling rate of the generated audio waveform." + } + }, + "required": ["audio"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..898d638c264aa8219cdc3a71d1a4562de0d084b8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md @@ -0,0 +1,41 @@ +## Use Cases + +### Script-based Video Generation + +Text-to-video models can be used to create short-form video content from a provided text script. These models can be used to create engaging and informative marketing videos. For example, a company could use a text-to-video model to create a video that explains how their product works. + +### Content format conversion + +Text-to-video models can be used to generate videos from long-form text, including blog posts, articles, and text files. Text-to-video models can be used to create educational videos that are more engaging and interactive. An example of this is creating a video that explains a complex concept from an article. + +### Voice-overs and Speech + +Text-to-video models can be used to create an AI newscaster to deliver daily news, or for a film-maker to create a short film or a music video. + +## Task Variants +Text-to-video models have different variants based on inputs and outputs. + +### Text-to-video Editing + +One text-to-video task is generating text-based video style and local attribute editing. Text-to-video editing models can make it easier to perform tasks like cropping, stabilization, color correction, resizing and audio editing consistently. + +### Text-to-video Search + +Text-to-video search is the task of retrieving videos that are relevant to a given text query. This can be challenging, as videos are a complex medium that can contain a lot of information. By using semantic analysis to extract the meaning of the text query, visual analysis to extract features from the videos, such as the objects and actions that are present in the video, and temporal analysis to categorize relationships between the objects and actions in the video, we can determine which videos are most likely to be relevant to the text query. + +### Text-driven Video Prediction + +Text-driven video prediction is the task of generating a video sequence from a text description. Text description can be anything from a simple sentence to a detailed story. The goal of this task is to generate a video that is both visually realistic and semantically consistent with the text description. + +### Video Translation + +Text-to-video translation models can translate videos from one language to another or allow to query the multilingual text-video model with non-English sentences. This can be useful for people who want to watch videos in a language that they don't understand, especially when multi-lingual captions are available for training. + +## Inference +Contribute an inference snippet for text-to-video here! + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. + +- [Text-to-Video: The Task, Challenges and the Current State](https://huggingface.co/blog/text-to-video) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..334146ba81e64ff378de65a09da14fddd0ae5fd4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts @@ -0,0 +1,106 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Microsoft Research Video to Text is a large-scale dataset for open domain video captioning", + id: "iejMac/CLIP-MSR-VTT", + }, + { + description: "UCF101 Human Actions dataset consists of 13,320 video clips from YouTube, with 101 classes.", + id: "quchenyuan/UCF101-ZIP", + }, + { + description: "A high-quality dataset for human action recognition in YouTube videos.", + id: "nateraw/kinetics", + }, + { + description: "A dataset of video clips of humans performing pre-defined basic actions with everyday objects.", + id: "HuggingFaceM4/something_something_v2", + }, + { + description: + "This dataset consists of text-video pairs and contains noisy samples with irrelevant video descriptions", + id: "HuggingFaceM4/webvid", + }, + { + description: "A dataset of short Flickr videos for the temporal localization of events with descriptions.", + id: "iejMac/CLIP-DiDeMo", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Inception Score uses an image classification model that predicts class labels and evaluates how distinct and diverse the images are. A higher score indicates better video generation.", + id: "is", + }, + { + description: + "Frechet Inception Distance uses an image classification model to obtain image embeddings. The metric compares mean and standard deviation of the embeddings of real and generated images. A smaller score indicates better video generation.", + id: "fid", + }, + { + description: + "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: + "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A strong model for consistent video generation.", + id: "tencent/HunyuanVideo", + }, + { + description: "A text-to-video model with high fidelity motion and strong prompt adherence.", + id: "Lightricks/LTX-Video", + }, + { + description: "A text-to-video model focusing on physics-aware applications like robotics.", + id: "nvidia/Cosmos-1.0-Diffusion-7B-Text2World", + }, + { + description: "Very fast model for video generation.", + id: "Lightricks/LTX-Video-0.9.8-13B-distilled", + }, + ], + spaces: [ + { + description: "An application that generates video from text.", + id: "VideoCrafter/VideoCrafter", + }, + { + description: "Consistent video generation application.", + id: "Wan-AI/Wan2.1", + }, + { + description: "A cutting edge video generation application.", + id: "Pyramid-Flow/pyramid-flow", + }, + ], + summary: + "Text-to-video models can be used in any application that requires generating consistent sequence of images from text. ", + widgetModels: ["Wan-AI/Wan2.2-TI2V-5B"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..0859ba524fb18b54bad8fc660190552f6a02cee0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts @@ -0,0 +1,57 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Video inference + */ +export interface TextToVideoInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Video + */ + parameters?: TextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Video + */ +export interface TextToVideoParameters { + /** + * A higher guidance scale value encourages the model to generate videos closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * One or several prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string[]; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Seed for the random number generator. + */ + seed?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Video task + */ +export interface TextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..077c988b60715c97657f9db2674e85fac4ba0272 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json @@ -0,0 +1,49 @@ +{ + "$id": "/inference/schemas/text-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Video inference", + "title": "TextToVideoInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data (sometimes called \"prompt\")", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Video", + "$ref": "#/$defs/TextToVideoParameters" + } + }, + "$defs": { + "TextToVideoParameters": { + "title": "TextToVideoParameters", + "type": "object", + "properties": { + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "guidance_scale": { + "type": "number", + "description": "A higher guidance scale value encourages the model to generate videos closely linked to the text prompt, but values too high may cause saturation and other artifacts." + }, + "negative_prompt": { + "type": "array", + "items": { + "type": "string" + }, + "description": "One or several prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..1a2c006dbc60d8f9d1e0db0afd3ef01e78d9221a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/text-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Video task", + "title": "TextToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9b0701385b5793f32bdafd890c476a4efb99b509 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md @@ -0,0 +1,76 @@ +## Use Cases + +### Information Extraction from Invoices + +You can extract entities of interest from invoices automatically using Named Entity Recognition (NER) models. Invoices can be read with Optical Character Recognition models and the output can be used to do inference with NER models. In this way, important information such as date, company name, and other named entities can be extracted. + +## Task Variants + +### Named Entity Recognition (NER) + +NER is the task of recognizing named entities in a text. These entities can be the names of people, locations, or organizations. The task is formulated as labeling each token with a class for each named entity and a class named "0" for tokens that do not contain any entities. The input for this task is text and the output is the annotated text with named entities. + +#### Inference + +You can use the 🤗 Transformers library `ner` pipeline to infer with NER models. + +```python +from transformers import pipeline + +classifier = pipeline("ner") +classifier("Hello I'm Omar and I live in Zürich.") +``` + +### Part-of-Speech (PoS) Tagging +In PoS tagging, the model recognizes parts of speech, such as nouns, pronouns, adjectives, or verbs, in a given text. The task is formulated as labeling each word with a part of the speech. + +#### Inference + +You can use the 🤗 Transformers library `token-classification` pipeline with a POS tagging model of your choice. The model will return a json with PoS tags for each token. + +```python +from transformers import pipeline + +classifier = pipeline("token-classification", model = "vblagoje/bert-english-uncased-finetuned-pos") +classifier("Hello I'm Omar and I live in Zürich.") +``` + +This is not limited to transformers! You can also use other libraries such as Stanza, spaCy, and Flair to do inference! Here is an example using a canonical [spaCy](https://hf.co/blog/spacy) model. + +```python +!pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl + +import en_core_web_sm + +nlp = en_core_web_sm.load() +doc = nlp("I'm Omar and I live in Zürich.") +for token in doc: + print(token.text, token.pos_, token.dep_, token.ent_type_) + +## I PRON nsubj +## 'm AUX ROOT +## Omar PROPN attr PERSON +### ... +``` + +## Useful Resources + +Would you like to learn more about token classification? Great! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Token Classification](https://huggingface.co/course/chapter7/2?fw=pt) +- [Blog post: Welcome spaCy to the Hugging Face Hub](https://huggingface.co/blog/spacy) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/token_classification.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/token_classification-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/token-classification) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/token-classification) + +### Documentation + +- [Token classification task guide](https://huggingface.co/docs/transformers/tasks/token_classification) diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ecce1bcc9e5537f092066ad9488fbd525fe1286 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts @@ -0,0 +1,92 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset useful to benchmark named entity recognition models.", + id: "eriktks/conll2003", + }, + { + description: + "A multilingual dataset of Wikipedia articles annotated for named entity recognition in over 150 different languages.", + id: "unimelb-nlp/wikiann", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + text: "My name is Omar and I live in Zürich.", + tokens: [ + { + type: "PERSON", + start: 11, + end: 15, + }, + { + type: "GPE", + start: 30, + end: 36, + }, + ], + type: "text-with-tokens", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: + "A robust performance model to identify people, locations, organizations and names of miscellaneous entities.", + id: "dslim/bert-base-NER", + }, + { + description: "A strong model to identify people, locations, organizations and names in multiple languages.", + id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english", + }, + { + description: "A token classification model specialized on medical entity recognition.", + id: "blaze999/Medical-NER", + }, + { + description: "Flair models are typically the state of the art in named entity recognition tasks.", + id: "flair/ner-english", + }, + ], + spaces: [ + { + description: + "An application that can recognizes entities, extracts noun chunks and recognizes various linguistic features of each token.", + id: "spacy/gradio_pipeline_visualizer", + }, + ], + summary: + "Token classification is a natural language understanding task in which a label is assigned to some tokens in a text. Some popular token classification subtasks are Named Entity Recognition (NER) and Part-of-Speech (PoS) tagging. NER models could be trained to identify specific entities in a text, such as dates, individuals and places; and PoS tagging would identify, for example, which words in a text are verbs, nouns, and punctuation marks.", + widgetModels: ["FacebookAI/xlm-roberta-large-finetuned-conll03-english"], + youtubeId: "wVHdVlPScxA", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..09f899c6b039a8f78f313c02e25b55a791e7e3c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts @@ -0,0 +1,83 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Token Classification inference + */ +export interface TokenClassificationInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Token Classification + */ + parameters?: TokenClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Token Classification + */ +export interface TokenClassificationParameters { + /** + * The strategy used to fuse tokens based on model predictions + */ + aggregation_strategy?: TokenClassificationAggregationStrategy; + /** + * A list of labels to ignore + */ + ignore_labels?: string[]; + /** + * The number of overlapping tokens between chunks when splitting the input text. + */ + stride?: number; + [property: string]: unknown; +} +/** + * Do not aggregate tokens + * + * Group consecutive tokens with the same label in a single entity. + * + * Similar to "simple", also preserves word integrity (use the label predicted for the first + * token in a word). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest + * score, averaged across the word's tokens). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest score + * across the word's tokens). + */ +export type TokenClassificationAggregationStrategy = "none" | "simple" | "first" | "average" | "max"; +export type TokenClassificationOutput = TokenClassificationOutputElement[]; +/** + * Outputs of inference for the Token Classification task + */ +export interface TokenClassificationOutputElement { + /** + * The character position in the input where this group ends. + */ + end: number; + /** + * The predicted label for a single token + */ + entity?: string; + /** + * The predicted label for a group of one or more tokens + */ + entity_group?: string; + /** + * The associated score / probability + */ + score: number; + /** + * The character position in the input where this group begins. + */ + start: number; + /** + * The corresponding text + */ + word: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..1176f3dd9a4a903dd41737bbd6dc088483285407 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json @@ -0,0 +1,64 @@ +{ + "$id": "/inference/schemas/token-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Token Classification inference", + "title": "TokenClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Token Classification", + "$ref": "#/$defs/TokenClassificationParameters" + } + }, + "$defs": { + "TokenClassificationParameters": { + "title": "TokenClassificationParameters", + "type": "object", + "properties": { + "ignore_labels": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of labels to ignore" + }, + "stride": { + "type": "integer", + "description": "The number of overlapping tokens between chunks when splitting the input text." + }, + "aggregation_strategy": { + "title": "TokenClassificationAggregationStrategy", + "type": "string", + "description": "The strategy used to fuse tokens based on model predictions", + "oneOf": [ + { + "const": "none", + "description": "Do not aggregate tokens" + }, + { + "const": "simple", + "description": "Group consecutive tokens with the same label in a single entity." + }, + { + "const": "first", + "description": "Similar to \"simple\", also preserves word integrity (use the label predicted for the first token in a word)." + }, + { + "const": "average", + "description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score, averaged across the word's tokens)." + }, + { + "const": "max", + "description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score across the word's tokens)." + } + ] + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..649a871b7b42b527b6a7f1c28fe86f5bfc085b25 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json @@ -0,0 +1,37 @@ +{ + "$id": "/inference/schemas/token-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Token Classification task", + "title": "TokenClassificationOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "entity_group": { + "type": "string", + "description": "The predicted label for a group of one or more tokens" + }, + "entity": { + "type": "string", + "description": "The predicted label for a single token" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + }, + "word": { + "type": "string", + "description": "The corresponding text" + }, + "start": { + "type": "integer", + "description": "The character position in the input where this group begins." + }, + "end": { + "type": "integer", + "description": "The character position in the input where this group ends." + } + }, + "required": ["score", "word", "start", "end"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/about.md b/node_modules/@huggingface/tasks/src/tasks/translation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..f4806687a5cbebba9dce19f0053b33bd349e3a82 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/about.md @@ -0,0 +1,65 @@ +## Use Cases + +You can find over a thousand Translation models on the Hub, but sometimes you might not find a model for the language pair you are interested in. When this happen, you can use a pretrained multilingual Translation model like [mBART](https://huggingface.co/facebook/mbart-large-cc25) and further train it on your own data in a process called fine-tuning. + +### Multilingual conversational agents + +Translation models can be used to build conversational agents across different languages. This can be done in two ways. + +- **Translate the dataset to a new language.** You can translate a dataset of intents (inputs) and responses to the target language. You can then train a new intent classification model with this new dataset. This allows you to proofread responses in the target language and have better control of the chatbot's outputs. + +* **Translate the input and output of the agent.** You can use a Translation model in user inputs so that the chatbot can process it. You can then translate the output of the chatbot into the language of the user. This approach might be less reliable as the chatbot will generate responses that were not defined before. + +## Inference + +You can use the 🤗 Transformers library with the `translation_xx_to_yy` pattern where xx is the source language code and yy is the target language code. The default model for the pipeline is [t5-base](https://huggingface.co/t5-base) which under the hood adds a task prefix indicating the task itself, e.g. “translate: English to French”. + +```python +from transformers import pipeline +en_fr_translator = pipeline("translation_en_to_fr") +en_fr_translator("How old are you?") +## [{'translation_text': ' quel âge êtes-vous?'}] +``` + +If you’d like to use a specific model checkpoint that is from one specific language to another, you can also directly use the `translation` pipeline. + +```python +from transformers import pipeline + +model_checkpoint = "Helsinki-NLP/opus-mt-en-fr" +translator = pipeline("translation", model=model_checkpoint) +translator("How are you?") +# [{'translation_text': 'Comment allez-vous ?'}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer translation models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.translation({ + model: "t5-base", + inputs: "My name is Wolfgang and I live in Berlin", +}); +``` + +## Useful Resources + +Would you like to learn more about Translation? Great! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Translation](https://huggingface.co/course/chapter7/4?fw=pt) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/translation.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/translation-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/translation) + +### Documentation + +- [Translation task guide](https://huggingface.co/docs/transformers/tasks/translation) diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/data.ts b/node_modules/@huggingface/tasks/src/tasks/translation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f7cb112c2a694464765858cd92bdc89280a0451 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/data.ts @@ -0,0 +1,70 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-generation", + datasets: [ + { + description: "A dataset of copyright-free books translated into 16 different languages.", + id: "Helsinki-NLP/opus_books", + }, + { + description: + "An example of translation between programming languages. This dataset consists of functions in Java and C#.", + id: "google/code_x_glue_cc_code_to_code_trans", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: "Mein Name ist Omar und ich wohne in Zürich.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "BLEU score is calculated by counting the number of shared single or subsequent tokens between the generated sequence and the reference. Subsequent n tokens are called “n-grams”. Unigram refers to a single token while bi-gram refers to token pairs and n-grams refer to n subsequent tokens. The score ranges from 0 to 1, where 1 means the translation perfectly matched and 0 did not match at all", + id: "bleu", + }, + { + description: "", + id: "sacrebleu", + }, + ], + models: [ + { + description: + "Very powerful model that can translate many languages between each other, especially low-resource languages.", + id: "facebook/nllb-200-1.3B", + }, + { + description: + "A general-purpose Transformer that can be used to translate from English to German, French, or Romanian.", + id: "google-t5/t5-base", + }, + ], + spaces: [ + { + description: "An application that can translate between 100 languages.", + id: "Iker/Translate-100-languages", + }, + { + description: "An application that can translate between many languages.", + id: "Geonmo/nllb-translation-demo", + }, + ], + summary: "Translation is the task of converting text from one language to another.", + widgetModels: ["facebook/mbart-large-50-many-to-many-mmt"], + youtubeId: "1JvfrvZgi6c", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..caa875033056ebed2ecbfeb6382e28d5bb8211f4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts @@ -0,0 +1,63 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Translation inference + */ +export interface TranslationInput { + /** + * The text to translate. + */ + inputs: string; + /** + * Additional inference parameters for Translation + */ + parameters?: TranslationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Translation + */ +export interface TranslationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The source language of the text. Required for models that can translate from multiple + * languages. + */ + src_lang?: string; + /** + * Target language to translate to. Required for models that can translate to multiple + * languages. + */ + tgt_lang?: string; + /** + * The truncation strategy to use. + */ + truncation?: TranslationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type TranslationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Translation task + */ +export interface TranslationOutput { + /** + * The translated text. + */ + translation_text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..8f0a6fc6f936d37f129dfb7998e6abd9671930e0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json @@ -0,0 +1,49 @@ +{ + "$id": "/inference/schemas/translation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Translation inference", + "title": "TranslationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to translate.", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Translation", + "$ref": "#/$defs/TranslationParameters" + } + }, + "$defs": { + "TranslationParameters": { + "title": "TranslationParameters", + "type": "object", + "properties": { + "src_lang": { + "type": "string", + "description": "The source language of the text. Required for models that can translate from multiple languages." + }, + "tgt_lang": { + "type": "string", + "description": "Target language to translate to. Required for models that can translate to multiple languages." + }, + "clean_up_tokenization_spaces": { + "type": "boolean", + "description": "Whether to clean up the potential extra spaces in the text output." + }, + "truncation": { + "title": "TranslationTruncationStrategy", + "type": "string", + "description": "The truncation strategy to use.", + "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"] + }, + "generate_parameters": { + "title": "generateParameters", + "type": "object", + "description": "Additional parametrization of the text generation algorithm." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..976c3641eb32a07865d2efc921242ade895da3c0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/translation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Translation task", + "title": "TranslationOutput", + "type": "object", + "properties": { + "translation_text": { + "type": "string", + "description": "The translated text." + } + }, + "required": ["translation_text"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..e5a9585528ae0afd0bc779d0d8628ceca167376e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md @@ -0,0 +1,50 @@ +## About the Task + +Unconditional image generation is the task of generating new images without any specific input. The main goal of this is to create novel, original images that are not based on existing images. +This can be used for a variety of applications, such as creating new artistic images, improving image recognition algorithms, or generating photorealistic images for virtual reality environments. + +Unconditional image generation models usually start with a _seed_ that generates a _random noise vector_. The model will then use this vector to create an output image similar to the images used for training the model. + +An example of unconditional image generation would be generating the image of a face on a model trained with the [CelebA dataset](https://huggingface.co/datasets/huggan/CelebA-HQ) or [generating a butterfly](https://huggingface.co/spaces/huggan/butterfly-gan) on a model trained with the [Smithsonian Butterflies dataset](https://huggingface.co/datasets/ceyda/smithsonian_butterflies). + +[Generative adversarial networks](https://en.wikipedia.org/wiki/Generative_adversarial_network) and [Diffusion](https://huggingface.co/docs/diffusers/index) are common architectures for this task. + +## Use Cases + +Unconditional image generation can be used for a variety of applications. + +### Artistic Expression + +Unconditional image generation can be used to create novel, original artwork that is not based on any existing images. This can be used to explore new creative possibilities and produce unique, imaginative images. + +### Data Augmentation + +Unconditional image generation models can be used to generate new images to improve the performance of image recognition algorithms. This makes algorithms more robust and able to handle a broader range of images. + +### Virtual Reality + +Unconditional image generation models can be used to create photorealistic images that can be used in virtual reality environments. This makes the VR experience more immersive and realistic. + +### Medical Imaging + +Unconditional image generation models can generate new medical images, such as CT or MRI scans, that can be used to train and evaluate medical imaging algorithms. This can improve the accuracy and reliability of these algorithms. + +### Industrial Design + +Unconditional image generation models can generate new designs for products, such as clothing or furniture, that are not based on any existing designs. This way, designers can explore new creative possibilities and produce unique, innovative designs. + +## Model Hosting and Inference + +This section should have useful information about Model Hosting and Inference + +## Useful Resources + +- [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class) +- [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index) +- [Unconditional Image Generation Training](https://huggingface.co/docs/diffusers/training/unconditional_training) + +### Training your own model in just a few seconds + +In this area, you can insert useful information about training the model + +This page was made possible thanks to the efforts of [Someet Sahoo](https://huggingface.co/Someet24) and [Juan Carlos Piñeros](https://huggingface.co/juancopi81). diff --git a/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcd66648eff68ecd77ab1c1a93528c7f305dab1b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts @@ -0,0 +1,72 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "The CIFAR-100 dataset consists of 60000 32x32 colour images in 100 classes, with 600 images per class.", + id: "cifar100", + }, + { + description: "Multiple images of celebrities, used for facial expression translation.", + id: "CelebA", + }, + ], + demo: { + inputs: [ + { + label: "Seed", + content: "42", + type: "text", + }, + { + label: "Number of images to generate:", + content: "4", + type: "text", + }, + ], + outputs: [ + { + filename: "unconditional-image-generation-output.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The inception score (IS) evaluates the quality of generated images. It measures the diversity of the generated images (the model predictions are evenly distributed across all possible labels) and their 'distinction' or 'sharpness' (the model confidently predicts a single label for each image).", + id: "Inception score (IS)", + }, + { + description: + "The Fréchet Inception Distance (FID) evaluates the quality of images created by a generative model by calculating the distance between feature vectors for real and generated images.", + id: "Frećhet Inception Distance (FID)", + }, + ], + models: [ + { + description: + "High-quality image generation model trained on the CIFAR-10 dataset. It synthesizes images of the ten classes presented in the dataset using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-cifar10-32", + }, + { + description: + "High-quality image generation model trained on the 256x256 CelebA-HQ dataset. It synthesizes images of faces using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-celebahq-256", + }, + ], + spaces: [ + { + description: "An application that can generate realistic faces.", + id: "CompVis/celeba-latent-diffusion", + }, + ], + summary: + "Unconditional image generation is the task of generating images with no condition in any context (like a prompt text or another image). Once trained, the model will create images that resemble its training data distribution.", + widgetModels: [""], + // TODO: Add related video + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..0436a873d3989f5c54fbff555fbfc573d3bd43b9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md @@ -0,0 +1,37 @@ +## Use Cases + +Video classification models can be used to categorize what a video is all about. + +### Activity Recognition + +Video classification models are used to perform activity recognition which is useful for fitness applications. Activity recognition is also helpful for vision-impaired individuals especially when they're commuting. + +### Video Search + +Models trained in video classification can improve user experience by organizing and categorizing video galleries on the phone or in the cloud, on multiple keywords or tags. + +## Inference + +Below you can find code for inferring with a pre-trained video classification model. + +```python +from transformers import pipeline + +pipe = pipeline(task = "video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset") +pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi?download=true") + +#[{'score': 0.90, 'label': 'BasketballDunk'}, +# {'score': 0.02, 'label': 'BalanceBeam'}, +# ... ] +``` + +## Useful Resources + +- [Developing a simple video classification model](https://keras.io/examples/vision/video_classification) +- [Video classification with Transformers](https://keras.io/examples/vision/video_transformers) +- [Building a video archive](https://www.youtube.com/watch?v=_IeS1m8r6SY) +- [Video classification task guide](https://huggingface.co/docs/transformers/tasks/video_classification) + +### Creating your own video classifier in minutes + +- [Fine-tuning tutorial notebook (PyTorch)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/video_classification.ipynb) diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e5abbce9cb324cd1f1a573e7b8a5a4184fd93ff --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts @@ -0,0 +1,84 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Benchmark dataset used for video classification with videos that belong to 400 classes.", + id: "kinetics400", + }, + ], + demo: { + inputs: [ + { + filename: "video-classification-input.gif", + type: "img", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Playing Guitar", + score: 0.514, + }, + { + label: "Playing Tennis", + score: 0.193, + }, + { + label: "Cooking", + score: 0.068, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "google/vivit-b-16x2-kinetics400", + }, + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "microsoft/xclip-base-patch32", + }, + ], + spaces: [ + { + description: "An application that classifies video at different timestamps.", + id: "nateraw/lavila", + }, + { + description: "An application that classifies video.", + id: "fcakyon/video-classification", + }, + ], + summary: + "Video classification is the task of assigning a label or class to an entire video. Videos are expected to have only one class for each video. Video classification models take a video as input and return a prediction about which class the video belongs to.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c937d9c180d5022695b1f3eb00568bb45b417e9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Video Classification inference + */ +export interface VideoClassificationInput { + /** + * The input video data + */ + inputs: unknown; + /** + * Additional inference parameters for Video Classification + */ + parameters?: VideoClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Video Classification + */ +export interface VideoClassificationParameters { + /** + * The sampling rate used to select frames from the video. + */ + frame_sampling_rate?: number; + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * The number of sampled frames to consider for classification. + */ + num_frames?: number; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type VideoClassificationOutput = VideoClassificationOutputElement[]; +/** + * Outputs of inference for the Video Classification task + */ +export interface VideoClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..277950e59d0834c788935ba0e5ab1b4dbc6a2525 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/video-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Video Classification inference", + "title": "VideoClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input video data" + }, + "parameters": { + "description": "Additional inference parameters for Video Classification", + "$ref": "#/$defs/VideoClassificationParameters" + } + }, + "$defs": { + "VideoClassificationParameters": { + "title": "VideoClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "TextClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "num_frames": { + "type": "integer", + "description": "The number of sampled frames to consider for classification." + }, + "frame_sampling_rate": { + "type": "integer", + "description": "The sampling rate used to select frames from the video." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..4c24f5d577717994e0b4a8e329a7e063a967cb10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json @@ -0,0 +1,10 @@ +{ + "$id": "/inference/schemas/video-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Video Classification task", + "title": "VideoClassificationOutput", + "type": "array", + "items": { + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..2d9af88d36a9e15b64e11623e25ecb2f3b20649f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md @@ -0,0 +1,98 @@ +Most of the video language models can take in videos, multiple videos, images and multiple images. Some of these models can also take interleaved inputs, which can have images and videos inside the text, where you can refer to the input images and input videos within the text prompt. + +## Different Types of Video Language Models + +Video language models come in three types: + +- **Base:** Pre-trained models that can be fine-tuned. +- **Instruction:** Base models fine-tuned on video-instruction pairs and answers. +- **Chatty/Conversational:** Base models fine-tuned on video conversation datasets. + +## Use Cases + +### Video Question Answering + +Video language models trained on video-question-answer pairs can be used for video question answering and generating captions for videos. + +### Video Chat + +Video language models can be used to have a dialogue about a video. + +### Video Recognition with Instructions + +Video language models can recognize images through descriptions. When given detailed descriptions of specific entities, they can classify the entities in a video. + +## Inference + +You can use the Transformers library to interact with video-language models. +Below we load [a video language model](https://huggingface.co/llava-hf/LLaVA-NeXT-Video-7B-hf), write a simple utility to sample videos, use chat template to format the text prompt, process the video and the text prompt and infer. To run the snippet below, please install [OpenCV](https://pypi.org/project/opencv-python/) by running `pip install opencv-python`. + +```python +import uuid +import requests +import cv2 +import torch +from transformers import LlavaNextVideoProcessor, LlavaNextVideoForConditionalGeneration + +device = "cuda" if torch.cuda.is_available() else "cpu" +model_id = "llava-hf/LLaVA-NeXT-Video-7B-hf" + +model = LlavaNextVideoForConditionalGeneration.from_pretrained( + model_id, + torch_dtype=torch.float16, + low_cpu_mem_usage=True, +).to(device) + +processor = LlavaNextVideoProcessor.from_pretrained(model_id) + +def sample_frames(url, num_frames): + response = requests.get(url) + path_id = str(uuid.uuid4()) + + path = f"./{path_id}.mp4" + + with open(path, "wb") as f: + f.write(response.content) + + video = cv2.VideoCapture(path) + total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) + interval = total_frames // num_frames + frames = [] + for i in range(total_frames): + ret, frame = video.read() + if not ret: + continue + if i % interval == 0: + pil_img = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) + frames.append(pil_img) + video.release() + return frames + +conversation = [ + { + + "role": "user", + "content": [ + {"type": "text", "text": "Why is this video funny?"}, + {"type": "video"}, + ], + }, +] + +prompt = processor.apply_chat_template(conversation, add_generation_prompt=True) + +video_url = "https://huggingface.co/spaces/merve/llava-interleave/resolve/main/cats_1.mp4" +video = sample_frames(video, 8) + +inputs = processor(text=prompt, videos=video, padding=True, return_tensors="pt").to(model.device) + +output = model.generate(**inputs, max_new_tokens=100, do_sample=False) +print(processor.decode(output[0][2:], skip_special_tokens=True)) + +# Why is this video funny? ASSISTANT: The humor in this video comes from the cat's facial expression and body language. The cat appears to be making a funny face, with its eyes squinted and mouth open, which can be interpreted as a playful or mischievous expression. Cats often make such faces when they are in a good mood or are playful, and this can be amusing to people who are familiar with their behavior. The combination of the cat's expression and the close- + +``` + +## Useful Resources + +- [Transformers task guide on video-text-to-text](https://huggingface.co/docs/transformers/tasks/video_text_to_text) diff --git a/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..75e6908efe3b103345e5ffb2aaf647a2e9ccc880 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts @@ -0,0 +1,74 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Multiple-choice questions and answers about videos.", + id: "lmms-lab/Video-MME", + }, + { + description: "A dataset of instructions and question-answer pairs about videos.", + id: "lmms-lab/VideoChatGPT", + }, + { + description: "Large video understanding dataset.", + id: "HuggingFaceFV/finevideo", + }, + ], + demo: { + inputs: [ + { + filename: "video-text-to-text-input.gif", + type: "img", + }, + { + label: "Text Prompt", + content: "What is happening in this video?", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: + "The video shows a series of images showing a fountain with water jets and a variety of colorful flowers and butterflies in the background.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust video-text-to-text model.", + id: "Vision-CAIR/LongVU_Qwen2_7B", + }, + { + description: "Strong video-text-to-text model with reasoning capabilities.", + id: "GoodiesHere/Apollo-LMMs-Apollo-7B-t32", + }, + { + description: "Strong video-text-to-text model.", + id: "HuggingFaceTB/SmolVLM2-2.2B-Instruct", + }, + ], + spaces: [ + { + description: "An application to chat with a video-text-to-text model.", + id: "llava-hf/video-llava", + }, + { + description: "A leaderboard for various video-text-to-text models.", + id: "opencompass/openvlm_video_leaderboard", + }, + { + description: "An application to generate highlights from a video.", + id: "HuggingFaceTB/SmolVLM2-HighlightGenerator", + }, + ], + summary: + "Video-text-to-text models take in a video and a text prompt and output text. These models are also called video-language models.", + widgetModels: [""], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9846262a8d7edfebe9d5ab69802a05b68e33c125 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md @@ -0,0 +1,86 @@ +## Use Cases + +### Video Style Transfer + +Apply artistic or cinematic styles to a video while preserving motion and structure. For example, convert real footage into anime, painting, or film-like visuals. + +### Frame Interpolation + +Generate intermediate frames to make videos smoother or convert 30 FPS videos to 60 FPS. This improves motion flow and enables realistic slow-motion playback. + +### Video Super-Resolution + +Enhance low-resolution videos into high-definition outputs with preserved detail and sharpness. Ideal for restoring old footage or improving video quality. + +### Motion Transfer + +Transfer the motion from a source video to another subject while maintaining identity and environment. This enables realistic animation or gesture replication. + +### Video Editing & Synthesis + +Add, remove, or modify objects in videos while keeping lighting and motion consistent. Perfect for visual effects, object replacement, and content-aware editing. + +### Temporal Modification + +Change a video’s overall time or environmental conditions, such as day to night or summer to winter. These models preserve motion dynamics and lighting continuity. + +### Virtual Try-on + +Simulate clothing changes or outfit fitting in videos while keeping the person’s motion and identity intact. Useful for digital fashion and e-commerce applications. + +## Inference + +Below is an example demonstrating how to use [Lucy-Edit-Dev](https://huggingface.co/decart-ai/Lucy-Edit-Dev) to perform video costume editing, changing a character’s clothing while maintaining identity and motion consistency. Lucy-Edit-Dev is trained on paired video edits, captioned videos, and extended image–text datasets. + +```python +!pip install torch diffusers + +import torch +from PIL import Image + +from diffusers import AutoencoderKLWan, LucyEditPipeline +from diffusers.utils import export_to_video, load_video + + +url = "https://d2drjpuinn46lb.cloudfront.net/painter_original_edit.mp4" +prompt = "Change the apron and blouse to a classic clown costume: satin polka-dot jumpsuit in bright primary colors, ruffled white collar, oversized pom-pom buttons, white gloves, oversized red shoes, red foam nose; soft window light from left, eye-level medium shot, natural folds and fabric highlights." +negative_prompt = "" +num_frames = 81 +height = 480 +width = 832 + +def convert_video(video: List[Image.Image]) -> List[Image.Image]: + video = load_video(url)[:num_frames] + video = [video[i].resize((width, height)) for i in range(num_frames)] + return video + +video = load_video(url, convert_method=convert_video) + +model_id = "decart-ai/Lucy-Edit-Dev" +vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) +pipe = LucyEditPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) +pipe.to("cuda") + +output = pipe( + prompt=prompt, + video=video, + negative_prompt=negative_prompt, + height=480, + width=832, + num_frames=81, + guidance_scale=5.0 +).frames[0] + +export_to_video(output, "output.mp4", fps=24) +``` + +For more inference examples, check out the model cards on Hugging Face, where you can try the provided example code. + +## Useful Resources + +You can read more about the datasets, model architectures, and open-source implementations in the following repositories: + +- [Lumen](https://github.com/Kunbyte-AI/Lumen) - Official implementation of Lumen for text-guided video editing. +- [VIRES](https://github.com/suimuc/VIRES) - Implementation for sketch- and text-guided video instance repainting. +- [ECCV2022-RIFE: Video Frame Interpolation](https://github.com/hzwer/ECCV2022-RIFE) - Real-time video frame interpolation via intermediate flow estimation. +- [StableVSR: Enhancing Perceptual Quality in Video](https://github.com/claudiom4sir/StableVSR) - Super-resolution method to enhance perceptual video quality. diff --git a/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bd172b2d1c59247ad61380601f84a69f745c46f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts @@ -0,0 +1,67 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Dataset with detailed annotations for training and benchmarking video instance editing.", + id: "suimu/VIRESET", + }, + { + description: "Dataset to evaluate models on long video generation and understanding.", + id: "zhangsh2001/LongV-EVAL", + }, + { + description: "Collection of 104 demo videos from the SeedVR/SeedVR2 series showcasing model outputs.", + id: "Iceclear/SeedVR_VideoDemos", + }, + ], + demo: { + inputs: [ + { + filename: "input.gif", + type: "img", + }, + ], + outputs: [ + { + filename: "output.gif", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "Model for editing outfits, character, and scenery in videos.", + id: "decart-ai/Lucy-Edit-Dev", + }, + { + description: "Framework that uses 3D mesh proxies for precise, consistent video editing.", + id: "LeoLau/Shape-for-Motion", + }, + { + description: "Model for generating physics-aware videos from input videos and control conditions.", + id: "nvidia/Cosmos-Transfer2.5-2B", + }, + { + description: "A model to upscale videos at input, designed for seamless use with ComfyUI.", + id: "numz/SeedVR2_comfyUI", + }, + ], + spaces: [ + { + description: "Interactive demo space for Lucy-Edit-Dev video editing.", + id: "decart-ai/lucy-edit-dev", + }, + { + description: "Demo space for SeedVR2-3B showcasing video upscaling and restoration.", + id: "ByteDance-Seed/SeedVR2-3B", + }, + ], + summary: + "Video-to-video models take one or more videos as input and generate new videos as output. They can enhance quality, interpolate frames, modify styles, or create new motion dynamics, enabling creative applications, video production, and research.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md new file mode 100644 index 0000000000000000000000000000000000000000..97635b411d28583b306eb6cb53bb46e72a814655 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md @@ -0,0 +1,54 @@ +## Use Cases + +### Multimodal Document Retrieval + +Visual document retrieval models can be used to retrieve relevant documents when given a text query. One needs to index the documents first, which is a one-time operation. After indexing is done, the retrieval model takes in a text query (question) and number `k` of documents to return, and the model returns the top-k most relevant documents for the query. The index can be used repetitively for inference. + +### Multimodal Retrieval Augmented Generation (RAG) + +Multimodal RAG is the task of generating answers from documents (texts or images) when given a text query and a bunch of documents. These documents and the text query can be fed to [a vision language model](https://huggingface.co/tasks/image-text-to-text) to get the actual answer. + +## Inference + +You can use transformers to infer visual document retrieval models. To calculate similarity between images and text, simply process both separately and pass each processed input through the model. The model outputs can then be passed to calculate similarity scores. + +```python +import torch +from PIL import Image +from transformers import ColPaliForRetrieval, ColPaliProcessor + +device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") + +model = ColPaliForRetrieval.from_pretrained( + "vidore/colpali-v1.2-hf", + torch_dtype=torch.bfloat16, +).to(device) + +processor = ColPaliProcessor.from_pretrained("vidore/colpali-v1.2-hf") + +# Your inputs (replace dummy images with screenshots of your documents) +images = [ + Image.new("RGB", (32, 32), color="white"), + Image.new("RGB", (16, 16), color="black"), +] +queries = [ + "What is the organizational structure for our R&D department?", + "Can you provide a breakdown of last year’s financial performance?", +] + +# Process the image and text +batch_images = processor(images=images).to(device) +batch_queries = processor(text=queries).to(device) + +with torch.no_grad(): + image_embeddings = model(**batch_images).embeddings + query_embeddings = model(**batch_queries).embeddings + +# Score the queries against the images +scores = processor.score_retrieval(query_embeddings, image_embeddings) +``` + +## Useful Resources + +- [Multimodal Retrieval Augmented Generation using ColPali and Qwen2VL](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb) +- [Fine-tuning ColPali for Multimodal Retrieval Augmented Generation](https://github.com/merveenoyan/smol-vision/blob/main/Finetune_ColPali.ipynb) diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6a8aceb5255c49b7c7b2ec74b391030ec244b4e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts @@ -0,0 +1,76 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset used to train visual document retrieval models.", + id: "vidore/colpali_train_set", + }, + ], + demo: { + inputs: [ + { + filename: "input.png", + type: "img", + }, + { + label: "Question", + content: "Is the model in this paper the fastest for inference?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Page 10", + score: 0.7, + }, + { + label: "Page 11", + score: 0.06, + }, + { + label: "Page 9", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "NDCG@k scores ranked recommendation lists for top-k results. 0 is the worst, 1 is the best.", + id: "Normalized Discounted Cumulative Gain at K", + }, + ], + models: [ + { + description: "Very accurate visual document retrieval model for multilingual queries and documents.", + id: "vidore/colqwen2-v1.0", + }, + { + description: + "Very fast and efficient visual document retrieval model that can also take in other modalities like audio.", + id: "Tevatron/OmniEmbed-v0.1", + }, + ], + spaces: [ + { + description: "A leaderboard of visual document retrieval models.", + id: "vidore/vidore-leaderboard", + }, + { + description: "Visual retrieval augmented generation demo based on ColQwen2 model.", + id: "vidore/visual-rag-tool", + }, + ], + summary: + "Visual document retrieval is the task of searching for relevant image-based documents, such as PDFs. These models take a text query and multiple documents as input and return the top-most relevant documents and relevancy scores as output.", + widgetModels: [""], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..7f96e1679b8a5b46042f5c6e2eb533e80749160f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md @@ -0,0 +1,48 @@ +## Use Cases + +### Aid the Visually Impaired Persons + +VQA models can be used to reduce visual barriers for visually impaired individuals by allowing them to get information about images from the web and the real world. + +### Education + +VQA models can be used to improve experiences at museums by allowing observers to directly ask questions they interested in. + +### Improved Image Retrieval + +Visual question answering models can be used to retrieve images with specific characteristics. For example, the user can ask "Is there a dog?" to find all images with dogs from a set of images. + +### Video Search + +Specific snippets/timestamps of a video can be retrieved based on search queries. For example, the user can ask "At which part of the video does the guitar appear?" and get a specific timestamp range from the whole video. + +## Task Variants + +### Video Question Answering + +Video Question Answering aims to answer questions asked about the content of a video. + +## Inference + +You can infer with Visual Question Answering models using the `vqa` (or `visual-question-answering`) pipeline. This pipeline requires [the Python Image Library (PIL)](https://pillow.readthedocs.io/en/stable/) to process images. You can install it with (`pip install pillow`). + +```python +from PIL import Image +from transformers import pipeline + +vqa_pipeline = pipeline("visual-question-answering") + +image = Image.open("elephant.jpeg") +question = "Is there an elephant?" + +vqa_pipeline(image, question, top_k=1) +#[{'score': 0.9998154044151306, 'answer': 'yes'}] +``` + +## Useful Resources + +- [An introduction to Visual Question Answering - AllenAI](https://blog.allenai.org/vanilla-vqa-adcaaaa94336) +- [Multi Modal Framework (MMF) - Meta Research](https://mmf.sh/docs/getting_started/video_overview/) + +The contents of this page are contributed by [ +Bharat Raghunathan](https://huggingface.co/bharat-raghunathan) and [Jose Londono Botero](https://huggingface.co/jlondonobo). diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..51de32a80d53a733265e3ebb40358d3efeb02d82 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts @@ -0,0 +1,97 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset containing questions (with answers) about images.", + id: "Graphcore/vqa", + }, + { + description: "A dataset to benchmark visual reasoning based on text in images.", + id: "facebook/textvqa", + }, + ], + demo: { + inputs: [ + { + filename: "elephant.jpeg", + type: "img", + }, + { + label: "Question", + content: "What is in this image?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "elephant", + score: 0.97, + }, + { + label: "elephants", + score: 0.06, + }, + { + label: "animal", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: + "Measures how much a predicted answer differs from the ground truth based on the difference in their semantic meaning.", + id: "wu-palmer similarity", + }, + ], + models: [ + { + description: "A visual question answering model trained to convert charts and plots to text.", + id: "google/deplot", + }, + { + description: + "A visual question answering model trained for mathematical reasoning and chart derendering from images.", + id: "google/matcha-base", + }, + { + description: "A strong visual question answering that answers questions from book covers.", + id: "google/pix2struct-ocrvqa-large", + }, + ], + spaces: [ + { + description: "An application that compares visual question answering models across different tasks.", + id: "merve/pix2struct", + }, + { + description: "An application that can answer questions based on images.", + id: "nielsr/vilt-vqa", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "Salesforce/BLIP", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "vumichien/Img2Prompt", + }, + ], + summary: + "Visual Question Answering is the task of answering open-ended questions based on an image. They output natural language responses to natural language questions.", + widgetModels: ["dandelin/vilt-b32-finetuned-vqa"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..3eb292c62d8c7aa03e540af836e7a65d0c21fe0d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Visual Question Answering inference + */ +export interface VisualQuestionAnsweringInput { + /** + * One (image, question) pair to answer + */ + inputs: VisualQuestionAnsweringInputData; + /** + * Additional inference parameters for Visual Question Answering + */ + parameters?: VisualQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (image, question) pair to answer + */ +export interface VisualQuestionAnsweringInputData { + /** + * The image. + */ + image: unknown; + /** + * The question to answer based on the image. + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Visual Question Answering + */ +export interface VisualQuestionAnsweringParameters { + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type VisualQuestionAnsweringOutput = VisualQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Visual Question Answering task + */ +export interface VisualQuestionAnsweringOutputElement { + /** + * The answer to the question + */ + answer?: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..d51f35c37992cef2147b35a263f2281cab1b3ea0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/visual-question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Visual Question Answering inference", + "title": "VisualQuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "description": "One (image, question) pair to answer", + "type": "object", + "title": "VisualQuestionAnsweringInputData", + "properties": { + "image": { + "description": "The image.", + "comment": "type=binary" + }, + "question": { + "description": "The question to answer based on the image.", + "type": "string" + } + }, + "required": ["question", "image"] + }, + "parameters": { + "description": "Additional inference parameters for Visual Question Answering", + "$ref": "#/$defs/VisualQuestionAnsweringParameters" + } + }, + "$defs": { + "VisualQuestionAnsweringParameters": { + "title": "VisualQuestionAnsweringParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "The number of answers to return (will be chosen by order of likelihood). Note that we return less than topk answers if there are not enough options available within the context." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..2233951410bc63e7a6ee1b827c4ee385690e3877 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json @@ -0,0 +1,21 @@ +{ + "$id": "/inference/schemas/visual-question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Visual Question Answering task", + "title": "VisualQuestionAnsweringOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer to the question" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + } + }, + "required": ["score"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9b7ff3c48c931d3355c76aed20b891fe8f57c54b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md @@ -0,0 +1,40 @@ +## About the Task + +Zero Shot Classification is the task of predicting a class that wasn't seen by the model during training. This method, which leverages a pre-trained language model, can be thought of as an instance of [transfer learning](https://www.youtube.com/watch?v=BqqfQnyjmgg) which generally refers to using a model trained for one task in a different application than what it was originally trained for. This is particularly useful for situations where the amount of labeled data is small. + +In zero shot classification, we provide the model with a prompt and a sequence of text that describes what we want our model to do, in natural language. Zero-shot classification excludes any examples of the desired task being completed. This differs from single or few-shot classification, as these tasks include a single or a few examples of the selected task. + +Zero, single and few-shot classification seem to be an emergent feature of large language models. This feature seems to come about around model sizes of +100M parameters. The effectiveness of a model at a zero, single or few-shot task seems to scale with model size, meaning that larger models (models with more trainable parameters or layers) generally do better at this task. + +Here is an example of a zero-shot prompt for classifying the sentiment of a sequence of text: + +``` +Classify the following input text into one of the following three categories: [positive, negative, neutral] + +Input Text: Hugging Face is awesome for making all of these +state of the art models available! +Sentiment: positive + +``` + +One great example of this task with a nice off-the-shelf model is available at the widget of this page, where the user can input a sequence of text and candidate labels to the model. This is a _word level_ example of zero shot classification, more elaborate and lengthy generations are available with larger models. Testing these models out and getting a feel for prompt engineering is the best way to learn how to use them. + +## Inference + +You can use the 🤗 Transformers library zero-shot-classification pipeline to infer with zero shot text classification models. + +```python +from transformers import pipeline + +pipe = pipeline(model="facebook/bart-large-mnli") +pipe("I have a problem with my iphone that needs to be resolved asap!", + candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"], +) +# output +>>> {'sequence': 'I have a problem with my iphone that needs to be resolved asap!!', 'labels': ['urgent', 'phone', 'computer', 'not urgent', 'tablet'], 'scores': [0.504, 0.479, 0.013, 0.003, 0.002]} +``` + +## Useful Resources + +- [Zero Shot Learning](https://joeddav.github.io/blog/2020/05/29/ZSL.html) +- [Hugging Face on Transfer Learning](https://huggingface.co/course/en/chapter1/4?fw=pt#transfer-learning) diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbd0ceda5f77e2e880bb41aa7602f8f15820ad0a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts @@ -0,0 +1,74 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: + "The Multi-Genre Natural Language Inference (MultiNLI) corpus is a crowd-sourced collection of 433k sentence pairs annotated with textual entailment information.", + id: "nyu-mll/multi_nli", + }, + { + description: + "FEVER is a publicly available dataset for fact extraction and verification against textual sources.", + id: "fever/fever", + }, + ], + demo: { + inputs: [ + { + label: "Text Input", + content: "Dune is the best movie ever.", + type: "text", + }, + { + label: "Candidate Labels", + content: "CINEMA, ART, MUSIC", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "CINEMA", + score: 0.9, + }, + { + label: "ART", + score: 0.1, + }, + { + label: "MUSIC", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [], + models: [ + { + description: "Powerful zero-shot text classification model.", + id: "facebook/bart-large-mnli", + }, + { + description: "Cutting-edge zero-shot multilingual text classification model.", + id: "MoritzLaurer/ModernBERT-large-zeroshot-v2.0", + }, + { + description: "Zero-shot text classification model that can be used for topic and sentiment classification.", + id: "knowledgator/gliclass-modern-base-v2.0-init", + }, + ], + spaces: [], + summary: + "Zero-shot text classification is a task in natural language processing where a model is trained on a set of labeled examples but is then able to classify new examples from previously unseen classes.", + widgetModels: ["facebook/bart-large-mnli"], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..aaae36f62661d9fd51dd4f6d4956aacc31d3a03a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts @@ -0,0 +1,55 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Classification inference + */ +export interface ZeroShotClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Zero Shot Classification + */ + parameters: ZeroShotClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Classification + */ +export interface ZeroShotClassificationParameters { + /** + * The set of possible class labels to classify the text into. + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the text + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + /** + * Whether multiple candidate labels can be true. If false, the scores are normalized such + * that the sum of the label likelihoods for each sequence is 1. If true, the labels are + * considered independent and probabilities are normalized for each candidate. + */ + multi_label?: boolean; + [property: string]: unknown; +} +export type ZeroShotClassificationOutput = ZeroShotClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Classification task + */ +export interface ZeroShotClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..c919eac7ed262d6b744dbf06acab124c3989aae2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/zero-shot-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Classification inference", + "title": "ZeroShotClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to classify", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Classification", + "$ref": "#/$defs/ZeroShotClassificationParameters" + } + }, + "$defs": { + "ZeroShotClassificationParameters": { + "title": "ZeroShotClassificationParameters", + "type": "object", + "properties": { + "candidate_labels": { + "type": "array", + "description": "The set of possible class labels to classify the text into.", + "items": { + "type": "string" + } + }, + "hypothesis_template": { + "type": "string", + "description": "The sentence used in conjunction with `candidate_labels` to attempt the text classification by replacing the placeholder with the candidate labels." + }, + "multi_label": { + "type": "boolean", + "description": "Whether multiple candidate labels can be true. If false, the scores are normalized such that the sum of the label likelihoods for each sequence is 1. If true, the labels are considered independent and probabilities are normalized for each candidate." + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..1b5ac0cc378da256645aef340709d0543482c522 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/zero-shot-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Classification task", + "title": "ZeroShotClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9cf273b299be7828ea2c75fd0da6f50d65c50029 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md @@ -0,0 +1,75 @@ +## About the Task + +Zero-shot image classification is a computer vision task to classify images into one of several classes, without any prior training or knowledge of the classes. + +Zero shot image classification works by transferring knowledge learnt during training of one model, to classify novel classes that was not present in the training data. So this is a variation of [transfer learning](https://www.youtube.com/watch?v=BqqfQnyjmgg). For instance, a model trained to differentiate cars from airplanes can be used to classify images of ships. + +The data in this learning paradigm consists of + +- Seen data - images and their corresponding labels +- Unseen data - only labels and no images +- Auxiliary information - additional information given to the model during training connecting the unseen and seen data. This can be in the form of textual description or word embeddings. + +## Use Cases + +### Image Retrieval + +Zero-shot learning resolves several challenges in image retrieval systems. For example, with the rapid growth of categories on the web, it is challenging to index images based on unseen categories. With zero-shot learning we can associate unseen categories to images by exploiting attributes to model the relationships among visual features and labels. + +### Action Recognition + +Action recognition is the task of identifying when a person in an image/video is performing a given action from a set of actions. If all the possible actions are not known beforehand, conventional deep learning models fail. With zero-shot learning, for a given domain of a set of actions, we can create a mapping connecting low-level features and a semantic description of auxiliary data to classify unknown classes of actions. + +## Task Variants + +You can contribute variants of this task [here](https://github.com/huggingface/hub-docs/blob/main/tasks/src/zero-shot-image-classification/about.md). + +## Inference + +The model can be loaded with the zero-shot-image-classification pipeline like so: + +```python +from transformers import pipeline +# More models in the model hub. +model_name = "openai/clip-vit-large-patch14-336" +classifier = pipeline("zero-shot-image-classification", model = model_name) +``` + +You can then use this pipeline to classify images into any of the class names you specify. You can specify more than two class labels too. + +```python +image_to_classify = "path_to_cat_and_dog_image.jpeg" +labels_for_classification = ["cat and dog", + "lion and cheetah", + "rabbit and lion"] +scores = classifier(image_to_classify, + candidate_labels = labels_for_classification) +``` + +The classifier would return a list of dictionaries after the inference which is stored in the variable `scores` in the code snippet above. Variable `scores` would look as follows: + +```python +[{'score': 0.9950482249259949, 'label': 'cat and dog'}, +{'score': 0.004863627254962921, 'label': 'rabbit and lion'}, +{'score': 8.816882473183796e-05, 'label': 'lion and cheetah'}] +``` + +The dictionary at the zeroth index of the list will contain the label with the highest score. + +```python +print(f"The highest score is {scores[0]['score']:.3f} for the label {scores[0]['label']}") +``` + +The output from the print statement above would look as follows: + +``` +The highest probability is 0.995 for the label cat and dog +``` + +## Useful Resources + +- [Zero-shot image classification task guide](https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification). +- [Image-text Similarity Search](https://huggingface.co/learn/cookbook/faiss_with_hf_datasets_and_clip) + +This page was made possible thanks to the efforts of [Shamima Hossain](https://huggingface.co/Shamima), [Haider Zaidi +](https://huggingface.co/chefhaider) and [Paarth Bhatnagar](https://huggingface.co/Paarth). diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae87eb4fa0fae8d42fca404ff15531f3417ea62c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts @@ -0,0 +1,88 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "", + id: "", + }, + ], + demo: { + inputs: [ + { + filename: "image-classification-input.jpeg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Cat", + score: 0.664, + }, + { + label: "Dog", + score: 0.329, + }, + { + label: "Bird", + score: 0.008, + }, + ], + }, + ], + }, + metrics: [ + { + description: "Computes the number of times the correct label appears in top K labels predicted", + id: "top-K accuracy", + }, + ], + models: [ + { + description: "Multilingual image classification model for 80 languages.", + id: "visheratin/mexma-siglip", + }, + { + description: "Strong zero-shot image classification model.", + id: "google/siglip2-base-patch16-224", + }, + { + description: "Robust zero-shot image classification model.", + id: "intfloat/mmE5-mllama-11b-instruct", + }, + { + description: "Powerful zero-shot image classification model supporting 94 languages.", + id: "jinaai/jina-clip-v2", + }, + { + description: "Strong image classification model for biomedical domain.", + id: "microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224", + }, + ], + spaces: [ + { + description: + "An application that leverages zero-shot image classification to find best captions to generate an image. ", + id: "pharma/CLIP-Interrogator", + }, + { + description: "An application to compare different zero-shot image classification models. ", + id: "merve/compare_clip_siglip", + }, + ], + summary: + "Zero-shot image classification is the task of classifying previously unseen classes during training of a model.", + widgetModels: ["google/siglip-so400m-patch14-224"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..a700bb4f30eb515c393aea91a2808c82e7e54388 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts @@ -0,0 +1,49 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Image Classification inference + */ +export interface ZeroShotImageClassificationInput { + /** + * The input image data to classify as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Image Classification + */ + parameters: ZeroShotImageClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Image Classification + */ +export interface ZeroShotImageClassificationParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the image + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + [property: string]: unknown; +} +export type ZeroShotImageClassificationOutput = ZeroShotImageClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Image Classification task + */ +export interface ZeroShotImageClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..7c3c413436c6354cca1ddd2bd6b516309ac3fa72 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json @@ -0,0 +1,39 @@ +{ + "$id": "/inference/schemas/zero-shot-image-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Image Classification inference", + "title": "ZeroShotImageClassificationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data to classify as a base64-encoded string.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Image Classification", + "$ref": "#/$defs/ZeroShotImageClassificationParameters" + } + }, + "$defs": { + "ZeroShotImageClassificationParameters": { + "title": "ZeroShotImageClassificationParameters", + "type": "object", + "properties": { + "candidate_labels": { + "description": "The candidate labels for this image", + "type": "array", + "items": { + "type": "string" + } + }, + "hypothesis_template": { + "type": "string", + "description": "The sentence used in conjunction with `candidate_labels` to attempt the image classification by replacing the placeholder with the candidate labels." + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..6b795fbdbae8b566845fb424f30a7d7908609358 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json @@ -0,0 +1,10 @@ +{ + "$id": "/inference/schemas/zero-shot-image-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Image Classification task", + "title": "ZeroShotImageClassificationOutput", + "type": "array", + "items": { + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..46c4bf7c169fc3664b89d6b1243b47d9b4cdc7aa --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md @@ -0,0 +1,45 @@ +## Use Cases + +Zero-shot object detection models can be used in any object detection application where the detection involves text queries for objects of interest. + +### Object Search + +Zero-shot object detection models can be used in image search. Smartphones, for example, use zero-shot object detection models to detect entities (such as specific places or objects) and allow the user to search for the entity on the internet. + +### Object Counting + +Zero-shot object detection models are used to count instances of objects in a given image. This can include counting the objects in warehouses or stores or the number of visitors in a store. They are also used to manage crowds at events to prevent disasters. + +### Object Tracking + +Zero-shot object detectors can track objects in videos. + +## Inference + +You can infer with zero-shot object detection models through the `zero-shot-object-detection` pipeline. When calling the pipeline, you just need to specify a path or HTTP link to an image and the candidate labels. + +```python +from transformers import pipeline +from PIL import Image + +image = Image.open("my-image.png").convert("RGB") + +detector = pipeline(model="google/owlvit-base-patch32", task="zero-shot-object-detection") + +predictions = detector( + image, + candidate_labels=["a photo of a cat", "a photo of a dog"], +) + +# [{'score': 0.95, +# 'label': 'a photo of a cat', +# 'box': {'xmin': 180, 'ymin': 71, 'xmax': 271, 'ymax': 178}}, +# ... +# ] +``` + +# Useful Resources + +- [Zero-shot object detection task guide](https://huggingface.co/docs/transformers/tasks/zero_shot_object_detection) + +This page was made possible thanks to the efforts of [Victor Guichard](https://huggingface.co/VictorGuichard) diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..705bbdeceaa10a04dd1f9232881b0a263ad0219a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts @@ -0,0 +1,67 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "zero-shot-object-detection-input.jpg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + filename: "zero-shot-object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid zero-shot object detection model.", + id: "openmmlab-community/mm_grounding_dino_large_all", + }, + { + description: "Cutting-edge zero-shot object detection model.", + id: "fushh7/LLMDet", + }, + ], + spaces: [ + { + description: "A demo to compare different zero-shot object detection models per output and latency.", + id: "ariG23498/zero-shot-od", + }, + { + description: + "A demo that combines a zero-shot object detection and mask generation model for zero-shot segmentation.", + id: "merve/OWLSAM", + }, + ], + summary: + "Zero-shot object detection is a computer vision task to detect objects and their classes in images, without any prior training or knowledge of the classes. Zero-shot object detection models receive an image as input, as well as a list of candidate classes, and output the bounding boxes and labels where the objects have been detected.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5ae3eb1ac8a5f6832ed098d9e80ecb2f21b41eb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Object Detection inference + */ +export interface ZeroShotObjectDetectionInput { + /** + * The input image data as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Object Detection + */ + parameters: ZeroShotObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Object Detection + */ +export interface ZeroShotObjectDetectionParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + xmax: number; + xmin: number; + ymax: number; + ymin: number; + [property: string]: unknown; +} +export type ZeroShotObjectDetectionOutput = ZeroShotObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Zero Shot Object Detection task + */ +export interface ZeroShotObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * A candidate label + */ + label: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..7e6264dee50a44b8e93a261ed96a3bb4c4f0a37d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json @@ -0,0 +1,35 @@ +{ + "$id": "/inference/schemas/zero-shot-object-detection/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Object Detection inference", + "title": "ZeroShotObjectDetectionInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input image data as a base64-encoded string.", + "type": "string", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Object Detection", + "$ref": "#/$defs/ZeroShotObjectDetectionParameters" + } + }, + "$defs": { + "ZeroShotObjectDetectionParameters": { + "title": "ZeroShotObjectDetectionParameters", + "type": "object", + "properties": { + "candidate_labels": { + "description": "The candidate labels for this image", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8afa6052769f617ae365348d4d560ee43095ae4a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json @@ -0,0 +1,47 @@ +{ + "$id": "/inference/schemas/zero-shot-object-detection/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Object Detection task", + "title": "ZeroShotObjectDetectionOutput", + "type": "array", + "items": { + "type": "object", + "title": "ZeroShotObjectDetectionOutputElement", + "properties": { + "label": { + "type": "string", + "description": "A candidate label" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + }, + "box": { + "$ref": "#/$defs/BoundingBox", + "description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image." + } + }, + "required": ["box", "label", "score"] + }, + "$defs": { + "BoundingBox": { + "title": "BoundingBox", + "type": "object", + "properties": { + "xmin": { + "type": "integer" + }, + "xmax": { + "type": "integer" + }, + "ymin": { + "type": "integer" + }, + "ymax": { + "type": "integer" + } + }, + "required": ["xmin", "xmax", "ymin", "ymax"] + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tokenizer-data.ts b/node_modules/@huggingface/tasks/src/tokenizer-data.ts new file mode 100644 index 0000000000000000000000000000000000000000..6be41e8f60df763bf854feea8ca8ed689794a609 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tokenizer-data.ts @@ -0,0 +1,32 @@ +export const SPECIAL_TOKENS_ATTRIBUTES = [ + "bos_token", + "eos_token", + "unk_token", + "sep_token", + "pad_token", + "cls_token", + "mask_token", + // additional_special_tokens (TODO) +] as const; + +/** + * Public interface for a tokenizer's special tokens mapping + */ +export interface AddedToken { + __type: "AddedToken"; + content?: string; + lstrip?: boolean; + normalized?: boolean; + rstrip?: boolean; + single_word?: boolean; +} +export type SpecialTokensMap = { + [key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken | null; +}; +/** + * Public interface for tokenizer config + */ +export interface TokenizerConfig extends SpecialTokensMap { + use_default_system_prompt?: boolean; + chat_template?: string | Array<{ name: string; template: string }>; +} diff --git a/node_modules/@huggingface/tasks/src/widget-example.ts b/node_modules/@huggingface/tasks/src/widget-example.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f60cd76bc9e314f037acca747af2c5c1d3cf35c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/widget-example.ts @@ -0,0 +1,128 @@ +/** + * See default-widget-inputs.ts for the default widget inputs, this files only contains the types + */ + +import type { ChatCompletionInputMessage } from "./tasks/index.js"; + +type TableData = Record; + +//#region outputs +export type WidgetExampleOutputLabels = Array<{ label: string; score: number }>; +export interface WidgetExampleOutputAnswerScore { + answer: string; + score: number; +} +export interface WidgetExampleOutputText { + text: string; +} +export interface WidgetExampleOutputUrl { + url: string; +} + +export type WidgetExampleOutput = + | WidgetExampleOutputLabels + | WidgetExampleOutputAnswerScore + | WidgetExampleOutputText + | WidgetExampleOutputUrl; +//#endregion + +export interface WidgetExampleBase { + example_title?: string; + group?: string; + /** + * Potential overrides to API parameters for this specific example + * (takes precedences over the model card metadata's inference.parameters) + */ + parameters?: { + /// token-classification + aggregation_strategy?: string; + /// text-generation + top_k?: number; + top_p?: number; + temperature?: number; + max_new_tokens?: number; + do_sample?: boolean; + /// text-to-image + negative_prompt?: string; + guidance_scale?: number; + num_inference_steps?: number; + }; + /** + * Optional output + */ + output?: TOutput; +} + +export interface WidgetExampleChatInput extends WidgetExampleBase { + messages: ChatCompletionInputMessage[]; +} + +export interface WidgetExampleTextInput extends WidgetExampleBase { + text: string; +} + +export interface WidgetExampleTextAndContextInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleTextInput { + context: string; +} + +export interface WidgetExampleTextAndTableInput extends WidgetExampleTextInput { + table: TableData; +} + +export interface WidgetExampleAssetInput extends WidgetExampleBase { + src: string; +} +export interface WidgetExampleAssetAndPromptInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleAssetInput { + prompt: string; +} + +export type WidgetExampleAssetAndTextInput = WidgetExampleAssetInput & + WidgetExampleTextInput; + +export type WidgetExampleAssetAndZeroShotInput = WidgetExampleAssetInput & + WidgetExampleZeroShotTextInput; + +export interface WidgetExampleStructuredDataInput extends WidgetExampleBase { + structured_data: TableData; +} + +export interface WidgetExampleTableDataInput extends WidgetExampleBase { + table: TableData; +} + +export interface WidgetExampleZeroShotTextInput extends WidgetExampleTextInput { + text: string; + candidate_labels: string; + multi_class: boolean; +} + +export interface WidgetExampleSentenceSimilarityInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleBase { + source_sentence: string; + sentences: string[]; +} + +//#endregion + +export type WidgetExample = + | WidgetExampleChatInput + | WidgetExampleTextInput + | WidgetExampleTextAndContextInput + | WidgetExampleTextAndTableInput + | WidgetExampleAssetInput + | WidgetExampleAssetAndPromptInput + | WidgetExampleAssetAndTextInput + | WidgetExampleAssetAndZeroShotInput + | WidgetExampleStructuredDataInput + | WidgetExampleTableDataInput + | WidgetExampleZeroShotTextInput + | WidgetExampleSentenceSimilarityInput; + +type KeysOfUnion = T extends unknown ? keyof T : never; + +export type WidgetExampleAttribute = KeysOfUnion; diff --git a/node_modules/@huggingface/tasks/tsconfig.json b/node_modules/@huggingface/tasks/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3e3c571e5e55e7e4df25af4ea1e4565e19969231 --- /dev/null +++ b/node_modules/@huggingface/tasks/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "lib": ["ES2022", "DOM"], + "module": "NodeNext", + "target": "ESNext", + "moduleResolution": "nodenext", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "skipLibCheck": true, + "noImplicitOverride": true, + "outDir": "./dist", + "declaration": true, + "declarationMap": true + }, + "include": ["src"], + "exclude": ["dist"] +} diff --git a/node_modules/@jridgewell/gen-mapping/LICENSE b/node_modules/@jridgewell/gen-mapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/gen-mapping/README.md b/node_modules/@jridgewell/gen-mapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..93692b10655a33f4bb4f37c28a576edf83b0c8e2 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/README.md @@ -0,0 +1,227 @@ +# @jridgewell/gen-mapping + +> Generate source maps + +`gen-mapping` allows you to generate a source map during transpilation or minification. +With a source map, you're able to trace the original location in the source file, either in Chrome's +DevTools or using a library like [`@jridgewell/trace-mapping`][trace-mapping]. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapGenerator`. This +provides the same `addMapping` and `setSourceContent` API. + +## Installation + +```sh +npm install @jridgewell/gen-mapping +``` + +## Usage + +```typescript +import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping'; + +const map = new GenMapping({ + file: 'output.js', + sourceRoot: 'https://example.com/', +}); + +setSourceContent(map, 'input.js', `function foo() {}`); + +addMapping(map, { + // Lines start at line 1, columns at column 0. + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +addMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 9 }, + name: 'foo', +}); + +assert.deepEqual(toDecodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: [ + [ [0, 0, 0, 0], [9, 0, 0, 9, 0] ] + ], +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: 'AAAA,SAASA', +}); +``` + +### Smaller Sourcemaps + +Not everything needs to be added to a sourcemap, and needless markings can cause signficantly +larger file sizes. `gen-mapping` exposes `maybeAddSegment`/`maybeAddMapping` APIs that will +intelligently determine if this marking adds useful information. If not, the marking will be +skipped. + +```typescript +import { maybeAddMapping } from '@jridgewell/gen-mapping'; + +const map = new GenMapping(); + +// Adding a sourceless marking at the beginning of a line isn't useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, +}); + +// Adding a new source marking is useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +// But adding another marking pointing to the exact same original location isn't, even if the +// generated column changed. +maybeAddMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + names: [], + sources: ['input.js'], + sourcesContent: [null], + mappings: 'AAAA', +}); +``` + +## Benchmarks + +``` +node v18.0.0 + +amp.js.map +Memory Usage: +gen-mapping: addSegment 5852872 bytes +gen-mapping: addMapping 7716042 bytes +source-map-js 6143250 bytes +source-map-0.6.1 6124102 bytes +source-map-0.8.0 6121173 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 441 ops/sec ±2.07% (90 runs sampled) +gen-mapping: addMapping x 350 ops/sec ±2.40% (86 runs sampled) +source-map-js: addMapping x 169 ops/sec ±2.42% (80 runs sampled) +source-map-0.6.1: addMapping x 167 ops/sec ±2.56% (80 runs sampled) +source-map-0.8.0: addMapping x 168 ops/sec ±2.52% (80 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 150,824,370 ops/sec ±0.07% (102 runs sampled) +gen-mapping: encoded output x 663 ops/sec ±0.22% (98 runs sampled) +source-map-js: encoded output x 197 ops/sec ±0.45% (84 runs sampled) +source-map-0.6.1: encoded output x 198 ops/sec ±0.33% (85 runs sampled) +source-map-0.8.0: encoded output x 197 ops/sec ±0.06% (93 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +babel.min.js.map +Memory Usage: +gen-mapping: addSegment 37578063 bytes +gen-mapping: addMapping 37212897 bytes +source-map-js 47638527 bytes +source-map-0.6.1 47690503 bytes +source-map-0.8.0 47470188 bytes +Smallest memory usage is gen-mapping: addMapping + +Adding speed: +gen-mapping: addSegment x 31.05 ops/sec ±8.31% (43 runs sampled) +gen-mapping: addMapping x 29.83 ops/sec ±7.36% (51 runs sampled) +source-map-js: addMapping x 20.73 ops/sec ±6.22% (38 runs sampled) +source-map-0.6.1: addMapping x 20.03 ops/sec ±10.51% (38 runs sampled) +source-map-0.8.0: addMapping x 19.30 ops/sec ±8.27% (37 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 381,379,234 ops/sec ±0.29% (96 runs sampled) +gen-mapping: encoded output x 95.15 ops/sec ±2.98% (72 runs sampled) +source-map-js: encoded output x 15.20 ops/sec ±7.41% (33 runs sampled) +source-map-0.6.1: encoded output x 16.36 ops/sec ±10.46% (31 runs sampled) +source-map-0.8.0: encoded output x 16.06 ops/sec ±6.45% (31 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +preact.js.map +Memory Usage: +gen-mapping: addSegment 416247 bytes +gen-mapping: addMapping 419824 bytes +source-map-js 1024619 bytes +source-map-0.6.1 1146004 bytes +source-map-0.8.0 1113250 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 13,755 ops/sec ±0.15% (98 runs sampled) +gen-mapping: addMapping x 13,013 ops/sec ±0.11% (101 runs sampled) +source-map-js: addMapping x 4,564 ops/sec ±0.21% (98 runs sampled) +source-map-0.6.1: addMapping x 4,562 ops/sec ±0.11% (99 runs sampled) +source-map-0.8.0: addMapping x 4,593 ops/sec ±0.11% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,864,020 ops/sec ±0.23% (93 runs sampled) +gen-mapping: encoded output x 14,368 ops/sec ±4.07% (82 runs sampled) +source-map-js: encoded output x 5,261 ops/sec ±0.21% (99 runs sampled) +source-map-0.6.1: encoded output x 5,124 ops/sec ±0.58% (99 runs sampled) +source-map-0.8.0: encoded output x 5,434 ops/sec ±0.33% (96 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +react.js.map +Memory Usage: +gen-mapping: addSegment 975096 bytes +gen-mapping: addMapping 1102981 bytes +source-map-js 2918836 bytes +source-map-0.6.1 2885435 bytes +source-map-0.8.0 2874336 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 4,772 ops/sec ±0.15% (100 runs sampled) +gen-mapping: addMapping x 4,456 ops/sec ±0.13% (97 runs sampled) +source-map-js: addMapping x 1,618 ops/sec ±0.24% (97 runs sampled) +source-map-0.6.1: addMapping x 1,622 ops/sec ±0.12% (99 runs sampled) +source-map-0.8.0: addMapping x 1,631 ops/sec ±0.12% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,107,695 ops/sec ±0.07% (99 runs sampled) +gen-mapping: encoded output x 5,421 ops/sec ±1.60% (89 runs sampled) +source-map-js: encoded output x 2,113 ops/sec ±1.81% (98 runs sampled) +source-map-0.6.1: encoded output x 2,126 ops/sec ±0.10% (100 runs sampled) +source-map-0.8.0: encoded output x 2,176 ops/sec ±0.39% (98 runs sampled) +Fastest is gen-mapping: decoded output +``` + +[source-map]: https://www.npmjs.com/package/source-map +[trace-mapping]: https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bbb0cacc5a77ef06b4a9921fe075914135d80f0f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs @@ -0,0 +1,292 @@ +// src/set-array.ts +var SetArray = class { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } +}; +function cast(set) { + return set; +} +function get(setarr, key) { + return cast(setarr)._indexes[key]; +} +function put(setarr, key) { + const index = get(setarr, key); + if (index !== void 0) return index; + const { array, _indexes: indexes } = cast(setarr); + const length = array.push(key); + return indexes[key] = length - 1; +} +function remove(setarr, key) { + const index = get(setarr, key); + if (index === void 0) return; + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]--; + } + indexes[key] = void 0; + array.pop(); +} + +// src/gen-mapping.ts +import { + encode +} from "@jridgewell/sourcemap-codec"; +import { TraceMap, decodedMappings } from "@jridgewell/trace-mapping"; + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; + +// src/gen-mapping.ts +var NO_NAME = -1; +var GenMapping = class { + constructor({ file, sourceRoot } = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +}; +function cast2(map) { + return map; +} +function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +} +function addMapping(map, mapping) { + return addMappingInternal(false, map, mapping); +} +var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +}; +var maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); +}; +function setSourceContent(map, source, content) { + const { + _sources: sources, + _sourcesContent: sourcesContent + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + sourcesContent[index] = content; +} +function setIgnore(map, source, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} +function toDecodedMap(map) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast2(map); + removeEmptyFinalLines(mappings); + return { + version: 3, + file: map.file || void 0, + names: names.array, + sourceRoot: map.sourceRoot || void 0, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array + }; +} +function toEncodedMap(map) { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: encode(decoded.mappings) + }); +} +function fromMap(input) { + const map = new TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(cast2(gen)._names, map.names); + putAll(cast2(gen)._sources, map.sources); + cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast2(gen)._mappings = decodedMappings(map); + if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList); + return gen; +} +function allMappings(map) { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast2(map); + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = void 0; + let original = void 0; + let name = void 0; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; +} +function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names + // _originalScopes: originalScopes, + } = cast2(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + assert(sourceLine); + assert(sourceColumn); + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert( + line, + index, + name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn] + ); +} +function assert(_val) { +} +function getIndex(arr, index) { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} +function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} +function putAll(setarr, array) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} +function skipSourceless(line, index) { + if (index === 0) return true; + const prev = line[index - 1]; + return prev.length === 1; +} +function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + if (index === 0) return false; + const prev = line[index - 1]; + if (prev.length === 1) return false; + return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME); +} +function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source, + original.line - 1, + original.column, + name, + content + ); +} +export { + GenMapping, + addMapping, + addSegment, + allMappings, + fromMap, + maybeAddMapping, + maybeAddSegment, + setIgnore, + setSourceContent, + toDecodedMap, + toEncodedMap +}; +//# sourceMappingURL=gen-mapping.mjs.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..4e37e457b383d40504afea5419ff2b20afd0eb85 --- /dev/null +++ b/node_modules/@jridgew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ACP,MACA,OACA,cACA,YACA,cACA,YACS;AAET,MAAI,UAAU,EAAG,QAAO;AAExB,QAAM,OAAO,KAAK,QAAQ,CAAC;AAG3B,MAAI,KAAK,WAAW,EAAG,QAAO;AAI9B,SACE,iBAAiB,KAAK,aAAa,KACnC,eAAe,KAAK,WAAW,KAC/B,iBAAiB,KAAK,aAAa,KACnC,gBAAgB,KAAK,WAAW,IAAI,KAAK,WAAW,IAAI;AAE5D;AAEA,SAAS,mBACP,UACA,KACA,SAOA;AACA,QAAM,EAAE,WAAW,QAAQ,UAAU,MAAM,QAAQ,IAAI;AACvD,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAY,QAAQ;AACpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,UAAU;AAAA,IACV;AAAA,IACA,SAAS,OAAO;AAAA,IAChB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;", + "names": ["cast"] +} diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..cb84af55fb03a9f4c966be7f375a4a151bb8c6c2 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js @@ -0,0 +1,358 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.sourcemapCodec, global.traceMapping); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.genMapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_sourcemapCodec, require_traceMapping) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/sourcemap-codec +var require_sourcemap_codec = __commonJS({ + "umd:@jridgewell/sourcemap-codec"(exports, module2) { + module2.exports = require_sourcemapCodec; + } +}); + +// umd:@jridgewell/trace-mapping +var require_trace_mapping = __commonJS({ + "umd:@jridgewell/trace-mapping"(exports, module2) { + module2.exports = require_traceMapping; + } +}); + +// src/gen-mapping.ts +var gen_mapping_exports = {}; +__export(gen_mapping_exports, { + GenMapping: () => GenMapping, + addMapping: () => addMapping, + addSegment: () => addSegment, + allMappings: () => allMappings, + fromMap: () => fromMap, + maybeAddMapping: () => maybeAddMapping, + maybeAddSegment: () => maybeAddSegment, + setIgnore: () => setIgnore, + setSourceContent: () => setSourceContent, + toDecodedMap: () => toDecodedMap, + toEncodedMap: () => toEncodedMap +}); +module.exports = __toCommonJS(gen_mapping_exports); + +// src/set-array.ts +var SetArray = class { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } +}; +function cast(set) { + return set; +} +function get(setarr, key) { + return cast(setarr)._indexes[key]; +} +function put(setarr, key) { + const index = get(setarr, key); + if (index !== void 0) return index; + const { array, _indexes: indexes } = cast(setarr); + const length = array.push(key); + return indexes[key] = length - 1; +} +function remove(setarr, key) { + const index = get(setarr, key); + if (index === void 0) return; + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]--; + } + indexes[key] = void 0; + array.pop(); +} + +// src/gen-mapping.ts +var import_sourcemap_codec = __toESM(require_sourcemap_codec()); +var import_trace_mapping = __toESM(require_trace_mapping()); + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; + +// src/gen-mapping.ts +var NO_NAME = -1; +var GenMapping = class { + constructor({ file, sourceRoot } = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +}; +function cast2(map) { + return map; +} +function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +} +function addMapping(map, mapping) { + return addMappingInternal(false, map, mapping); +} +var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +}; +var maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); +}; +function setSourceContent(map, source, content) { + const { + _sources: sources, + _sourcesContent: sourcesContent + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + sourcesContent[index] = content; +} +function setIgnore(map, source, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} +function toDecodedMap(map) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast2(map); + removeEmptyFinalLines(mappings); + return { + version: 3, + file: map.file || void 0, + names: names.array, + sourceRoot: map.sourceRoot || void 0, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array + }; +} +function toEncodedMap(map) { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: (0, import_sourcemap_codec.encode)(decoded.mappings) + }); +} +function fromMap(input) { + const map = new import_trace_mapping.TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(cast2(gen)._names, map.names); + putAll(cast2(gen)._sources, map.sources); + cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast2(gen)._mappings = (0, import_trace_mapping.decodedMappings)(map); + if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList); + return gen; +} +function allMappings(map) { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast2(map); + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = void 0; + let original = void 0; + let name = void 0; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; +} +function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names + // _originalScopes: originalScopes, + } = cast2(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + assert(sourceLine); + assert(sourceColumn); + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert( + line, + index, + name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn] + ); +} +function assert(_val) { +} +function getIndex(arr, index) { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} +function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} +function putAll(setarr, array) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} +function skipSourceless(line, index) { + if (index === 0) return true; + const prev = line[index - 1]; + return prev.length === 1; +} +function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + if (index === 0) return false; + const prev = line[index - 1]; + if (prev.length === 1) return false; + return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME); +} +function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source, + original.line - 1, + original.column, + name, + content + ); +} +})); +//# sourceMappingURL=gen-mapping.umd.js.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b13750bf67818b051645f7c332594e3cf7786375 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/sourcemap-codec", "umd:@jridgewell/trace-mapping", "../src/gen-mapping.ts", "../src/set-array.ts", "../src/sourcemap-segment.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,6CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,2CAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUO,IAAM,WAAN,MAAoC;AAAA,EAIzC,cAAc;AACZ,SAAK,WAAW,EAAE,WAAW,KAAK;AAClC,SAAK,QAAQ,CAAC;AAAA,EAChB;AACF;AAWA,SAAS,KAAoB,KAAg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ACA,KACA,SAOA;AACA,QAAM,EAAE,WAAW,QAAQ,UAAU,MAAM,QAAQ,IAAI;AACvD,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAY,QAAQ;AACpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,UAAU;AAAA,IACV;AAAA,IACA,SAAS,OAAO;AAAA,IAChB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;", + "names": ["module", "module", "cast"] +} diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ba936e82bcf799e9d42bdb5ecd3ef11e978189e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts @@ -0,0 +1,88 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ed43543e9c70b62a90af8dfe05c9e470532e083 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts @@ -0,0 +1,32 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa19fb5e72da1d12d3484c44b13daa608cece5ba --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts @@ -0,0 +1,12 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8eb90fb47477b1e82336ff79f6caaab4722b38d7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts @@ -0,0 +1,43 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; diff --git a/node_modules/@jridgewell/gen-mapping/package.json b/node_modules/@jridgewell/gen-mapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..036f9b799d93aca59d80244410216583eda2d97b --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/package.json @@ -0,0 +1,67 @@ +{ + "name": "@jridgewell/gen-mapping", + "version": "0.3.13", + "description": "Generate source maps", + "keywords": [ + "source", + "map" + ], + "main": "dist/gen-mapping.umd.js", + "module": "dist/gen-mapping.mjs", + "types": "types/gen-mapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/gen-mapping.d.mts", + "default": "./dist/gen-mapping.mjs" + }, + "default": { + "types": "./types/gen-mapping.d.cts", + "default": "./dist/gen-mapping.umd.js" + } + }, + "./dist/gen-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs gen-mapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/gen-mapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/gen-mapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } +} diff --git a/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts b/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..ecc878c5755eea6e252d31475e3c0f87817140e0 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts @@ -0,0 +1,614 @@ +import { SetArray, put, remove } from './set-array'; +import { + encode, + // encodeGeneratedRanges, + // encodeOriginalScopes +} from '@jridgewell/sourcemap-codec'; +import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping'; + +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, +} from './sourcemap-segment'; + +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +// import type { OriginalScope, GeneratedRange } from '@jridgewell/sourcemap-codec'; +import type { SourceMapSegment } from './sourcemap-segment'; +import type { + DecodedSourceMap, + EncodedSourceMap, + Pos, + Mapping, + // BindingExpressionRange, + // OriginalPos, + // OriginalScopeInfo, + // GeneratedRangeInfo, +} from './types'; + +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; + +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; + +const NO_NAME = -1; + +/** + * Provides the state to generate a sourcemap. + */ +export class GenMapping { + declare private _names: SetArray; + declare private _sources: SetArray; + declare private _sourcesContent: (string | null)[]; + declare private _mappings: SourceMapSegment[][]; + // private declare _originalScopes: OriginalScope[][]; + // private declare _generatedRanges: GeneratedRange[]; + declare private _ignoreList: SetArray; + declare file: string | null | undefined; + declare sourceRoot: string | null | undefined; + + constructor({ file, sourceRoot }: Options = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + // this._originalScopes = []; + // this._generatedRanges = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +} + +interface PublicMap { + _names: GenMapping['_names']; + _sources: GenMapping['_sources']; + _sourcesContent: GenMapping['_sourcesContent']; + _mappings: GenMapping['_mappings']; + // _originalScopes: GenMapping['_originalScopes']; + // _generatedRanges: GenMapping['_generatedRanges']; + _ignoreList: GenMapping['_ignoreList']; +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the map into a type + * with public access modifiers. + */ +function cast(map: unknown): PublicMap { + return map as any; +} + +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source?: null, + sourceLine?: null, + sourceColumn?: null, + name?: null, + content?: null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source: string, + sourceLine: number, + sourceColumn: number, + name?: null, + content?: string | null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source: string, + sourceLine: number, + sourceColumn: number, + name: string, + content?: string | null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source?: string | null, + sourceLine?: number | null, + sourceColumn?: number | null, + name?: string | null, + content?: string | null, +): void { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, + ); +} + +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source?: string | null; + original?: Pos | null; + name?: string | null; + content?: string | null; + }, +): void { + return addMappingInternal(false, map, mapping as Parameters[2]); +} + +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export const maybeAddSegment: typeof addSegment = ( + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, +) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, + ); +}; + +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export const maybeAddMapping: typeof addMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping as Parameters[2]); +}; + +/** + * Adds/removes the content of the source file to the source map. + */ +export function setSourceContent(map: GenMapping, source: string, content: string | null): void { + const { + _sources: sources, + _sourcesContent: sourcesContent, + // _originalScopes: originalScopes, + } = cast(map); + const index = put(sources, source); + sourcesContent[index] = content; + // if (index === originalScopes.length) originalScopes[index] = []; +} + +export function setIgnore(map: GenMapping, source: string, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList, + // _originalScopes: originalScopes, + } = cast(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + // if (index === originalScopes.length) originalScopes[index] = []; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} + +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function toDecodedMap(map: GenMapping): DecodedSourceMap { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList, + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast(map); + removeEmptyFinalLines(mappings); + + return { + version: 3, + file: map.file || undefined, + names: names.array, + sourceRoot: map.sourceRoot || undefined, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array, + }; +} + +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function toEncodedMap(map: GenMapping): EncodedSourceMap { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: encode(decoded.mappings as SourceMapSegment[][]), + }); +} + +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export function fromMap(input: SourceMapInput): GenMapping { + const map = new TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + + putAll(cast(gen)._names, map.names); + putAll(cast(gen)._sources, map.sources as string[]); + cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast(gen)._mappings = decodedMappings(map) as GenMapping['_mappings']; + // TODO: implement originalScopes/generatedRanges + if (map.ignoreList) putAll(cast(gen)._ignoreList, map.ignoreList); + + return gen; +} + +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export function allMappings(map: GenMapping): Mapping[] { + const out: Mapping[] = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast(map); + + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + + const generated = { line: i + 1, column: seg[COLUMN] }; + let source: string | undefined = undefined; + let original: Pos | undefined = undefined; + let name: string | undefined = undefined; + + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + + out.push({ generated, source, original, name } as Mapping); + } + } + + return out; +} + +// This split declaration is only so that terser can elminiate the static initialization block. +function addSegmentInternal( + skipable: boolean, + map: GenMapping, + genLine: number, + genColumn: number, + source: S, + sourceLine: S extends string ? number : null | undefined, + sourceColumn: S extends string ? number : null | undefined, + name: S extends string ? string | null | undefined : null | undefined, + content: S extends string ? string | null | undefined : null | undefined, +): void { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + // _originalScopes: originalScopes, + } = cast(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + + // Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source + // isn't nullish. + assert(sourceLine); + assert(sourceColumn); + + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null; + // if (sourcesIndex === originalScopes.length) originalScopes[sourcesIndex] = []; + + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + + return insert( + line, + index, + name + ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] + : [genColumn, sourcesIndex, sourceLine, sourceColumn], + ); +} + +function assert(_val: unknown): asserts _val is T { + // noop. +} + +function getIndex(arr: T[][], index: number): T[] { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} + +function getColumnIndex(line: SourceMapSegment[], genColumn: number): number { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} + +function insert(array: T[], index: number, value: T) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} + +function removeEmptyFinalLines(mappings: SourceMapSegment[][]) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} + +function putAll(setarr: SetArray, array: T[]) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} + +function skipSourceless(line: SourceMapSegment[], index: number): boolean { + // The start of a line is already sourceless, so adding a sourceless segment to the beginning + // doesn't generate any useful information. + if (index === 0) return true; + + const prev = line[index - 1]; + // If the previous segment is also sourceless, then adding another sourceless segment doesn't + // genrate any new information. Else, this segment will end the source/named segment and point to + // a sourceless position, which is useful. + return prev.length === 1; +} + +function skipSource( + line: SourceMapSegment[], + index: number, + sourcesIndex: number, + sourceLine: number, + sourceColumn: number, + namesIndex: number, +): boolean { + // A source/named segment at the start of a line gives position at that genColumn + if (index === 0) return false; + + const prev = line[index - 1]; + + // If the previous segment is sourceless, then we're transitioning to a source. + if (prev.length === 1) return false; + + // If the previous segment maps to the exact same source position, then this segment doesn't + // provide any new position information. + return ( + sourcesIndex === prev[SOURCES_INDEX] && + sourceLine === prev[SOURCE_LINE] && + sourceColumn === prev[SOURCE_COLUMN] && + namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME) + ); +} + +function addMappingInternal( + skipable: boolean, + map: GenMapping, + mapping: { + generated: Pos; + source: S; + original: S extends string ? Pos : null | undefined; + name: S extends string ? string | null | undefined : null | undefined; + content: S extends string ? string | null | undefined : null | undefined; + }, +) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null, + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source as string, + original.line - 1, + original.column, + name, + content, + ); +} + +/* +export function addOriginalScope( + map: GenMapping, + data: { + start: Pos; + end: Pos; + source: string; + kind: string; + name?: string; + variables?: string[]; + }, +): OriginalScopeInfo { + const { start, end, source, kind, name, variables } = data; + const { + _sources: sources, + _sourcesContent: sourcesContent, + _originalScopes: originalScopes, + _names: names, + } = cast(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (index === originalScopes.length) originalScopes[index] = []; + + const kindIndex = put(names, kind); + const scope: OriginalScope = name + ? [start.line - 1, start.column, end.line - 1, end.column, kindIndex, put(names, name)] + : [start.line - 1, start.column, end.line - 1, end.column, kindIndex]; + if (variables) { + scope.vars = variables.map((v) => put(names, v)); + } + const len = originalScopes[index].push(scope); + return [index, len - 1, variables]; +} +*/ + +// Generated Ranges +/* +export function addGeneratedRange( + map: GenMapping, + data: { + start: Pos; + isScope: boolean; + originalScope?: OriginalScopeInfo; + callsite?: OriginalPos; + }, +): GeneratedRangeInfo { + const { start, isScope, originalScope, callsite } = data; + const { + _originalScopes: originalScopes, + _sources: sources, + _sourcesContent: sourcesContent, + _generatedRanges: generatedRanges, + } = cast(map); + + const range: GeneratedRange = [ + start.line - 1, + start.column, + 0, + 0, + originalScope ? originalScope[0] : -1, + originalScope ? originalScope[1] : -1, + ]; + if (originalScope?.[2]) { + range.bindings = originalScope[2].map(() => [[-1]]); + } + if (callsite) { + const index = put(sources, callsite.source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (index === originalScopes.length) originalScopes[index] = []; + range.callsite = [index, callsite.line - 1, callsite.column]; + } + if (isScope) range.isScope = true; + generatedRanges.push(range); + + return [range, originalScope?.[2]]; +} + +export function setEndPosition(range: GeneratedRangeInfo, pos: Pos) { + range[0][2] = pos.line - 1; + range[0][3] = pos.column; +} + +export function addBinding( + map: GenMapping, + range: GeneratedRangeInfo, + variable: string, + expression: string | BindingExpressionRange, +) { + const { _names: names } = cast(map); + const bindings = (range[0].bindings ||= []); + const vars = range[1]; + + const index = vars!.indexOf(variable); + const binding = getIndex(bindings, index); + + if (typeof expression === 'string') binding[0] = [put(names, expression)]; + else { + const { start } = expression; + binding.push([put(names, expression.expression), start.line - 1, start.column]); + } +} +*/ diff --git a/node_modules/@jridgewell/gen-mapping/src/set-array.ts b/node_modules/@jridgewell/gen-mapping/src/set-array.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2a73a5229e176a34a4bb418bd1189999731b7a1 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/set-array.ts @@ -0,0 +1,82 @@ +type Key = string | number | symbol; + +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export class SetArray { + declare private _indexes: Record; + declare array: readonly T[]; + + constructor() { + this._indexes = { __proto__: null } as any; + this.array = []; + } +} + +interface PublicSet { + array: T[]; + _indexes: SetArray['_indexes']; +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the set into a type + * with public access modifiers. + */ +function cast(set: SetArray): PublicSet { + return set as any; +} + +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export function get(setarr: SetArray, key: T): number | undefined { + return cast(setarr)._indexes[key]; +} + +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export function put(setarr: SetArray, key: T): number { + // The key may or may not be present. If it is present, it's a number. + const index = get(setarr, key); + if (index !== undefined) return index; + + const { array, _indexes: indexes } = cast(setarr); + + const length = array.push(key); + return (indexes[key] = length - 1); +} + +/** + * Pops the last added item out of the SetArray. + */ +export function pop(setarr: SetArray): void { + const { array, _indexes: indexes } = cast(setarr); + if (array.length === 0) return; + + const last = array.pop()!; + indexes[last] = undefined; +} + +/** + * Removes the key, if it exists in the set. + */ +export function remove(setarr: SetArray, key: T): void { + const index = get(setarr, key); + if (index === undefined) return; + + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]!--; + } + indexes[key] = undefined; + array.pop(); +} diff --git a/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts b/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb296dd30234bc61899000bbcc706e71765264c8 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts @@ -0,0 +1,16 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; + +export type SourceMapSegment = + | [GeneratedColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; + +export const COLUMN = 0; +export const SOURCES_INDEX = 1; +export const SOURCE_LINE = 2; +export const SOURCE_COLUMN = 3; +export const NAMES_INDEX = 4; diff --git a/node_modules/@jridgewell/gen-mapping/src/types.ts b/node_modules/@jridgewell/gen-mapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b087f706a0394e6f8921e92a9c005c3c6ac13de0 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/types.ts @@ -0,0 +1,61 @@ +// import type { GeneratedRange, OriginalScope } from '@jridgewell/sourcemap-codec'; +import type { SourceMapSegment } from './sourcemap-segment'; + +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} + +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; + // originalScopes: string[]; + // generatedRanges: string; +} + +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; + // originalScopes: readonly OriginalScope[][]; + // generatedRanges: readonly GeneratedRange[]; +} + +export interface Pos { + line: number; // 1-based + column: number; // 0-based +} + +export interface OriginalPos extends Pos { + source: string; +} + +export interface BindingExpressionRange { + start: Pos; + expression: string; +} + +// export type OriginalScopeInfo = [number, number, string[] | undefined]; +// export type GeneratedRangeInfo = [GeneratedRange, string[] | undefined]; + +export type Mapping = + | { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; + } + | { + generated: Pos; + source: string; + original: Pos; + name: string; + } + | { + generated: Pos; + source: string; + original: Pos; + name: undefined; + }; diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..7618d8572b325324ccde88eb0a046a0bed73626e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts @@ -0,0 +1,89 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.cts'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; +//# sourceMappingURL=gen-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a2b1835336445da0c96f2785ce5b8625a3af4c7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAA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AAgB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAO,QAYvE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAwB9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAO9D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAYzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,EAAE,CA0BtD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bbc0d89cfd861c2c66cdb2458956c013bd59508e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts @@ -0,0 +1,89 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.mts'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; +//# sourceMappingURL=gen-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a2b1835336445da0c96f2785ce5b8625a3af4c7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,OAAO,EAKR,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;AAE5D,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAIF;;GAEG;AACH,qBAAa,UAAU;IACrB,QAAgB,MAAM,CAAmB;IACzC,QAAgB,QAAQ,CAAmB;IAC3C,QAAgB,eAAe,CAAoB;IACnD,QAAgB,SAAS,CAAuB;IAGhD,QAAgB,WAAW,CAAmB;IACtC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;gBAElC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAE,OAAY;CAW/C;AAoBD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,IAAI,EACb,UAAU,CAAC,EAAE,IAAI,EACjB,YAAY,CAAC,EAAE,IAAI,EACnB,IAAI,CAAC,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,IAAI,GACb,IAAI,CAAC;AACR,wBAAgB,UAAU,CACxB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,M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AAe,EAAE,OAAO,UAEpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAS9F;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAO,QAYvE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAwB9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAO9D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAYzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,EAAE,CA0BtD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5d8cda35a7e698625549fc38e9d89a6c7e89fadf --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts @@ -0,0 +1,33 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; +//# sourceMappingURL=set-array.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..c52b8bcee0042015be193c19481001d8e8fbd01f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5d8cda35a7e698625549fc38e9d89a6c7e89fadf --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts @@ -0,0 +1,33 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; +//# sourceMappingURL=set-array.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..c52b8bcee0042015be193c19481001d8e8fbd01f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..68862952d54b0caba765fcd7c04f64bed329756d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts @@ -0,0 +1,13 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..23cdc45288829ff39c538527202d24649c8a78ff --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..68862952d54b0caba765fcd7c04f64bed329756d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts @@ -0,0 +1,13 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..23cdc45288829ff39c538527202d24649c8a78ff --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.cts b/node_modules/@jridgewell/gen-mapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..58da00a9fb250d52be96d60c70ee7ccdd1cd0deb --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.cts @@ -0,0 +1,44 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..159e734d5f994f5ed32fcdc1640096994dc12d72 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.mts b/node_modules/@jridgewell/gen-mapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e9837ebe53aa653a2a295e60069813f47e456fc3 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.mts @@ -0,0 +1,44 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..159e734d5f994f5ed32fcdc1640096994dc12d72 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/LICENSE b/node_modules/@jridgewell/remapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/remapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/remapping/README.md b/node_modules/@jridgewell/remapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6d092d7eaad3a73a8f094a63b7fe85fe714ef9eb --- /dev/null +++ b/node_modules/@jridgewell/remapping/README.md @@ -0,0 +1,218 @@ +# @jridgewell/remapping + +> Remap sequential sourcemaps through transformations to point at the original source code + +Remapping allows you to take the sourcemaps generated through transforming your code and "remap" +them to the original source locations. Think "my minified code, transformed with babel and bundled +with webpack", all pointing to the correct location in your original source code. + +With remapping, none of your source code transformations need to be aware of the input's sourcemap, +they only need to generate an output sourcemap. This greatly simplifies building custom +transformations (think a find-and-replace). + +## Installation + +```sh +npm install @jridgewell/remapping +``` + +## Usage + +```typescript +function remapping( + map: SourceMap | SourceMap[], + loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined), + options?: { excludeContent: boolean, decodedMappings: boolean } +): SourceMap; + +// LoaderContext gives the loader the importing sourcemap, tree depth, the ability to override the +// "source" location (where child sources are resolved relative to, or the location of original +// source), and the ability to override the "content" of an original source for inclusion in the +// output sourcemap. +type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; +} +``` + +`remapping` takes the final output sourcemap, and a `loader` function. For every source file pointer +in the sourcemap, the `loader` will be called with the resolved path. If the path itself represents +a transformed file (it has a sourcmap associated with it), then the `loader` should return that +sourcemap. If not, the path will be treated as an original, untransformed source code. + +```js +// Babel transformed "helloworld.js" into "transformed.js" +const transformedMap = JSON.stringify({ + file: 'transformed.js', + // 1st column of 2nd line of output file translates into the 1st source + // file, line 3, column 2 + mappings: ';CAEE', + sources: ['helloworld.js'], + version: 3, +}); + +// Uglify minified "transformed.js" into "transformed.min.js" +const minifiedTransformedMap = JSON.stringify({ + file: 'transformed.min.js', + // 0th column of 1st line of output file translates into the 1st source + // file, line 2, column 1. + mappings: 'AACC', + names: [], + sources: ['transformed.js'], + version: 3, +}); + +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + // The "transformed.js" file is an transformed file. + if (file === 'transformed.js') { + // The root importer is empty. + console.assert(ctx.importer === ''); + // The depth in the sourcemap tree we're currently loading. + // The root `minifiedTransformedMap` is depth 0, and its source children are depth 1, etc. + console.assert(ctx.depth === 1); + + return transformedMap; + } + + // Loader will be called to load transformedMap's source file pointers as well. + console.assert(file === 'helloworld.js'); + // `transformed.js`'s sourcemap points into `helloworld.js`. + console.assert(ctx.importer === 'transformed.js'); + // This is a source child of `transformed`, which is a source child of `minifiedTransformedMap`. + console.assert(ctx.depth === 2); + return null; + } +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +In this example, `loader` will be called twice: + +1. `"transformed.js"`, the first source file pointer in the `minifiedTransformedMap`. We return the + associated sourcemap for it (its a transformed file, after all) so that sourcemap locations can + be traced through it into the source files it represents. +2. `"helloworld.js"`, our original, unmodified source code. This file does not have a sourcemap, so + we return `null`. + +The `remapped` sourcemap now points from `transformed.min.js` into locations in `helloworld.js`. If +you were to read the `mappings`, it says "0th column of the first line output line points to the 1st +column of the 2nd line of the file `helloworld.js`". + +### Multiple transformations of a file + +As a convenience, if you have multiple single-source transformations of a file, you may pass an +array of sourcemap files in the order of most-recent transformation sourcemap first. Note that this +changes the `importer` and `depth` of each call to our loader. So our above example could have been +written as: + +```js +const remapped = remapping( + [minifiedTransformedMap, transformedMap], + () => null +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +### Advanced control of the loading graph + +#### `source` + +The `source` property can overridden to any value to change the location of the current load. Eg, +for an original source file, it allows us to change the location to the original source regardless +of what the sourcemap source entry says. And for transformed files, it allows us to change the +relative resolving location for child sources of the loaded sourcemap. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // We pretend the transformed.js file actually exists in the 'src/' directory. When the nested + // source files are loaded, they will now be relative to `src/`. + ctx.source = 'src/transformed.js'; + return transformedMap; + } + + console.assert(file === 'src/helloworld.js'); + // We could futher change the source of this original file, eg, to be inside a nested directory + // itself. This will be reflected in the remapped sourcemap. + ctx.source = 'src/nested/transformed.js'; + return null; + } +); + +console.log(remapped); +// { +// …, +// sources: ['src/nested/helloworld.js'], +// }; +``` + + +#### `content` + +The `content` property can be overridden when we encounter an original source file. Eg, this allows +you to manually provide the source content of the original file regardless of whether the +`sourcesContent` field is present in the parent sourcemap. It can also be set to `null` to remove +the source content. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // transformedMap does not include a `sourcesContent` field, so usually the remapped sourcemap + // would not include any `sourcesContent` values. + return transformedMap; + } + + console.assert(file === 'helloworld.js'); + // We can read the file to provide the source content. + ctx.content = fs.readFileSync(file, 'utf8'); + return null; + } +); + +console.log(remapped); +// { +// …, +// sourcesContent: [ +// 'console.log("Hello world!")', +// ], +// }; +``` + +### Options + +#### excludeContent + +By default, `excludeContent` is `false`. Passing `{ excludeContent: true }` will exclude the +`sourcesContent` field from the returned sourcemap. This is mainly useful when you want to reduce +the size out the sourcemap. + +#### decodedMappings + +By default, `decodedMappings` is `false`. Passing `{ decodedMappings: true }` will leave the +`mappings` field in a [decoded state](https://github.com/rich-harris/sourcemap-codec) instead of +encoding into a VLQ string. diff --git a/node_modules/@jridgewell/remapping/dist/remapping.mjs b/node_modules/@jridgewell/remapping/dist/remapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8b7009c049e3188f5fda149852d3e17fd5de4009 --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.mjs @@ -0,0 +1,144 @@ +// src/build-source-map-tree.ts +import { TraceMap } from "@jridgewell/trace-mapping"; + +// src/source-map-tree.ts +import { GenMapping, maybeAddSegment, setIgnore, setSourceContent } from "@jridgewell/gen-mapping"; +import { traceSegment, decodedMappings } from "@jridgewell/trace-mapping"; +var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false); +var EMPTY_SOURCES = []; +function SegmentObject(source, line, column, name, content, ignore) { + return { source, line, column, name, content, ignore }; +} +function Source(map, sources, source, content, ignore) { + return { + map, + sources, + source, + content, + ignore + }; +} +function MapSource(map, sources) { + return Source(map, sources, "", null, false); +} +function OriginalSource(source, content, ignore) { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} +function traceMappings(tree) { + const gen = new GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = decodedMappings(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + if (segment.length !== 1) { + const source2 = rootSources[segment[1]]; + traced = originalPositionFor( + source2, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : "" + ); + if (traced == null) continue; + } + const { column, line, name, content, source, ignore } = traced; + maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) setSourceContent(gen, source, content); + if (ignore) setIgnore(gen, source, true); + } + } + return gen; +} +function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + const segment = traceSegment(source.map, line, column); + if (segment == null) return null; + if (segment.length === 1) return SOURCELESS_MAPPING; + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name + ); +} + +// src/build-source-map-tree.ts +function asArray(value) { + if (Array.isArray(value)) return value; + return [value]; +} +function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new TraceMap(m, "")); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file. +Did you specify these with the most recent transformation maps first?` + ); + } + } + let tree = build(map, loader, "", 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} +function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent, ignoreList } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + const ctx = { + importer, + depth, + source: sourceFile || "", + content: void 0, + ignore: void 0 + }; + const sourceMap = loader(ctx.source, ctx); + const { source, content, ignore } = ctx; + if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth); + const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + return MapSource(map, children); +} + +// src/source-map.ts +import { toDecodedMap, toEncodedMap } from "@jridgewell/gen-mapping"; +var SourceMap = class { + constructor(map, options) { + const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); + this.version = out.version; + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.ignoreList = out.ignoreList; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } +}; + +// src/remapping.ts +function remapping(input, loader, options) { + const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} +export { + remapping as default +}; +//# sourceMappingURL=remapping.mjs.map diff --git a/node_modules/@jridgewell/remapping/dist/remapping.mjs.map b/node_modules/@jridgewell/remapping/dist/remapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..66801e6d1c7566a5873a127112df792aac35347d --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/build-source-map-tree.ts", "../src/source-map-tree.ts", "../src/source-map.ts", "../src/remapping.ts"], + "mappings": ";AAAA,SAAS,gBAAgB;;;ACAzB,SAAS,YAAY,iBAAiB,WAAW,wBAAwB;AACzE,SAAS,cAAc,uBAAu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W;AACX,QAAM,OACJ,OAAO,YAAY,WAAW,UAAU,EAAE,gBAAgB,CAAC,CAAC,SAAS,iBAAiB,MAAM;AAC9F,QAAM,OAAO,mBAAmB,OAAO,MAAM;AAC7C,SAAO,IAAI,UAAU,cAAc,IAAI,GAAG,IAAI;AAChD;", + "names": ["source"] +} diff --git a/node_modules/@jridgewell/remapping/dist/remapping.umd.js b/node_modules/@jridgewell/remapping/dist/remapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..077eb4d5dc61564539a2f580533940f4f5ad7e23 --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.umd.js @@ -0,0 +1,212 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/gen-mapping'), require('@jridgewell/trace-mapping')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/gen-mapping', '@jridgewell/trace-mapping'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.genMapping, global.traceMapping); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.remapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_genMapping, require_traceMapping) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/trace-mapping +var require_trace_mapping = __commonJS({ + "umd:@jridgewell/trace-mapping"(exports, module2) { + module2.exports = require_traceMapping; + } +}); + +// umd:@jridgewell/gen-mapping +var require_gen_mapping = __commonJS({ + "umd:@jridgewell/gen-mapping"(exports, module2) { + module2.exports = require_genMapping; + } +}); + +// src/remapping.ts +var remapping_exports = {}; +__export(remapping_exports, { + default: () => remapping +}); +module.exports = __toCommonJS(remapping_exports); + +// src/build-source-map-tree.ts +var import_trace_mapping2 = __toESM(require_trace_mapping()); + +// src/source-map-tree.ts +var import_gen_mapping = __toESM(require_gen_mapping()); +var import_trace_mapping = __toESM(require_trace_mapping()); +var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false); +var EMPTY_SOURCES = []; +function SegmentObject(source, line, column, name, content, ignore) { + return { source, line, column, name, content, ignore }; +} +function Source(map, sources, source, content, ignore) { + return { + map, + sources, + source, + content, + ignore + }; +} +function MapSource(map, sources) { + return Source(map, sources, "", null, false); +} +function OriginalSource(source, content, ignore) { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} +function traceMappings(tree) { + const gen = new import_gen_mapping.GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = (0, import_trace_mapping.decodedMappings)(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + if (segment.length !== 1) { + const source2 = rootSources[segment[1]]; + traced = originalPositionFor( + source2, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : "" + ); + if (traced == null) continue; + } + const { column, line, name, content, source, ignore } = traced; + (0, import_gen_mapping.maybeAddSegment)(gen, i, genCol, source, line, column, name); + if (source && content != null) (0, import_gen_mapping.setSourceContent)(gen, source, content); + if (ignore) (0, import_gen_mapping.setIgnore)(gen, source, true); + } + } + return gen; +} +function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + const segment = (0, import_trace_mapping.traceSegment)(source.map, line, column); + if (segment == null) return null; + if (segment.length === 1) return SOURCELESS_MAPPING; + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name + ); +} + +// src/build-source-map-tree.ts +function asArray(value) { + if (Array.isArray(value)) return value; + return [value]; +} +function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new import_trace_mapping2.TraceMap(m, "")); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file. +Did you specify these with the most recent transformation maps first?` + ); + } + } + let tree = build(map, loader, "", 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} +function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent, ignoreList } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + const ctx = { + importer, + depth, + source: sourceFile || "", + content: void 0, + ignore: void 0 + }; + const sourceMap = loader(ctx.source, ctx); + const { source, content, ignore } = ctx; + if (sourceMap) return build(new import_trace_mapping2.TraceMap(sourceMap, source), loader, source, depth); + const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + return MapSource(map, children); +} + +// src/source-map.ts +var import_gen_mapping2 = __toESM(require_gen_mapping()); +var SourceMap = class { + constructor(map, options) { + const out = options.decodedMappings ? (0, import_gen_mapping2.toDecodedMap)(map) : (0, import_gen_mapping2.toEncodedMap)(map); + this.version = out.version; + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.ignoreList = out.ignoreList; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } +}; + +// src/remapping.ts +function remapping(input, loader, options) { + const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} +})); +//# sourceMappingURL=remapping.umd.js.map diff --git a/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map b/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d5e0786411414c3565f1914751a7a1c0073153eb --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/trace-mapping", "umd:@jridgewell/gen-mapping", "../src/remapping.ts", "../src/build-source-map-tree.ts", "../src/source-map-tree.ts", "../src/source-map.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,2CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,yCAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAC,wBAAyB;;;ACAzB,yBAAyE;AACzE,2BAA8C;AA+B9C,IAAM,qBAAqC,8BAAc,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK;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CAAC,SAAS,iBAAiB,MAAM;AAC9F,QAAM,OAAO,mBAAmB,OAAO,MAAM;AAC7C,SAAO,IAAI,UAAU,cAAc,IAAI,GAAG,IAAI;AAChD;", + "names": ["module", "module", "import_trace_mapping", "source", "import_gen_mapping"] +} diff --git a/node_modules/@jridgewell/remapping/package.json b/node_modules/@jridgewell/remapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ed00441ea559a1546bd16b7915e2e9fe6e7708bb --- /dev/null +++ b/node_modules/@jridgewell/remapping/package.json @@ -0,0 +1,71 @@ +{ + "name": "@jridgewell/remapping", + "version": "2.3.5", + "description": "Remap sequential sourcemaps through transformations to point at the original source code", + "keywords": [ + "source", + "map", + "remap" + ], + "main": "dist/remapping.umd.js", + "module": "dist/remapping.mjs", + "types": "types/remapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/remapping.d.mts", + "default": "./dist/remapping.mjs" + }, + "default": { + "types": "./types/remapping.d.cts", + "default": "./dist/remapping.umd.js" + } + }, + "./dist/remapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs remapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/remapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/remapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "devDependencies": { + "source-map": "0.6.1" + } +} diff --git a/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts b/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e0262bd7c981be3b510203ea08841ea1a47fc89 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts @@ -0,0 +1,89 @@ +import { TraceMap } from '@jridgewell/trace-mapping'; + +import { OriginalSource, MapSource } from './source-map-tree'; + +import type { Sources, MapSource as MapSourceType } from './source-map-tree'; +import type { SourceMapInput, SourceMapLoader, LoaderContext } from './types'; + +function asArray(value: T | T[]): T[] { + if (Array.isArray(value)) return value; + return [value]; +} + +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export default function buildSourceMapTree( + input: SourceMapInput | SourceMapInput[], + loader: SourceMapLoader, +): MapSourceType { + const maps = asArray(input).map((m) => new TraceMap(m, '')); + const map = maps.pop()!; + + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file.\n` + + 'Did you specify these with the most recent transformation maps first?', + ); + } + } + + let tree = build(map, loader, '', 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} + +function build( + map: TraceMap, + loader: SourceMapLoader, + importer: string, + importerDepth: number, +): MapSourceType { + const { resolvedSources, sourcesContent, ignoreList } = map; + + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile: string | null, i: number): Sources => { + // The loading context gives the loader more information about why this file is being loaded + // (eg, from which importer). It also allows the loader to override the location of the loaded + // sourcemap/original source, or to override the content in the sourcesContent field if it's + // an unmodified source file. + const ctx: LoaderContext = { + importer, + depth, + source: sourceFile || '', + content: undefined, + ignore: undefined, + }; + + // Use the provided loader callback to retrieve the file's sourcemap. + // TODO: We should eventually support async loading of sourcemap files. + const sourceMap = loader(ctx.source, ctx); + + const { source, content, ignore } = ctx; + + // If there is a sourcemap, then we need to recurse into it to load its source files. + if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth); + + // Else, it's an unmodified source file. + // The contents of this unmodified source file can be overridden via the loader context, + // allowing it to be explicitly null or a string. If it remains undefined, we fall back to + // the importing sourcemap's `sourcesContent` field. + const sourceContent = + content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + + return MapSource(map, children); +} diff --git a/node_modules/@jridgewell/remapping/src/remapping.ts b/node_modules/@jridgewell/remapping/src/remapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0f8b0ded2debe99b5f94b84ba7ce76dc04dafac --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/remapping.ts @@ -0,0 +1,42 @@ +import buildSourceMapTree from './build-source-map-tree'; +import { traceMappings } from './source-map-tree'; +import SourceMap from './source-map'; + +import type { SourceMapInput, SourceMapLoader, Options } from './types'; +export type { + SourceMapSegment, + EncodedSourceMap, + EncodedSourceMap as RawSourceMap, + DecodedSourceMap, + SourceMapInput, + SourceMapLoader, + LoaderContext, + Options, +} from './types'; +export type { SourceMap }; + +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export default function remapping( + input: SourceMapInput | SourceMapInput[], + loader: SourceMapLoader, + options?: boolean | Options, +): SourceMap { + const opts = + typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} diff --git a/node_modules/@jridgewell/remapping/src/source-map-tree.ts b/node_modules/@jridgewell/remapping/src/source-map-tree.ts new file mode 100644 index 0000000000000000000000000000000000000000..935240f913436d8ad8c0a2befedeb270f820dad0 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/source-map-tree.ts @@ -0,0 +1,172 @@ +import { GenMapping, maybeAddSegment, setIgnore, setSourceContent } from '@jridgewell/gen-mapping'; +import { traceSegment, decodedMappings } from '@jridgewell/trace-mapping'; + +import type { TraceMap } from '@jridgewell/trace-mapping'; + +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; + +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; + +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; + +export type Sources = OriginalSource | MapSource; + +const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false); +const EMPTY_SOURCES: Sources[] = []; + +function SegmentObject( + source: string, + line: number, + column: number, + name: string, + content: string | null, + ignore: boolean, +): SourceMapSegmentObject { + return { source, line, column, name, content, ignore }; +} + +function Source( + map: TraceMap, + sources: Sources[], + source: '', + content: null, + ignore: false, +): MapSource; +function Source( + map: null, + sources: Sources[], + source: string, + content: string | null, + ignore: boolean, +): OriginalSource; +function Source( + map: TraceMap | null, + sources: Sources[], + source: string | '', + content: string | null, + ignore: boolean, +): Sources { + return { + map, + sources, + source, + content, + ignore, + } as any; +} + +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export function MapSource(map: TraceMap, sources: Sources[]): MapSource { + return Source(map, sources, '', null, false); +} + +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export function OriginalSource( + source: string, + content: string | null, + ignore: boolean, +): OriginalSource { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} + +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export function traceMappings(tree: MapSource): GenMapping { + // TODO: Eventually support sourceRoot, which has to be removed because the sources are already + // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. + const gen = new GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = decodedMappings(map); + + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced: SourceMapSegmentObject | null = SOURCELESS_MAPPING; + + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length !== 1) { + const source = rootSources[segment[1]]; + traced = originalPositionFor( + source, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : '', + ); + + // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a + // respective segment into an original source. + if (traced == null) continue; + } + + const { column, line, name, content, source, ignore } = traced; + + maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) setSourceContent(gen, source, content); + if (ignore) setIgnore(gen, source, true); + } + } + + return gen; +} + +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export function originalPositionFor( + source: Sources, + line: number, + column: number, + name: string, +): SourceMapSegmentObject | null { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + + const segment = traceSegment(source.map, line, column); + + // If we couldn't find a segment, then this doesn't exist in the sourcemap. + if (segment == null) return null; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length === 1) return SOURCELESS_MAPPING; + + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name, + ); +} diff --git a/node_modules/@jridgewell/remapping/src/source-map.ts b/node_modules/@jridgewell/remapping/src/source-map.ts new file mode 100644 index 0000000000000000000000000000000000000000..5156086f210f4b7264601aa83a6639d9b076b284 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/source-map.ts @@ -0,0 +1,38 @@ +import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping'; + +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types'; + +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export default class SourceMap { + declare file?: string | null; + declare mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + declare sourceRoot?: string; + declare names: string[]; + declare sources: (string | null)[]; + declare sourcesContent?: (string | null)[]; + declare version: 3; + declare ignoreList: number[] | undefined; + + constructor(map: GenMapping, options: Options) { + const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); + this.version = out.version; // SourceMap spec says this should be first. + this.file = out.file; + this.mappings = out.mappings as SourceMap['mappings']; + this.names = out.names as SourceMap['names']; + this.ignoreList = out.ignoreList as SourceMap['ignoreList']; + this.sourceRoot = out.sourceRoot; + + this.sources = out.sources as SourceMap['sources']; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent as SourceMap['sourcesContent']; + } + } + + toString(): string { + return JSON.stringify(this); + } +} diff --git a/node_modules/@jridgewell/remapping/src/types.ts b/node_modules/@jridgewell/remapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..384961d20d5f6933d9c7f47fc753e934a6cbebc8 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/types.ts @@ -0,0 +1,27 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; + +export type { + SourceMapSegment, + DecodedSourceMap, + EncodedSourceMap, +} from '@jridgewell/trace-mapping'; + +export type { SourceMapInput }; + +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; + +export type SourceMapLoader = ( + file: string, + ctx: LoaderContext, +) => SourceMapInput | null | undefined | void; + +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..e089aeaab3a0fba9c7d264f0f65eff992180e036 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts @@ -0,0 +1,15 @@ +import type { MapSource as MapSourceType } from './source-map-tree.cts'; +import type { SourceMapInput, SourceMapLoader } from './types.cts'; +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export = function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType; +//# sourceMappingURL=build-source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..38e4290dbeacd537e9c3dc783c6848dfe441e5e3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"build-source-map-tree.d.ts","sourceRoot":"","sources":["../src/build-source-map-tree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAW,SAAS,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAO9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,GACtB,aAAa,CAkBf"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..746ac5f730888a0ca6c071ec975b64291537ee57 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts @@ -0,0 +1,15 @@ +import type { MapSource as MapSourceType } from './source-map-tree.mts'; +import type { SourceMapInput, SourceMapLoader } from './types.mts'; +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export default function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType; +//# sourceMappingURL=build-source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..38e4290dbeacd537e9c3dc783c6848dfe441e5e3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"build-source-map-tree.d.ts","sourceRoot":"","sources":["../src/build-source-map-tree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAW,SAAS,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAO9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,GACtB,aAAa,CAkBf"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.cts b/node_modules/@jridgewell/remapping/types/remapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2022784752343ea9079b466504b00f93026e4f93 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.cts @@ -0,0 +1,21 @@ +import SourceMap from './source-map.cts'; +import type { SourceMapInput, SourceMapLoader, Options } from './types.cts'; +export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types.cts'; +export type { SourceMap }; +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export = function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap; +//# sourceMappingURL=remapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.cts.map b/node_modules/@jridgewell/remapping/types/remapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f2fd0efd61b77ee14bd4aa44f5e597e1b8ffcdf --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.d.ts","sourceRoot":"","sources":["../src/remapping.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,IAAI,YAAY,EAChC,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAC1B,SAAS,CAKX"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.mts b/node_modules/@jridgewell/remapping/types/remapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..95c406698754b2f70d5040ff33c1a332ac18e266 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.mts @@ -0,0 +1,21 @@ +import SourceMap from './source-map.mts'; +import type { SourceMapInput, SourceMapLoader, Options } from './types.mts'; +export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types.mts'; +export type { SourceMap }; +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export default function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap; +//# sourceMappingURL=remapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.mts.map b/node_modules/@jridgewell/remapping/types/remapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f2fd0efd61b77ee14bd4aa44f5e597e1b8ffcdf --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.d.ts","sourceRoot":"","sources":["../src/remapping.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,IAAI,YAAY,EAChC,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAC1B,SAAS,CAKX"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..440f65b8c2d471b558ac0700f04265c796fe0664 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts @@ -0,0 +1,46 @@ +import { GenMapping } from '@jridgewell/gen-mapping'; +import type { TraceMap } from '@jridgewell/trace-mapping'; +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; +export type Sources = OriginalSource | MapSource; +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource; +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource; +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export declare function traceMappings(tree: MapSource): GenMapping; +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null; +//# sourceMappingURL=source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..e7cbfb9563f40b30775b981a4cb06376a97796e1 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map-tree.d.ts","sourceRoot":"","sources":["../src/source-map-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,yBAAyB,CAAC;AAGnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AA8CjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,CAEtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,EAAE,OAAO,GACd,cAAc,CAEhB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAyCzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,sBAAsB,GAAG,IAAI,CAmB/B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..440f65b8c2d471b558ac0700f04265c796fe0664 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts @@ -0,0 +1,46 @@ +import { GenMapping } from '@jridgewell/gen-mapping'; +import type { TraceMap } from '@jridgewell/trace-mapping'; +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; +export type Sources = OriginalSource | MapSource; +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource; +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource; +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export declare function traceMappings(tree: MapSource): GenMapping; +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null; +//# sourceMappingURL=source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..e7cbfb9563f40b30775b981a4cb06376a97796e1 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map-tree.d.ts","sourceRoot":"","sources":["../src/source-map-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,yBAAyB,CAAC;AAGnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AA8CjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,CAEtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,EAAE,OAAO,GACd,cAAc,CAEhB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAyCzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,sBAAsB,GAAG,IAAI,CAmB/B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.cts b/node_modules/@jridgewell/remapping/types/source-map.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..fdb7eedeb3b3f01125d66832f345e31d1f77d786 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.cts @@ -0,0 +1,19 @@ +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types.cts'; +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export = class SourceMap { + file?: string | null; + mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + sourceRoot?: string; + names: string[]; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList: number[] | undefined; + constructor(map: GenMapping, options: Options); + toString(): string; +} +//# sourceMappingURL=source-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.cts.map b/node_modules/@jridgewell/remapping/types/source-map.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..593daf8e0abaffe983e2c1166b3e8180d9649644 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAE7B,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO;IAe7C,QAAQ,IAAI,MAAM;CAGnB"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.mts b/node_modules/@jridgewell/remapping/types/source-map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..52ebba2f72b103271db863d1f667105bb65163b3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.mts @@ -0,0 +1,19 @@ +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types.mts'; +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export default class SourceMap { + file?: string | null; + mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + sourceRoot?: string; + names: string[]; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList: number[] | undefined; + constructor(map: GenMapping, options: Options); + toString(): string; +} +//# sourceMappingURL=source-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.mts.map b/node_modules/@jridgewell/remapping/types/source-map.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..593daf8e0abaffe983e2c1166b3e8180d9649644 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAE7B,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO;IAe7C,QAAQ,IAAI,MAAM;CAGnB"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.cts b/node_modules/@jridgewell/remapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..eeb320f847682b723d15ea336d35f8c3109faa75 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.cts @@ -0,0 +1,16 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping'; +export type { SourceMapInput }; +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; +export type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void; +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.cts.map b/node_modules/@jridgewell/remapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..4f8647e4c9c5d4075fd48dd86a5fe1028fa7ad65 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,aAAa,KACf,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.mts b/node_modules/@jridgewell/remapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..eeb320f847682b723d15ea336d35f8c3109faa75 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.mts @@ -0,0 +1,16 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping'; +export type { SourceMapInput }; +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; +export type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void; +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.mts.map b/node_modules/@jridgewell/remapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..4f8647e4c9c5d4075fd48dd86a5fe1028fa7ad65 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,aAAa,KACf,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/LICENSE b/node_modules/@jridgewell/resolve-uri/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0a81b2ade1c77efc8ed0e73172efd07ea1c73539 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/LICENSE @@ -0,0 +1,19 @@ +Copyright 2019 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/README.md b/node_modules/@jridgewell/resolve-uri/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2fe70df77ec8e109faf2bc857e9893d486ad9eb1 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/README.md @@ -0,0 +1,40 @@ +# @jridgewell/resolve-uri + +> Resolve a URI relative to an optional base URI + +Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths. + +## Installation + +```sh +npm install @jridgewell/resolve-uri +``` + +## Usage + +```typescript +function resolve(input: string, base?: string): string; +``` + +```js +import resolve from '@jridgewell/resolve-uri'; + +resolve('foo', 'https://example.com'); // => 'https://example.com/foo' +``` + +| Input | Base | Resolution | Explanation | +|-----------------------|-------------------------|--------------------------------|--------------------------------------------------------------| +| `https://example.com` | _any_ | `https://example.com/` | Input is normalized only | +| `//example.com` | `https://base.com/` | `https://example.com/` | Input inherits the base's protocol | +| `//example.com` | _rest_ | `//example.com/` | Input is normalized only | +| `/example` | `https://base.com/` | `https://base.com/example` | Input inherits the base's origin | +| `/example` | `//base.com/` | `//base.com/example` | Input inherits the base's host and remains protocol relative | +| `/example` | _rest_ | `/example` | Input is normalized only | +| `example` | `https://base.com/dir/` | `https://base.com/dir/example` | Input is joined with the base | +| `example` | `https://base.com/file` | `https://base.com/example` | Input is joined with the base without its file | +| `example` | `//base.com/dir/` | `//base.com/dir/example` | Input is joined with the base's last directory | +| `example` | `//base.com/file` | `//base.com/example` | Input is joined with the base without its file | +| `example` | `/base/dir/` | `/base/dir/example` | Input is joined with the base's last directory | +| `example` | `/base/file` | `/base/example` | Input is joined with the base without its file | +| `example` | `base/dir/` | `base/dir/example` | Input is joined with the base's last directory | +| `example` | `base/file` | `base/example` | Input is joined with the base without its file | diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e958e8817081205d26fc8b1298cae205420e3936 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs @@ -0,0 +1,232 @@ +// Matches the scheme of a URL, eg "http://" +const schemeRegex = /^[\w+.-]+:\/\//; +/** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ +const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; +/** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ +const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; +function isAbsoluteUrl(input) { + return schemeRegex.test(input); +} +function isSchemeRelativeUrl(input) { + return input.startsWith('//'); +} +function isAbsolutePath(input) { + return input.startsWith('/'); +} +function isFileUrl(input) { + return input.startsWith('file:'); +} +function isRelative(input) { + return /^[.?#]/.test(input); +} +function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); +} +function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); +} +function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: 7 /* Absolute */, + }; +} +function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = 6 /* SchemeRelative */; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = 5 /* AbsolutePath */; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? 3 /* Query */ + : input.startsWith('#') + ? 2 /* Hash */ + : 4 /* RelativePath */ + : 1 /* Empty */; + return url; +} +function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} +function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } +} +/** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ +function normalizePath(url, type) { + const rel = type <= 4 /* RelativePath */; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; +} +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== 7 /* Absolute */) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case 1 /* Empty */: + url.hash = baseUrl.hash; + // fall through + case 2 /* Hash */: + url.query = baseUrl.query; + // fall through + case 3 /* Query */: + case 4 /* RelativePath */: + mergePaths(url, baseUrl); + // fall through + case 5 /* AbsolutePath */: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case 6 /* SchemeRelative */: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case 2 /* Hash */: + case 3 /* Query */: + return queryHash; + case 4 /* RelativePath */: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case 5 /* AbsolutePath */: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } +} + +export { resolve as default }; +//# sourceMappingURL=resolve-uri.mjs.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1de97d011e53986c4497437eec6b649a51611fdf --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.mjs","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nconst enum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":"AAAA;AACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;AAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;AAE5F;;;;;;;;;AASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;AAuBpF,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC;IACpC,OAAO,OAAO,CACZ,KAAK,CAAC,CAAC,CAAC,EACR,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,KAAK,CAAC,CAAC,CAAC,EACR,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,KAAK,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C,IAAI,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;;;;gBAIlD,OAAO,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;aAChC;YAED,OAAO,IAAI,GAAG,SAAS,CAAC;SACzB;QAED;YACE,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;QAE9B;YACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;KACpF;AACH;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..a783049b0136da9128af243b699229e0870aa390 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js @@ -0,0 +1,240 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.resolveURI = factory()); +})(this, (function () { 'use strict'; + + // Matches the scheme of a URL, eg "http://" + const schemeRegex = /^[\w+.-]+:\/\//; + /** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ + const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; + /** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ + const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; + function isAbsoluteUrl(input) { + return schemeRegex.test(input); + } + function isSchemeRelativeUrl(input) { + return input.startsWith('//'); + } + function isAbsolutePath(input) { + return input.startsWith('/'); + } + function isFileUrl(input) { + return input.startsWith('file:'); + } + function isRelative(input) { + return /^[.?#]/.test(input); + } + function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); + } + function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); + } + function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: 7 /* Absolute */, + }; + } + function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = 6 /* SchemeRelative */; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = 5 /* AbsolutePath */; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? 3 /* Query */ + : input.startsWith('#') + ? 2 /* Hash */ + : 4 /* RelativePath */ + : 1 /* Empty */; + return url; + } + function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); + } + function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } + } + /** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ + function normalizePath(url, type) { + const rel = type <= 4 /* RelativePath */; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; + } + /** + * Attempts to resolve `input` URL/path relative to `base`. + */ + function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== 7 /* Absolute */) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case 1 /* Empty */: + url.hash = baseUrl.hash; + // fall through + case 2 /* Hash */: + url.query = baseUrl.query; + // fall through + case 3 /* Query */: + case 4 /* RelativePath */: + mergePaths(url, baseUrl); + // fall through + case 5 /* AbsolutePath */: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case 6 /* SchemeRelative */: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case 2 /* Hash */: + case 3 /* Query */: + return queryHash; + case 4 /* RelativePath */: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case 5 /* AbsolutePath */: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } + } + + return resolve; + +})); +//# sourceMappingURL=resolve-uri.umd.js.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..70a37f21da35cad5db599004fb8ca601f3dfa57b --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.umd.js","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nconst enum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAErC;;;;;;;;;;IAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;IAE5F;;;;;;;;;IASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;IAuBpF,SAAS,aAAa,CAAC,KAAa;QAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,mBAAmB,CAAC,KAAa;QACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,cAAc,CAAC,KAAa;QACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,SAAS,CAAC,KAAa;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,UAAU,CAAC,KAAa;QAC/B,OAAO,Q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Aa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAE9B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;QACvC,QAAQ,SAAS;;;YAIf,kBAAkB;YAClB;gBACE,OAAO,SAAS,CAAC;YAEnB,2BAA2B;;gBAEzB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE/B,IAAI,CAAC,IAAI;oBAAE,OAAO,SAAS,IAAI,GAAG,CAAC;gBAEnC,IAAI,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;;;;oBAIlD,OAAO,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;iBAChC;gBAED,OAAO,IAAI,GAAG,SAAS,CAAC;aACzB;YAED;gBACE,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;YAE9B;gBACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;SACpF;IACH;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7f0b3b2d7d2eba98141e8b346328b1ff6d6118c --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts @@ -0,0 +1,4 @@ +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +export default function resolve(input: string, base: string | undefined): string; diff --git a/node_modules/@jridgewell/resolve-uri/package.json b/node_modules/@jridgewell/resolve-uri/package.json new file mode 100644 index 0000000000000000000000000000000000000000..02a4c5187e7ca726d36ff24dda674400b1c3f846 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/package.json @@ -0,0 +1,69 @@ +{ + "name": "@jridgewell/resolve-uri", + "version": "3.1.2", + "description": "Resolve a URI relative to an optional base URI", + "keywords": [ + "resolve", + "uri", + "url", + "path" + ], + "author": "Justin Ridgewell ", + "license": "MIT", + "repository": "https://github.com/jridgewell/resolve-uri", + "main": "dist/resolve-uri.umd.js", + "module": "dist/resolve-uri.mjs", + "types": "dist/types/resolve-uri.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/resolve-uri.d.ts", + "browser": "./dist/resolve-uri.umd.js", + "require": "./dist/resolve-uri.umd.js", + "import": "./dist/resolve-uri.mjs" + }, + "./dist/resolve-uri.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "prebuild": "rm -rf dist", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:only", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "mocha --watch", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build" + }, + "devDependencies": { + "@jridgewell/resolve-uri-latest": "npm:@jridgewell/resolve-uri@*", + "@rollup/plugin-typescript": "8.3.0", + "@typescript-eslint/eslint-plugin": "5.10.0", + "@typescript-eslint/parser": "5.10.0", + "c8": "7.11.0", + "eslint": "8.7.0", + "eslint-config-prettier": "8.3.0", + "mocha": "9.2.0", + "npm-run-all": "4.1.5", + "prettier": "2.5.1", + "rollup": "2.66.0", + "typescript": "4.5.5" + } +} diff --git a/node_modules/@jridgewell/sourcemap-codec/LICENSE b/node_modules/@jridgewell/sourcemap-codec/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/sourcemap-codec/README.md b/node_modules/@jridgewell/sourcemap-codec/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b3e0708bf93737649c24aefc0cf216f23905908e --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/README.md @@ -0,0 +1,264 @@ +# @jridgewell/sourcemap-codec + +Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). + + +## Why? + +Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap. + +This package makes the process slightly easier. + + +## Installation + +```bash +npm install @jridgewell/sourcemap-codec +``` + + +## Usage + +```js +import { encode, decode } from '@jridgewell/sourcemap-codec'; + +var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); + +assert.deepEqual( decoded, [ + // the first line (of the generated code) has no mappings, + // as shown by the starting semi-colon (which separates lines) + [], + + // the second line contains four (comma-separated) segments + [ + // segments are encoded as you'd expect: + // [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ] + + // i.e. the first segment begins at column 2, and maps back to the second column + // of the second line (both zero-based) of the 0th source, and uses the 0th + // name in the `map.names` array + [ 2, 0, 2, 2, 0 ], + + // the remaining segments are 4-length rather than 5-length, + // because they don't map a name + [ 4, 0, 2, 4 ], + [ 6, 0, 2, 5 ], + [ 7, 0, 2, 7 ] + ], + + // the final line contains two segments + [ + [ 2, 1, 10, 19 ], + [ 12, 1, 11, 20 ] + ] +]); + +var encoded = encode( decoded ); +assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); +``` + +## Benchmarks + +``` +node v20.10.0 + +amp.js.map - 45120 segments + +Decode Memory Usage: +local code 5815135 bytes +@jridgewell/sourcemap-codec 1.4.15 5868160 bytes +sourcemap-codec 5492584 bytes +source-map-0.6.1 13569984 bytes +source-map-0.8.0 6390584 bytes +chrome dev tools 8011136 bytes +Smallest memory usage is sourcemap-codec + +Decode speed: +decode: local code x 492 ops/sec ±1.22% (90 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 499 ops/sec ±1.16% (89 runs sampled) +decode: sourcemap-codec x 376 ops/sec ±1.66% (89 runs sampled) +decode: source-map-0.6.1 x 34.99 ops/sec ±0.94% (48 runs sampled) +decode: source-map-0.8.0 x 351 ops/sec ±0.07% (95 runs sampled) +chrome dev tools x 165 ops/sec ±0.91% (86 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 444248 bytes +@jridgewell/sourcemap-codec 1.4.15 623024 bytes +sourcemap-codec 8696280 bytes +source-map-0.6.1 8745176 bytes +source-map-0.8.0 8736624 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 796 ops/sec ±0.11% (97 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 795 ops/sec ±0.25% (98 runs sampled) +encode: sourcemap-codec x 231 ops/sec ±0.83% (86 runs sampled) +encode: source-map-0.6.1 x 166 ops/sec ±0.57% (86 runs sampled) +encode: source-map-0.8.0 x 203 ops/sec ±0.45% (88 runs sampled) +Fastest is encode: local code,encode: @jridgewell/sourcemap-codec 1.4.15 + + +*** + + +babel.min.js.map - 347793 segments + +Decode Memory Usage: +local code 35424960 bytes +@jridgewell/sourcemap-codec 1.4.15 35424696 bytes +sourcemap-codec 36033464 bytes +source-map-0.6.1 62253704 bytes +source-map-0.8.0 43843920 bytes +chrome dev tools 45111400 bytes +Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15 + +Decode speed: +decode: local code x 38.18 ops/sec ±5.44% (52 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 38.36 ops/sec ±5.02% (52 runs sampled) +decode: sourcemap-codec x 34.05 ops/sec ±4.45% (47 runs sampled) +decode: source-map-0.6.1 x 4.31 ops/sec ±2.76% (15 runs sampled) +decode: source-map-0.8.0 x 55.60 ops/sec ±0.13% (73 runs sampled) +chrome dev tools x 16.94 ops/sec ±3.78% (46 runs sampled) +Fastest is decode: source-map-0.8.0 + +Encode Memory Usage: +local code 2606016 bytes +@jridgewell/sourcemap-codec 1.4.15 2626440 bytes +sourcemap-codec 21152576 bytes +source-map-0.6.1 25023928 bytes +source-map-0.8.0 25256448 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 127 ops/sec ±0.18% (83 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 128 ops/sec ±0.26% (83 runs sampled) +encode: sourcemap-codec x 29.31 ops/sec ±2.55% (53 runs sampled) +encode: source-map-0.6.1 x 18.85 ops/sec ±3.19% (36 runs sampled) +encode: source-map-0.8.0 x 19.34 ops/sec ±1.97% (36 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15 + + +*** + + +preact.js.map - 1992 segments + +Decode Memory Usage: +local code 261696 bytes +@jridgewell/sourcemap-codec 1.4.15 244296 bytes +sourcemap-codec 302816 bytes +source-map-0.6.1 939176 bytes +source-map-0.8.0 336 bytes +chrome dev tools 587368 bytes +Smallest memory usage is source-map-0.8.0 + +Decode speed: +decode: local code x 17,782 ops/sec ±0.32% (97 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 17,863 ops/sec ±0.40% (100 runs sampled) +decode: sourcemap-codec x 12,453 ops/sec ±0.27% (101 runs sampled) +decode: source-map-0.6.1 x 1,288 ops/sec ±1.05% (96 runs sampled) +decode: source-map-0.8.0 x 9,289 ops/sec ±0.27% (101 runs sampled) +chrome dev tools x 4,769 ops/sec ±0.18% (100 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 262944 bytes +@jridgewell/sourcemap-codec 1.4.15 25544 bytes +sourcemap-codec 323048 bytes +source-map-0.6.1 507808 bytes +source-map-0.8.0 507480 bytes +Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15 + +Encode speed: +encode: local code x 24,207 ops/sec ±0.79% (95 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 24,288 ops/sec ±0.48% (96 runs sampled) +encode: sourcemap-codec x 6,761 ops/sec ±0.21% (100 runs sampled) +encode: source-map-0.6.1 x 5,374 ops/sec ±0.17% (99 runs sampled) +encode: source-map-0.8.0 x 5,633 ops/sec ±0.32% (99 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15,encode: local code + + +*** + + +react.js.map - 5726 segments + +Decode Memory Usage: +local code 678816 bytes +@jridgewell/sourcemap-codec 1.4.15 678816 bytes +sourcemap-codec 816400 bytes +source-map-0.6.1 2288864 bytes +source-map-0.8.0 721360 bytes +chrome dev tools 1012512 bytes +Smallest memory usage is local code + +Decode speed: +decode: local code x 6,178 ops/sec ±0.19% (98 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 6,261 ops/sec ±0.22% (100 runs sampled) +decode: sourcemap-codec x 4,472 ops/sec ±0.90% (99 runs sampled) +decode: source-map-0.6.1 x 449 ops/sec ±0.31% (95 runs sampled) +decode: source-map-0.8.0 x 3,219 ops/sec ±0.13% (100 runs sampled) +chrome dev tools x 1,743 ops/sec ±0.20% (99 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 140960 bytes +@jridgewell/sourcemap-codec 1.4.15 159808 bytes +sourcemap-codec 969304 bytes +source-map-0.6.1 930520 bytes +source-map-0.8.0 930248 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 8,013 ops/sec ±0.19% (100 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 7,989 ops/sec ±0.20% (101 runs sampled) +encode: sourcemap-codec x 2,472 ops/sec ±0.21% (99 runs sampled) +encode: source-map-0.6.1 x 2,200 ops/sec ±0.17% (99 runs sampled) +encode: source-map-0.8.0 x 2,220 ops/sec ±0.37% (99 runs sampled) +Fastest is encode: local code + + +*** + + +vscode.map - 2141001 segments + +Decode Memory Usage: +local code 198955264 bytes +@jridgewell/sourcemap-codec 1.4.15 199175352 bytes +sourcemap-codec 199102688 bytes +source-map-0.6.1 386323432 bytes +source-map-0.8.0 244116432 bytes +chrome dev tools 293734280 bytes +Smallest memory usage is local code + +Decode speed: +decode: local code x 3.90 ops/sec ±22.21% (15 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 3.95 ops/sec ±23.53% (15 runs sampled) +decode: sourcemap-codec x 3.82 ops/sec ±17.94% (14 runs sampled) +decode: source-map-0.6.1 x 0.61 ops/sec ±7.81% (6 runs sampled) +decode: source-map-0.8.0 x 9.54 ops/sec ±0.28% (28 runs sampled) +chrome dev tools x 2.18 ops/sec ±10.58% (10 runs sampled) +Fastest is decode: source-map-0.8.0 + +Encode Memory Usage: +local code 13509880 bytes +@jridgewell/sourcemap-codec 1.4.15 13537648 bytes +sourcemap-codec 32540104 bytes +source-map-0.6.1 127531040 bytes +source-map-0.8.0 127535312 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 20.10 ops/sec ±0.19% (38 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 20.26 ops/sec ±0.32% (38 runs sampled) +encode: sourcemap-codec x 5.44 ops/sec ±1.64% (18 runs sampled) +encode: source-map-0.6.1 x 2.30 ops/sec ±4.79% (10 runs sampled) +encode: source-map-0.8.0 x 2.46 ops/sec ±6.53% (10 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15 +``` + +# License + +MIT diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs new file mode 100644 index 0000000000000000000000000000000000000000..532bab39f010d1ce7988e3ae3f7e23a28d5a43a5 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs @@ -0,0 +1,423 @@ +// src/vlq.ts +var comma = ",".charCodeAt(0); +var semicolon = ";".charCodeAt(0); +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var intToChar = new Uint8Array(64); +var charToInt = new Uint8Array(128); +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} +function decodeInteger(reader, relative) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -2147483648 | -value; + } + return relative + value; +} +function encodeInteger(builder, num, relative) { + let delta = num - relative; + delta = delta < 0 ? -delta << 1 | 1 : delta << 1; + do { + let clamped = delta & 31; + delta >>>= 5; + if (delta > 0) clamped |= 32; + builder.write(intToChar[clamped]); + } while (delta > 0); + return num; +} +function hasMoreVlq(reader, max) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} + +// src/strings.ts +var bufLength = 1024 * 16; +var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + } +} : { + decode(buf) { + let out = ""; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + } +}; +var StringWriter = class { + constructor() { + this.pos = 0; + this.out = ""; + this.buffer = new Uint8Array(bufLength); + } + write(v) { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + flush() { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +}; +var StringReader = class { + constructor(buffer) { + this.pos = 0; + this.buffer = buffer; + } + next() { + return this.buffer.charCodeAt(this.pos++); + } + peek() { + return this.buffer.charCodeAt(this.pos); + } + indexOf(char) { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +}; + +// src/scopes.ts +var EMPTY = []; +function decodeOriginalScopes(input) { + const { length } = input; + const reader = new StringReader(input); + const scopes = []; + const stack = []; + let line = 0; + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + if (!hasMoreVlq(reader, length)) { + const last = stack.pop(); + last[2] = line; + last[3] = column; + continue; + } + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 1; + const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]; + let vars = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + scopes.push(scope); + stack.push(scope); + } + return scopes; +} +function encodeOriginalScopes(scopes) { + const writer = new StringWriter(); + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + return writer.flush(); +} +function _encodeOriginalScopes(scopes, index, writer, state) { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + if (index > 0) writer.write(comma); + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + const fields = scope.length === 6 ? 1 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + for (const v of vars) { + encodeInteger(writer, v, 0); + } + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + return index; +} +function decodeGeneratedRanges(input) { + const { length } = input; + const reader = new StringReader(input); + const ranges = []; + const stack = []; + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + do { + const semi = reader.indexOf(";"); + let genColumn = 0; + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop(); + last[2] = genLine; + last[3] = genColumn; + continue; + } + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 1; + const hasCallsite = fields & 2; + const hasScope = fields & 4; + let callsite = null; + let bindings = EMPTY; + let range; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0 + ); + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; + } else { + range = [genLine, genColumn, 0, 0]; + } + range.isScope = !!hasScope; + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0 + ); + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + ranges.push(range); + stack.push(range); + } + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + return ranges; +} +function encodeGeneratedRanges(ranges) { + if (ranges.length === 0) return ""; + const writer = new StringWriter(); + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + return writer.flush(); +} +function _encodeGeneratedRanges(ranges, index, writer, state) { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings + } = range; + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + state[1] = encodeInteger(writer, range[1], state[1]); + const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0); + encodeInteger(writer, fields, 0); + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); + encodeInteger(writer, expRange[0], 0); + } + } + } + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + return index; +} +function catchupLine(writer, lastLine, line) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} + +// src/sourcemap-codec.ts +function decode(mappings) { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + do { + const semi = reader.indexOf(";"); + const line = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + while (reader.pos < semi) { + let seg; + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + line.push(seg); + reader.pos++; + } + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + return decoded; +} +function sort(line) { + line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[0] - b[0]; +} +function encode(decoded) { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + let genColumn = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + genColumn = encodeInteger(writer, segment[0], genColumn); + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + return writer.flush(); +} +export { + decode, + decodeGeneratedRanges, + decodeOriginalScopes, + encode, + encodeGeneratedRanges, + encodeOriginalScopes +}; +//# sourceMappingURL=sourcemap-codec.mjs.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c276844b25973802e167a1da9521f7b54f058b72 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/vlq.ts", "../src/strings.ts", "../src/scopes.ts", "../src/sourcemap-codec.ts"], + "mappings": ";AAEO,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,QAAQ;AACd,IAAM,YAAY,IAAI,WAAW,EAAE;AACnC,IAAM,YAAY,IAAI,WAAW,GAAG;AAEpC,SAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAM,IAAI,MAAM,WAAW,CAAC;AAC5B,YAAU,CAAC,IAAI;AACf,YAAU,CAAC,IAAI;AACjB;AAEO,SAAS,cAAc,QAAsB,UAA0B;AAC5E,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,KAAG;AACD,UAAM,IAAI,OAAO,KAAK;AACtB,cAAU,UAAU,CAAC;AACrB,cAAU,UAAU,OAAO;AAC3B,aAAS;AAAA,EACX,SAAS,UAAU;AAEnB,QAAM,eAAe,QAAQ;AAC7B,aAAW;AAEX,MAAI,cAAc;AAChB,YAAQ,cAAc,CAAC;AAAA,EACzB;AAEA,SAAO,WAAW;AACpB;AAEO,SAAS,cAAc,SAAuB,KAAa,UAA0B;AAC1F,MAAI,QAAQ,MAAM;AAElB,UAAQ,QAAQ,IAAK,CAAC,SAAS,IAAK,IAAI,SAAS;AACjD,KAAG;AACD,QAAI,UAAU,QAAQ;AACtB,eAAW;AACX,QAAI,QAAQ,EAAG,YAAW;AAC1B,YAAQ,MAAM,UAAU,OAAO,CAAC;AAAA,EAClC,SAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,SAAS,WAAW,QAAsB,KAAa;AAC5D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IAAI,EAAG,QAAO,MAAM,KAAK;AAE7B,kBAAY,cAAc,QAAQ,QAAQ,CAAC,GAAG,SAAS;AAEvD,UAAI,QAAQ,WAAW,EAAG;AAC1B,qBAAe,cAAc,QAAQ,QAAQ,CAAC,GAAG,YAAY;AAC7D,mBAAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AACzD,qBAAe,cAAc,QAAQ,QAAQ,CAAC,GAAG,YAAY;AAE7D,UAAI,QAAQ,WAAW,EAAG;AAC1B,mBAAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AAAA,IAC3D;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AACtB;", + "names": [] +} diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..2d8e459f3e2f952d02a62b795bab39252a81d481 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js @@ -0,0 +1,464 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.sourcemapCodec = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module) { +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/sourcemap-codec.ts +var sourcemap_codec_exports = {}; +__export(sourcemap_codec_exports, { + decode: () => decode, + decodeGeneratedRanges: () => decodeGeneratedRanges, + decodeOriginalScopes: () => decodeOriginalScopes, + encode: () => encode, + encodeGeneratedRanges: () => encodeGeneratedRanges, + encodeOriginalScopes: () => encodeOriginalScopes +}); +module.exports = __toCommonJS(sourcemap_codec_exports); + +// src/vlq.ts +var comma = ",".charCodeAt(0); +var semicolon = ";".charCodeAt(0); +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var intToChar = new Uint8Array(64); +var charToInt = new Uint8Array(128); +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} +function decodeInteger(reader, relative) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -2147483648 | -value; + } + return relative + value; +} +function encodeInteger(builder, num, relative) { + let delta = num - relative; + delta = delta < 0 ? -delta << 1 | 1 : delta << 1; + do { + let clamped = delta & 31; + delta >>>= 5; + if (delta > 0) clamped |= 32; + builder.write(intToChar[clamped]); + } while (delta > 0); + return num; +} +function hasMoreVlq(reader, max) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} + +// src/strings.ts +var bufLength = 1024 * 16; +var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + } +} : { + decode(buf) { + let out = ""; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + } +}; +var StringWriter = class { + constructor() { + this.pos = 0; + this.out = ""; + this.buffer = new Uint8Array(bufLength); + } + write(v) { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + flush() { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +}; +var StringReader = class { + constructor(buffer) { + this.pos = 0; + this.buffer = buffer; + } + next() { + return this.buffer.charCodeAt(this.pos++); + } + peek() { + return this.buffer.charCodeAt(this.pos); + } + indexOf(char) { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +}; + +// src/scopes.ts +var EMPTY = []; +function decodeOriginalScopes(input) { + const { length } = input; + const reader = new StringReader(input); + const scopes = []; + const stack = []; + let line = 0; + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + if (!hasMoreVlq(reader, length)) { + const last = stack.pop(); + last[2] = line; + last[3] = column; + continue; + } + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 1; + const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]; + let vars = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + scopes.push(scope); + stack.push(scope); + } + return scopes; +} +function encodeOriginalScopes(scopes) { + const writer = new StringWriter(); + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + return writer.flush(); +} +function _encodeOriginalScopes(scopes, index, writer, state) { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + if (index > 0) writer.write(comma); + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + const fields = scope.length === 6 ? 1 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + for (const v of vars) { + encodeInteger(writer, v, 0); + } + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + return index; +} +function decodeGeneratedRanges(input) { + const { length } = input; + const reader = new StringReader(input); + const ranges = []; + const stack = []; + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + do { + const semi = reader.indexOf(";"); + let genColumn = 0; + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop(); + last[2] = genLine; + last[3] = genColumn; + continue; + } + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 1; + const hasCallsite = fields & 2; + const hasScope = fields & 4; + let callsite = null; + let bindings = EMPTY; + let range; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0 + ); + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; + } else { + range = [genLine, genColumn, 0, 0]; + } + range.isScope = !!hasScope; + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0 + ); + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + ranges.push(range); + stack.push(range); + } + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + return ranges; +} +function encodeGeneratedRanges(ranges) { + if (ranges.length === 0) return ""; + const writer = new StringWriter(); + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + return writer.flush(); +} +function _encodeGeneratedRanges(ranges, index, writer, state) { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings + } = range; + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + state[1] = encodeInteger(writer, range[1], state[1]); + const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0); + encodeInteger(writer, fields, 0); + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); + encodeInteger(writer, expRange[0], 0); + } + } + } + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + return index; +} +function catchupLine(writer, lastLine, line) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} + +// src/sourcemap-codec.ts +function decode(mappings) { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + do { + const semi = reader.indexOf(";"); + const line = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + while (reader.pos < semi) { + let seg; + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + line.push(seg); + reader.pos++; + } + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + return decoded; +} +function sort(line) { + line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[0] - b[0]; +} +function encode(decoded) { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + let genColumn = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + genColumn = encodeInteger(writer, segment[0], genColumn); + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + return writer.flush(); +} +})); +//# sourceMappingURL=sourcemap-codec.umd.js.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..abc18d286e183092e99784dedb2651c3a551c20d --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/sourcemap-codec.ts", "../src/vlq.ts", "../src/strings.ts", "../src/scopes.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,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AAA,IAC3D;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AACtB;", + "names": [] +} diff --git a/node_modules/@jridgewell/sourcemap-codec/package.json b/node_modules/@jridgewell/sourcemap-codec/package.json new file mode 100644 index 0000000000000000000000000000000000000000..da551376440ae3d77c4159d2385403459a4f447f --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/package.json @@ -0,0 +1,63 @@ +{ + "name": "@jridgewell/sourcemap-codec", + "version": "1.5.5", + "description": "Encode/decode sourcemap mappings", + "keywords": [ + "sourcemap", + "vlq" + ], + "main": "dist/sourcemap-codec.umd.js", + "module": "dist/sourcemap-codec.mjs", + "types": "types/sourcemap-codec.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/sourcemap-codec.d.mts", + "default": "./dist/sourcemap-codec.mjs" + }, + "default": { + "types": "./types/sourcemap-codec.d.cts", + "default": "./dist/sourcemap-codec.umd.js" + } + }, + "./dist/sourcemap-codec.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs sourcemap-codec.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/sourcemap-codec", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/sourcemap-codec" + }, + "author": "Justin Ridgewell ", + "license": "MIT" +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts b/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts new file mode 100644 index 0000000000000000000000000000000000000000..d194c2f0a66567fdc42e7d4bddc79a5e5d1ad005 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts @@ -0,0 +1,345 @@ +import { StringReader, StringWriter } from './strings'; +import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq'; + +const EMPTY: any[] = []; + +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; + +type Mix = (A & O) | (B & O); + +export type OriginalScope = Mix< + [Line, Column, Line, Column, Kind], + [Line, Column, Line, Column, Kind, Name], + { vars: Var[] } +>; + +export type GeneratedRange = Mix< + [Line, Column, Line, Column], + [Line, Column, Line, Column, SourcesIndex, ScopesIndex], + { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; + } +>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; + +export function decodeOriginalScopes(input: string): OriginalScope[] { + const { length } = input; + const reader = new StringReader(input); + const scopes: OriginalScope[] = []; + const stack: OriginalScope[] = []; + let line = 0; + + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + + if (!hasMoreVlq(reader, length)) { + const last = stack.pop()!; + last[2] = line; + last[3] = column; + continue; + } + + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 0b0001; + + const scope: OriginalScope = ( + hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind] + ) as OriginalScope; + + let vars: Var[] = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + + scopes.push(scope); + stack.push(scope); + } + + return scopes; +} + +export function encodeOriginalScopes(scopes: OriginalScope[]): string { + const writer = new StringWriter(); + + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + + return writer.flush(); +} + +function _encodeOriginalScopes( + scopes: OriginalScope[], + index: number, + writer: StringWriter, + state: [ + number, // GenColumn + ], +): number { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + + if (index > 0) writer.write(comma); + + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + + const fields = scope.length === 6 ? 0b0001 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + + for (const v of vars) { + encodeInteger(writer, v, 0); + } + + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || (l === endLine && c >= endColumn)) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + + return index; +} + +export function decodeGeneratedRanges(input: string): GeneratedRange[] { + const { length } = input; + const reader = new StringReader(input); + const ranges: GeneratedRange[] = []; + const stack: GeneratedRange[] = []; + + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + + do { + const semi = reader.indexOf(';'); + let genColumn = 0; + + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop()!; + last[2] = genLine; + last[3] = genColumn; + continue; + } + + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 0b0001; + const hasCallsite = fields & 0b0010; + const hasScope = fields & 0b0100; + + let callsite: CallSite | null = null; + let bindings: Binding[] = EMPTY; + let range: GeneratedRange; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0, + ); + + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex] as GeneratedRange; + } else { + range = [genLine, genColumn, 0, 0] as GeneratedRange; + } + + range.isScope = !!hasScope; + + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0, + ); + + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges: BindingExpressionRange[]; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + + ranges.push(range); + stack.push(range); + } + + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + + return ranges; +} + +export function encodeGeneratedRanges(ranges: GeneratedRange[]): string { + if (ranges.length === 0) return ''; + + const writer = new StringWriter(); + + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + + return writer.flush(); +} + +function _encodeGeneratedRanges( + ranges: GeneratedRange[], + index: number, + writer: StringWriter, + state: [ + number, // GenLine + number, // GenColumn + number, // DefSourcesIndex + number, // DefScopesIndex + number, // CallSourcesIndex + number, // CallLine + number, // CallColumn + ], +): number { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings, + } = range; + + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + + state[1] = encodeInteger(writer, range[1], state[1]); + + const fields = + (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0); + encodeInteger(writer, fields, 0); + + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite!; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1]!, bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2]!, bindingStartColumn); + encodeInteger(writer, expRange[0]!, 0); + } + } + } + + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || (l === endLine && c >= endColumn)) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + + return index; +} + +function catchupLine(writer: StringWriter, lastLine: number, line: number) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts b/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts new file mode 100644 index 0000000000000000000000000000000000000000..a81f894dc1f18937c58978ee1351b6e70bbc8c86 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts @@ -0,0 +1,111 @@ +import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq'; +import { StringWriter, StringReader } from './strings'; + +export { + decodeOriginalScopes, + encodeOriginalScopes, + decodeGeneratedRanges, + encodeGeneratedRanges, +} from './scopes'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes'; + +export type SourceMapSegment = + | [number] + | [number, number, number, number] + | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; + +export function decode(mappings: string): SourceMapMappings { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded: SourceMapMappings = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + + do { + const semi = reader.indexOf(';'); + const line: SourceMapLine = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + + while (reader.pos < semi) { + let seg: SourceMapSegment; + + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + + line.push(seg); + reader.pos++; + } + + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + + return decoded; +} + +function sort(line: SourceMapSegment[]) { + line.sort(sortComparator); +} + +function sortComparator(a: SourceMapSegment, b: SourceMapSegment): number { + return a[0] - b[0]; +} + +export function encode(decoded: SourceMapMappings): string; +export function encode(decoded: Readonly): string; +export function encode(decoded: Readonly): string { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + + let genColumn = 0; + + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + + genColumn = encodeInteger(writer, segment[0], genColumn); + + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + + return writer.flush(); +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/strings.ts b/node_modules/@jridgewell/sourcemap-codec/src/strings.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1619650ea773450fe1febaf6a1354c4022f04b6 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/strings.ts @@ -0,0 +1,65 @@ +const bufLength = 1024 * 16; + +// Provide a fallback for older environments. +const td = + typeof TextDecoder !== 'undefined' + ? /* #__PURE__ */ new TextDecoder() + : typeof Buffer !== 'undefined' + ? { + decode(buf: Uint8Array): string { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + }, + } + : { + decode(buf: Uint8Array): string { + let out = ''; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + }, + }; + +export class StringWriter { + pos = 0; + private out = ''; + private buffer = new Uint8Array(bufLength); + + write(v: number): void { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + + flush(): string { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +} + +export class StringReader { + pos = 0; + declare private buffer: string; + + constructor(buffer: string) { + this.buffer = buffer; + } + + next(): number { + return this.buffer.charCodeAt(this.pos++); + } + + peek(): number { + return this.buffer.charCodeAt(this.pos); + } + + indexOf(char: string): number { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts b/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts new file mode 100644 index 0000000000000000000000000000000000000000..a42c681511bbec0faecd9aeb9e6e7d5dbea0e391 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts @@ -0,0 +1,55 @@ +import type { StringReader, StringWriter } from './strings'; + +export const comma = ','.charCodeAt(0); +export const semicolon = ';'.charCodeAt(0); + +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +const intToChar = new Uint8Array(64); // 64 possible chars. +const charToInt = new Uint8Array(128); // z is 122 in ASCII + +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} + +export function decodeInteger(reader: StringReader, relative: number): number { + let value = 0; + let shift = 0; + let integer = 0; + + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + + const shouldNegate = value & 1; + value >>>= 1; + + if (shouldNegate) { + value = -0x80000000 | -value; + } + + return relative + value; +} + +export function encodeInteger(builder: StringWriter, num: number, relative: number): number { + let delta = num - relative; + + delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; + do { + let clamped = delta & 0b011111; + delta >>>= 5; + if (delta > 0) clamped |= 0b100000; + builder.write(intToChar[clamped]); + } while (delta > 0); + + return num; +} + +export function hasMoreVlq(reader: StringReader, max: number) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..c583c7560dece416257b832315f89fa58f32c782 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts @@ -0,0 +1,50 @@ +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; +type Mix = (A & O) | (B & O); +export type OriginalScope = Mix<[ + Line, + Column, + Line, + Column, + Kind +], [ + Line, + Column, + Line, + Column, + Kind, + Name +], { + vars: Var[]; +}>; +export type GeneratedRange = Mix<[ + Line, + Column, + Line, + Column +], [ + Line, + Column, + Line, + Column, + SourcesIndex, + ScopesIndex +], { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; +}>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; +export declare function decodeOriginalScopes(input: string): OriginalScope[]; +export declare function encodeOriginalScopes(scopes: OriginalScope[]): string; +export declare function decodeGeneratedRanges(input: string): GeneratedRange[]; +export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string; +export {}; +//# sourceMappingURL=scopes.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..630e6477b73f115c0f660fe2b50b8acb36b54a61 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,GAAG,CAC7B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;CAAC,EAClC;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,IAAI;CAAC,EACxC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAC9B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;CAAC,EAC5B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,YAAY;IAAE,WAAW;CAAC,EACvD;IACE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CACF,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,KAAK,OAAO,GAAG,sBAAsB,EAAE,CAAC;AACxC,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c583c7560dece416257b832315f89fa58f32c782 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts @@ -0,0 +1,50 @@ +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; +type Mix = (A & O) | (B & O); +export type OriginalScope = Mix<[ + Line, + Column, + Line, + Column, + Kind +], [ + Line, + Column, + Line, + Column, + Kind, + Name +], { + vars: Var[]; +}>; +export type GeneratedRange = Mix<[ + Line, + Column, + Line, + Column +], [ + Line, + Column, + Line, + Column, + SourcesIndex, + ScopesIndex +], { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; +}>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; +export declare function decodeOriginalScopes(input: string): OriginalScope[]; +export declare function encodeOriginalScopes(scopes: OriginalScope[]): string; +export declare function decodeGeneratedRanges(input: string): GeneratedRange[]; +export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string; +export {}; +//# sourceMappingURL=scopes.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..630e6477b73f115c0f660fe2b50b8acb36b54a61 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,GAAG,CAC7B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;CAAC,EAClC;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,IAAI;CAAC,EACxC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAC9B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;CAAC,EAC5B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,YAAY;IAAE,WAAW;CAAC,EACvD;IACE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CACF,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,KAAK,OAAO,GAAG,sBAAsB,EAAE,CAAC;AACxC,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5f35e22fbd820a22774712e8ee9a143198181570 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts @@ -0,0 +1,9 @@ +export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.cts'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.cts'; +export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; +export declare function decode(mappings: string): SourceMapMappings; +export declare function encode(decoded: SourceMapMappings): string; +export declare function encode(decoded: Readonly): string; +//# sourceMappingURL=sourcemap-codec.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..7123d5208334960664abfaae0e5b663819462c0b --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..199fb9f534fe625d4c18c27c2b79e2309708279c --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts @@ -0,0 +1,9 @@ +export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.mts'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.mts'; +export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; +export declare function decode(mappings: string): SourceMapMappings; +export declare function encode(decoded: SourceMapMappings): string; +export declare function encode(decoded: Readonly): string; +//# sourceMappingURL=sourcemap-codec.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..7123d5208334960664abfaae0e5b663819462c0b --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..62faceb3de9c90532158206c1ab55ee35ac24a89 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts @@ -0,0 +1,16 @@ +export declare class StringWriter { + pos: number; + private out; + private buffer; + write(v: number): void; + flush(): string; +} +export declare class StringReader { + pos: number; + private buffer; + constructor(buffer: string); + next(): number; + peek(): number; + indexOf(char: string): number; +} +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..d3602da4257449b6145da1bcaf14314073d6f31a --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..62faceb3de9c90532158206c1ab55ee35ac24a89 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts @@ -0,0 +1,16 @@ +export declare class StringWriter { + pos: number; + private out; + private buffer; + write(v: number): void; + flush(): string; +} +export declare class StringReader { + pos: number; + private buffer; + constructor(buffer: string); + next(): number; + peek(): number; + indexOf(char: string): number; +} +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..d3602da4257449b6145da1bcaf14314073d6f31a --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..dbd6602d1876df8089ce52b3309b340d1a088555 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts @@ -0,0 +1,7 @@ +import type { StringReader, StringWriter } from './strings.cts'; +export declare const comma: number; +export declare const semicolon: number; +export declare function decodeInteger(reader: StringReader, relative: number): number; +export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number; +export declare function hasMoreVlq(reader: StringReader, max: number): boolean; +//# sourceMappingURL=vlq.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..6fdc356977cc89df14692e21863ed6724b63a0fc --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2c739bc9fedb038a659a85726a98af7c5f32c5da --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts @@ -0,0 +1,7 @@ +import type { StringReader, StringWriter } from './strings.mts'; +export declare const comma: number; +export declare const semicolon: number; +export declare function decodeInteger(reader: StringReader, relative: number): number; +export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number; +export declare function hasMoreVlq(reader: StringReader, max: number): boolean; +//# sourceMappingURL=vlq.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..6fdc356977cc89df14692e21863ed6724b63a0fc --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/LICENSE b/node_modules/@jridgewell/trace-mapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/trace-mapping/README.md b/node_modules/@jridgewell/trace-mapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9fc0ed09cedeb0eea388b5d2b891b87886830776 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/README.md @@ -0,0 +1,348 @@ +# @jridgewell/trace-mapping + +> Trace the original position through a source map + +`trace-mapping` allows you to take the line and column of an output file and trace it to the +original location in the source file through a source map. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapConsumer`. This +provides the same `originalPositionFor` and `generatedPositionFor` API, without requiring WASM. + +## Installation + +```sh +npm install @jridgewell/trace-mapping +``` + +## Usage + +```typescript +import { + TraceMap, + originalPositionFor, + generatedPositionFor, + sourceContentFor, + isIgnored, +} from '@jridgewell/trace-mapping'; + +const tracer = new TraceMap({ + version: 3, + sources: ['input.js'], + sourcesContent: ['content of input.js'], + names: ['foo'], + mappings: 'KAyCIA', + ignoreList: [], +}); + +// Lines start at line 1, columns at column 0. +const traced = originalPositionFor(tracer, { line: 1, column: 5 }); +assert.deepEqual(traced, { + source: 'input.js', + line: 42, + column: 4, + name: 'foo', +}); + +const content = sourceContentFor(tracer, traced.source); +assert.strictEqual(content, 'content for input.js'); + +const generated = generatedPositionFor(tracer, { + source: 'input.js', + line: 42, + column: 4, +}); +assert.deepEqual(generated, { + line: 1, + column: 5, +}); + +const ignored = isIgnored(tracer, 'input.js'); +assert.equal(ignored, false); +``` + +We also provide a lower level API to get the actual segment that matches our line and column. Unlike +`originalPositionFor`, `traceSegment` uses a 0-base for `line`: + +```typescript +import { traceSegment } from '@jridgewell/trace-mapping'; + +// line is 0-base. +const traced = traceSegment(tracer, /* line */ 0, /* column */ 5); + +// Segments are [outputColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] +// Again, line is 0-base and so is sourceLine +assert.deepEqual(traced, [5, 0, 41, 4, 0]); +``` + +### SectionedSourceMaps + +The sourcemap spec defines a special `sections` field that's designed to handle concatenation of +output code with associated sourcemaps. This type of sourcemap is rarely used (no major build tool +produces it), but if you are hand coding a concatenation you may need it. We provide an `AnyMap` +helper that can receive either a regular sourcemap or a `SectionedSourceMap` and returns a +`TraceMap` instance: + +```typescript +import { AnyMap } from '@jridgewell/trace-mapping'; +const fooOutput = 'foo'; +const barOutput = 'bar'; +const output = [fooOutput, barOutput].join('\n'); + +const sectioned = new AnyMap({ + version: 3, + sections: [ + { + // 0-base line and column + offset: { line: 0, column: 0 }, + // fooOutput's sourcemap + map: { + version: 3, + sources: ['foo.js'], + names: ['foo'], + mappings: 'AAAAA', + }, + }, + { + // barOutput's sourcemap will not affect the first line, only the second + offset: { line: 1, column: 0 }, + map: { + version: 3, + sources: ['bar.js'], + names: ['bar'], + mappings: 'AAAAA', + }, + }, + ], +}); + +const traced = originalPositionFor(sectioned, { + line: 2, + column: 0, +}); + +assert.deepEqual(traced, { + source: 'bar.js', + line: 1, + column: 0, + name: 'bar', +}); +``` + +## Benchmarks + +``` +node v20.10.0 + +amp.js.map - 45120 segments + +Memory Usage: +trace-mapping decoded 414164 bytes +trace-mapping encoded 6274352 bytes +source-map-js 10968904 bytes +source-map-0.6.1 17587160 bytes +source-map-0.8.0 8812155 bytes +Chrome dev tools 8672912 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 205 ops/sec ±0.19% (88 runs sampled) +trace-mapping: encoded JSON input x 405 ops/sec ±1.47% (88 runs sampled) +trace-mapping: decoded Object input x 4,645 ops/sec ±0.15% (98 runs sampled) +trace-mapping: encoded Object input x 458 ops/sec ±1.63% (91 runs sampled) +source-map-js: encoded Object input x 75.48 ops/sec ±1.64% (67 runs sampled) +source-map-0.6.1: encoded Object input x 39.37 ops/sec ±1.44% (53 runs sampled) +Chrome dev tools: encoded Object input x 150 ops/sec ±1.76% (79 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 44,946 ops/sec ±0.16% (99 runs sampled) +trace-mapping: encoded originalPositionFor x 37,995 ops/sec ±1.81% (89 runs sampled) +source-map-js: encoded originalPositionFor x 9,230 ops/sec ±1.36% (93 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 8,057 ops/sec ±0.84% (96 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 28,198 ops/sec ±1.12% (91 runs sampled) +Chrome dev tools: encoded originalPositionFor x 46,276 ops/sec ±1.35% (95 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 204,406 ops/sec ±0.19% (97 runs sampled) +trace-mapping: encoded originalPositionFor x 196,695 ops/sec ±0.24% (99 runs sampled) +source-map-js: encoded originalPositionFor x 11,948 ops/sec ±0.94% (99 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 10,730 ops/sec ±0.36% (100 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 51,427 ops/sec ±0.21% (98 runs sampled) +Chrome dev tools: encoded originalPositionFor x 162,615 ops/sec ±0.18% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +babel.min.js.map - 347793 segments + +Memory Usage: +trace-mapping decoded 18504 bytes +trace-mapping encoded 35428008 bytes +source-map-js 51676808 bytes +source-map-0.6.1 63367136 bytes +source-map-0.8.0 43158400 bytes +Chrome dev tools 50721552 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 17.82 ops/sec ±6.35% (35 runs sampled) +trace-mapping: encoded JSON input x 31.57 ops/sec ±7.50% (43 runs sampled) +trace-mapping: decoded Object input x 867 ops/sec ±0.74% (94 runs sampled) +trace-mapping: encoded Object input x 33.83 ops/sec ±7.66% (46 runs sampled) +source-map-js: encoded Object input x 6.58 ops/sec ±3.31% (20 runs sampled) +source-map-0.6.1: encoded Object input x 4.23 ops/sec ±3.43% (15 runs sampled) +Chrome dev tools: encoded Object input x 22.14 ops/sec ±3.79% (41 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 78,234 ops/sec ±1.48% (29 runs sampled) +trace-mapping: encoded originalPositionFor x 60,761 ops/sec ±1.35% (21 runs sampled) +source-map-js: encoded originalPositionFor x 51,448 ops/sec ±2.17% (89 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 47,221 ops/sec ±1.99% (15 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 84,002 ops/sec ±1.45% (27 runs sampled) +Chrome dev tools: encoded originalPositionFor x 106,457 ops/sec ±1.38% (37 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 930,943 ops/sec ±0.25% (99 runs sampled) +trace-mapping: encoded originalPositionFor x 843,545 ops/sec ±0.34% (97 runs sampled) +source-map-js: encoded originalPositionFor x 114,510 ops/sec ±1.37% (36 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 87,412 ops/sec ±0.72% (92 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 197,709 ops/sec ±0.89% (59 runs sampled) +Chrome dev tools: encoded originalPositionFor x 688,983 ops/sec ±0.33% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +preact.js.map - 1992 segments + +Memory Usage: +trace-mapping decoded 33136 bytes +trace-mapping encoded 254240 bytes +source-map-js 837488 bytes +source-map-0.6.1 961928 bytes +source-map-0.8.0 54384 bytes +Chrome dev tools 709680 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 3,709 ops/sec ±0.13% (99 runs sampled) +trace-mapping: encoded JSON input x 6,447 ops/sec ±0.22% (101 runs sampled) +trace-mapping: decoded Object input x 83,062 ops/sec ±0.23% (100 runs sampled) +trace-mapping: encoded Object input x 14,980 ops/sec ±0.28% (100 runs sampled) +source-map-js: encoded Object input x 2,544 ops/sec ±0.16% (99 runs sampled) +source-map-0.6.1: encoded Object input x 1,221 ops/sec ±0.37% (97 runs sampled) +Chrome dev tools: encoded Object input x 4,241 ops/sec ±0.39% (93 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 91,028 ops/sec ±0.14% (94 runs sampled) +trace-mapping: encoded originalPositionFor x 84,348 ops/sec ±0.26% (98 runs sampled) +source-map-js: encoded originalPositionFor x 26,998 ops/sec ±0.23% (98 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 18,049 ops/sec ±0.26% (100 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 41,916 ops/sec ±0.28% (98 runs sampled) +Chrome dev tools: encoded originalPositionFor x 88,616 ops/sec ±0.14% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 319,960 ops/sec ±0.16% (100 runs sampled) +trace-mapping: encoded originalPositionFor x 302,153 ops/sec ±0.18% (100 runs sampled) +source-map-js: encoded originalPositionFor x 35,574 ops/sec ±0.19% (100 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 19,943 ops/sec ±0.12% (101 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 54,648 ops/sec ±0.20% (99 runs sampled) +Chrome dev tools: encoded originalPositionFor x 278,319 ops/sec ±0.17% (102 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +react.js.map - 5726 segments + +Memory Usage: +trace-mapping decoded 10872 bytes +trace-mapping encoded 681512 bytes +source-map-js 2563944 bytes +source-map-0.6.1 2150864 bytes +source-map-0.8.0 88680 bytes +Chrome dev tools 1149576 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 1,887 ops/sec ±0.28% (99 runs sampled) +trace-mapping: encoded JSON input x 4,749 ops/sec ±0.48% (97 runs sampled) +trace-mapping: decoded Object input x 74,236 ops/sec ±0.11% (99 runs sampled) +trace-mapping: encoded Object input x 5,752 ops/sec ±0.38% (100 runs sampled) +source-map-js: encoded Object input x 806 ops/sec ±0.19% (97 runs sampled) +source-map-0.6.1: encoded Object input x 418 ops/sec ±0.33% (94 runs sampled) +Chrome dev tools: encoded Object input x 1,524 ops/sec ±0.57% (92 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 620,201 ops/sec ±0.33% (96 runs sampled) +trace-mapping: encoded originalPositionFor x 579,548 ops/sec ±0.35% (97 runs sampled) +source-map-js: encoded originalPositionFor x 230,983 ops/sec ±0.62% (54 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 158,145 ops/sec ±0.80% (46 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 343,801 ops/sec ±0.55% (96 runs sampled) +Chrome dev tools: encoded originalPositionFor x 659,649 ops/sec ±0.49% (98 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 2,368,079 ops/sec ±0.32% (98 runs sampled) +trace-mapping: encoded originalPositionFor x 2,134,039 ops/sec ±2.72% (87 runs sampled) +source-map-js: encoded originalPositionFor x 290,120 ops/sec ±2.49% (82 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 187,613 ops/sec ±0.86% (49 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 479,569 ops/sec ±0.65% (96 runs sampled) +Chrome dev tools: encoded originalPositionFor x 2,048,414 ops/sec ±0.24% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +vscode.map - 2141001 segments + +Memory Usage: +trace-mapping decoded 5206584 bytes +trace-mapping encoded 208370336 bytes +source-map-js 278493008 bytes +source-map-0.6.1 391564048 bytes +source-map-0.8.0 257508787 bytes +Chrome dev tools 291053000 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 1.63 ops/sec ±33.88% (9 runs sampled) +trace-mapping: encoded JSON input x 3.29 ops/sec ±36.13% (13 runs sampled) +trace-mapping: decoded Object input x 103 ops/sec ±0.93% (77 runs sampled) +trace-mapping: encoded Object input x 5.42 ops/sec ±28.54% (19 runs sampled) +source-map-js: encoded Object input x 1.07 ops/sec ±13.84% (7 runs sampled) +source-map-0.6.1: encoded Object input x 0.60 ops/sec ±2.43% (6 runs sampled) +Chrome dev tools: encoded Object input x 2.61 ops/sec ±22.00% (11 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 257,019 ops/sec ±0.97% (93 runs sampled) +trace-mapping: encoded originalPositionFor x 179,163 ops/sec ±0.83% (92 runs sampled) +source-map-js: encoded originalPositionFor x 73,337 ops/sec ±1.35% (87 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 38,797 ops/sec ±1.66% (88 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 107,758 ops/sec ±1.94% (45 runs sampled) +Chrome dev tools: encoded originalPositionFor x 188,550 ops/sec ±1.85% (79 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 447,621 ops/sec ±3.64% (94 runs sampled) +trace-mapping: encoded originalPositionFor x 323,698 ops/sec ±5.20% (88 runs sampled) +source-map-js: encoded originalPositionFor x 78,387 ops/sec ±1.69% (89 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 41,016 ops/sec ±3.01% (25 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 124,204 ops/sec ±0.90% (92 runs sampled) +Chrome dev tools: encoded originalPositionFor x 230,087 ops/sec ±2.61% (93 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor +``` + +[source-map]: https://www.npmjs.com/package/source-map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..73a95c77d0329af0dcabf21caaa14a49956d0cbd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs @@ -0,0 +1,493 @@ +// src/trace-mapping.ts +import { encode, decode } from "@jridgewell/sourcemap-codec"; + +// src/resolve.ts +import resolveUri from "@jridgewell/resolve-uri"; + +// src/strip-filename.ts +function stripFilename(path) { + if (!path) return ""; + const index = path.lastIndexOf("/"); + return path.slice(0, index + 1); +} + +// src/resolve.ts +function resolver(mapUrl, sourceRoot) { + const from = stripFilename(mapUrl); + const prefix = sourceRoot ? sourceRoot + "/" : ""; + return (source) => resolveUri(prefix + (source || ""), from); +} + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; +var REV_GENERATED_LINE = 1; +var REV_GENERATED_COLUMN = 2; + +// src/sort.ts +function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + if (!owned) mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} +function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} +function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} +function sortSegments(line, owned) { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; +} + +// src/by-source.ts +function buildBySources(decoded, memos) { + const sources = memos.map(() => []); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + const sourceIndex2 = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const source = sources[sourceIndex2]; + const segs = source[sourceLine] || (source[sourceLine] = []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + return sources; +} + +// src/binary-search.ts +var found = false; +function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + (high - low >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + found = false; + return low - 1; +} +function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1 + }; +} +function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return state.lastIndex = binarySearch(haystack, needle, low, high); +} + +// src/types.ts +function parse(map) { + return typeof map === "string" ? JSON.parse(map) : map; +} + +// src/flatten-map.ts +var FlattenMap = function(map, mapUrl) { + const parsed = parse(map); + if (!("sections" in parsed)) { + return new TraceMap(parsed, mapUrl); + } + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + const ignoreList = []; + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity + ); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList + }; + return presortedDecodedMap(joined); +}; +function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc + ); + } +} +function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const parsed = parse(input); + if ("sections" in parsed) return recurse(...arguments); + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + if (lineI > stopLine) return; + const out = getLine(mappings, lineI); + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + if (lineI === stopLine && column >= stopColumn) return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]] + ); + } + } +} +function append(arr, other) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} +function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} + +// src/trace-mapping.ts +var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)"; +var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)"; +var LEAST_UPPER_BOUND = -1; +var GREATEST_LOWER_BOUND = 1; +var TraceMap = class { + constructor(map, mapUrl) { + const isString = typeof map === "string"; + if (!isString && map._decodedMemo) return map; + const parsed = parse(map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0; + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + const { mappings } = parsed; + if (typeof mappings === "string") { + this._encoded = mappings; + this._decoded = void 0; + } else if (Array.isArray(mappings)) { + this._encoded = void 0; + this._decoded = maybeSort(mappings, isString); + } else if (parsed.sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + this._decodedMemo = memoizedState(); + this._bySources = void 0; + this._bySourceMemos = void 0; + } +}; +function cast(map) { + return map; +} +function encodedMappings(map) { + var _a, _b; + return (_b = (_a = cast(map))._encoded) != null ? _b : _a._encoded = encode(cast(map)._decoded); +} +function decodedMappings(map) { + var _a; + return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)); +} +function traceSegment(map, line, column) { + const decoded = decodedMappings(map); + if (line >= decoded.length) return null; + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND + ); + return index === -1 ? null : segments[index]; +} +function originalPositionFor(map, needle) { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const decoded = decodedMappings(map); + if (line >= decoded.length) return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND + ); + if (index === -1) return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null + ); +} +function generatedPositionFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} +function allGeneratedPositionsFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} +function eachMapping(map, cb) { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name + }); + } + } +} +function sourceIndex(map, source) { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} +function sourceContentFor(map, source) { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} +function isIgnored(map, source) { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} +function presortedDecodedMap(map, mapUrl) { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} +function decodedMap(map) { + return clone(map, decodedMappings(map)); +} +function encodedMap(map) { + return clone(map, encodedMappings(map)); +} +function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || map.x_google_ignoreList + }; +} +function OMapping(source, line, column, name) { + return { source, line, column, name }; +} +function GMapping(line, column) { + return { line, column }; +} +function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + if (index === -1 || index === segments.length) return -1; + return index; +} +function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + if (!found && bias === LEAST_UPPER_BOUND) min++; + if (min === -1 || min === segments.length) return []; + const matchedColumn = found ? column : segments[min][COLUMN]; + if (!found) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} +function generatedPosition(map, source, line, column, bias, all) { + var _a, _b; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex2 = sources.indexOf(source); + if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source); + if (sourceIndex2 === -1) return all ? [] : GMapping(null, null); + const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState)); + const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos)); + const segments = generated[sourceIndex2][line]; + if (segments == null) return all ? [] : GMapping(null, null); + const memo = bySourceMemos[sourceIndex2]; + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} +export { + FlattenMap as AnyMap, + FlattenMap, + GREATEST_LOWER_BOUND, + LEAST_UPPER_BOUND, + TraceMap, + allGeneratedPositionsFor, + decodedMap, + decodedMappings, + eachMapping, + encodedMap, + encodedMappings, + generatedPositionFor, + isIgnored, + originalPositionFor, + presortedDecodedMap, + sourceContentFor, + traceSegment +}; +//# sourceMappingURL=trace-mapping.mjs.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..a78958143be1bbc8f203e6efe48e41663e9ce534 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/trace-mapping.ts", "../src/resolve.ts", "../src/strip-filename.ts", "../src/sourcemap-segment.ts", "../src/sort.ts", "../src/by-source.ts", "../src/binary-search.ts", "../src/types.ts", "../src/flatten-map.ts"], + "mappings": ";AAAA,SAAS,QAAQ,cAAc;;;ACA/B,OAAO,gBAAgB;;;ACGR,SAAR,cAA+B,MAAyC;AAC7E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,QAAQ,KAAK,YAAY,GAAG;AAClC,SAAO,KAAK,MAAM,GAAG,QAAQ,CAAC;AAChC;;;ADHe,SAAR,SACL,QACA,YACS;AACT,QAAM,O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I,IAAK,QAAO,wBAAwB,UAAU,MAAM,MAAM,QAAQ,IAAI;AAE1E,QAAM,QAAQ,qBAAqB,UAAU,MAAM,MAAM,QAAQ,IAAI;AACrE,MAAI,UAAU,GAAI,QAAO,SAAS,MAAM,IAAI;AAE5C,QAAM,UAAU,SAAS,KAAK;AAC9B,SAAO,SAAS,QAAQ,kBAAkB,IAAI,GAAG,QAAQ,oBAAoB,CAAC;AAChF;", + "names": ["sourceIndex", "sourceIndex"] +} diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..0387ae38c67017175d2441333ff49781ca5094fa --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js @@ -0,0 +1,559 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/resolve-uri'), require('@jridgewell/sourcemap-codec')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/resolve-uri', '@jridgewell/sourcemap-codec'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.resolveURI, global.sourcemapCodec); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.traceMapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_resolveURI, require_sourcemapCodec) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/sourcemap-codec +var require_sourcemap_codec = __commonJS({ + "umd:@jridgewell/sourcemap-codec"(exports, module2) { + module2.exports = require_sourcemapCodec; + } +}); + +// umd:@jridgewell/resolve-uri +var require_resolve_uri = __commonJS({ + "umd:@jridgewell/resolve-uri"(exports, module2) { + module2.exports = require_resolveURI; + } +}); + +// src/trace-mapping.ts +var trace_mapping_exports = {}; +__export(trace_mapping_exports, { + AnyMap: () => FlattenMap, + FlattenMap: () => FlattenMap, + GREATEST_LOWER_BOUND: () => GREATEST_LOWER_BOUND, + LEAST_UPPER_BOUND: () => LEAST_UPPER_BOUND, + TraceMap: () => TraceMap, + allGeneratedPositionsFor: () => allGeneratedPositionsFor, + decodedMap: () => decodedMap, + decodedMappings: () => decodedMappings, + eachMapping: () => eachMapping, + encodedMap: () => encodedMap, + encodedMappings: () => encodedMappings, + generatedPositionFor: () => generatedPositionFor, + isIgnored: () => isIgnored, + originalPositionFor: () => originalPositionFor, + presortedDecodedMap: () => presortedDecodedMap, + sourceContentFor: () => sourceContentFor, + traceSegment: () => traceSegment +}); +module.exports = __toCommonJS(trace_mapping_exports); +var import_sourcemap_codec = __toESM(require_sourcemap_codec()); + +// src/resolve.ts +var import_resolve_uri = __toESM(require_resolve_uri()); + +// src/strip-filename.ts +function stripFilename(path) { + if (!path) return ""; + const index = path.lastIndexOf("/"); + return path.slice(0, index + 1); +} + +// src/resolve.ts +function resolver(mapUrl, sourceRoot) { + const from = stripFilename(mapUrl); + const prefix = sourceRoot ? sourceRoot + "/" : ""; + return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from); +} + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; +var REV_GENERATED_LINE = 1; +var REV_GENERATED_COLUMN = 2; + +// src/sort.ts +function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + if (!owned) mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} +function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} +function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} +function sortSegments(line, owned) { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; +} + +// src/by-source.ts +function buildBySources(decoded, memos) { + const sources = memos.map(() => []); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + const sourceIndex2 = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const source = sources[sourceIndex2]; + const segs = source[sourceLine] || (source[sourceLine] = []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + return sources; +} + +// src/binary-search.ts +var found = false; +function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + (high - low >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + found = false; + return low - 1; +} +function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1 + }; +} +function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return state.lastIndex = binarySearch(haystack, needle, low, high); +} + +// src/types.ts +function parse(map) { + return typeof map === "string" ? JSON.parse(map) : map; +} + +// src/flatten-map.ts +var FlattenMap = function(map, mapUrl) { + const parsed = parse(map); + if (!("sections" in parsed)) { + return new TraceMap(parsed, mapUrl); + } + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + const ignoreList = []; + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity + ); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList + }; + return presortedDecodedMap(joined); +}; +function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc + ); + } +} +function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const parsed = parse(input); + if ("sections" in parsed) return recurse(...arguments); + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + if (lineI > stopLine) return; + const out = getLine(mappings, lineI); + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + if (lineI === stopLine && column >= stopColumn) return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]] + ); + } + } +} +function append(arr, other) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} +function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} + +// src/trace-mapping.ts +var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)"; +var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)"; +var LEAST_UPPER_BOUND = -1; +var GREATEST_LOWER_BOUND = 1; +var TraceMap = class { + constructor(map, mapUrl) { + const isString = typeof map === "string"; + if (!isString && map._decodedMemo) return map; + const parsed = parse(map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0; + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + const { mappings } = parsed; + if (typeof mappings === "string") { + this._encoded = mappings; + this._decoded = void 0; + } else if (Array.isArray(mappings)) { + this._encoded = void 0; + this._decoded = maybeSort(mappings, isString); + } else if (parsed.sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + this._decodedMemo = memoizedState(); + this._bySources = void 0; + this._bySourceMemos = void 0; + } +}; +function cast(map) { + return map; +} +function encodedMappings(map) { + var _a, _b; + return (_b = (_a = cast(map))._encoded) != null ? _b : _a._encoded = (0, import_sourcemap_codec.encode)(cast(map)._decoded); +} +function decodedMappings(map) { + var _a; + return (_a = cast(map))._decoded || (_a._decoded = (0, import_sourcemap_codec.decode)(cast(map)._encoded)); +} +function traceSegment(map, line, column) { + const decoded = decodedMappings(map); + if (line >= decoded.length) return null; + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND + ); + return index === -1 ? null : segments[index]; +} +function originalPositionFor(map, needle) { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const decoded = decodedMappings(map); + if (line >= decoded.length) return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND + ); + if (index === -1) return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null + ); +} +function generatedPositionFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} +function allGeneratedPositionsFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} +function eachMapping(map, cb) { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name + }); + } + } +} +function sourceIndex(map, source) { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} +function sourceContentFor(map, source) { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} +function isIgnored(map, source) { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} +function presortedDecodedMap(map, mapUrl) { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} +function decodedMap(map) { + return clone(map, decodedMappings(map)); +} +function encodedMap(map) { + return clone(map, encodedMappings(map)); +} +function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || map.x_google_ignoreList + }; +} +function OMapping(source, line, column, name) { + return { source, line, column, name }; +} +function GMapping(line, column) { + return { line, column }; +} +function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + if (index === -1 || index === segments.length) return -1; + return index; +} +function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + if (!found && bias === LEAST_UPPER_BOUND) min++; + if (min === -1 || min === segments.length) return []; + const matchedColumn = found ? column : segments[min][COLUMN]; + if (!found) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} +function generatedPosition(map, source, line, column, bias, all) { + var _a, _b; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex2 = sources.indexOf(source); + if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source); + if (sourceIndex2 === -1) return all ? [] : GMapping(null, null); + const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState)); + const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos)); + const segments = generated[sourceIndex2][line]; + if (segments == null) return all ? [] : GMapping(null, null); + const memo = bySourceMemos[sourceIndex2]; + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} +})); +//# sourceMappingURL=trace-mapping.umd.js.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..68b0c775d6a8c2d06f07fc5d1d5dd7d86c564b8b --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/sourcemap-codec", "umd:@jridgewell/resolve-uri", "../src/trace-mapping.ts", "../src/resolve.ts", "../src/strip-filename.ts", "../src/sourcemap-segment.ts", "../src/sort.ts", "../src/by-source.ts", "../src/binary-search.ts", "../src/types.ts", "../src/flatten-map.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,6CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,yCAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;;;ACA/B,yBAAuB;;;ACGR,SAAR,cAA+B,MAAyC;AAC7E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,QAAQ,KAAK,YAAY,GAAG;AAClC,SAAO,KAAK,MAAM,GAAG,QAAQ,CAAC;AAChC;;;ADHe,SAAR,SACL,QACA,YACS;AACT,QAAM,OAAO,cAAc,MAAM;AAIjC,QAAM,SAAS,aAAa,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AM,MAAM,QAAQ,IAAI;AAE1E,QAAM,QAAQ,qBAAqB,UAAU,MAAM,MAAM,QAAQ,IAAI;AACrE,MAAI,UAAU,GAAI,QAAO,SAAS,MAAM,IAAI;AAE5C,QAAM,UAAU,SAAS,KAAK;AAC9B,SAAO,SAAS,QAAQ,kBAAkB,IAAI,GAAG,QAAQ,oBAAoB,CAAC;AAChF;", + "names": ["module", "module", "resolveUri", "sourceIndex", "sourceIndex"] +} diff --git a/node_modules/@jridgewell/trace-mapping/package.json b/node_modules/@jridgewell/trace-mapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9d3a1c08e5d4c0316371ed16f966c353ab34e790 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/package.json @@ -0,0 +1,67 @@ +{ + "name": "@jridgewell/trace-mapping", + "version": "0.3.31", + "description": "Trace the original position through a source map", + "keywords": [ + "source", + "map" + ], + "main": "dist/trace-mapping.umd.js", + "module": "dist/trace-mapping.mjs", + "types": "types/trace-mapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/trace-mapping.d.mts", + "default": "./dist/trace-mapping.mjs" + }, + "default": { + "types": "./types/trace-mapping.d.cts", + "default": "./dist/trace-mapping.umd.js" + } + }, + "./dist/trace-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.mjs", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs trace-mapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/trace-mapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } +} diff --git a/node_modules/@jridgewell/trace-mapping/src/binary-search.ts b/node_modules/@jridgewell/trace-mapping/src/binary-search.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1144ad1cdcdf6dcdfbfe3fed3f4daeeb2b1bd8d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/binary-search.ts @@ -0,0 +1,115 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment'; +import { COLUMN } from './sourcemap-segment'; + +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; + +export let found = false; + +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export function binarySearch( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + low: number, + high: number, +): number { + while (low <= high) { + const mid = low + ((high - low) >> 1); + const cmp = haystack[mid][COLUMN] - needle; + + if (cmp === 0) { + found = true; + return mid; + } + + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + found = false; + return low - 1; +} + +export function upperBound( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + index: number, +): number { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} + +export function lowerBound( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + index: number, +): number { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} + +export function memoizedState(): MemoState { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1, + }; +} + +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export function memoizedBinarySearch( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + state: MemoState, + key: number, +): number { + const { lastKey, lastNeedle, lastIndex } = state; + + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + + if (needle >= lastNeedle) { + // lastIndex may be -1 if the previous needle was not found. + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + + return (state.lastIndex = binarySearch(haystack, needle, low, high)); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/by-source.ts b/node_modules/@jridgewell/trace-mapping/src/by-source.ts new file mode 100644 index 0000000000000000000000000000000000000000..1da6af05cae200e2c4df1322a08910d0c5082e37 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/by-source.ts @@ -0,0 +1,41 @@ +import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment'; +import { sortComparator } from './sort'; + +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment'; + +export type Source = ReverseSegment[][]; + +// Rebuilds the original source files, with mappings that are ordered by source line/column instead +// of generated line/column. +export default function buildBySources( + decoded: readonly SourceMapSegment[][], + memos: unknown[], +): Source[] { + const sources: Source[] = memos.map(() => []); + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + + const sourceIndex = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + + const source = sources[sourceIndex]; + const segs = (source[sourceLine] ||= []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + + return sources; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts b/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts new file mode 100644 index 0000000000000000000000000000000000000000..61ac40caabeb70e1759bf67e0582d01240120713 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts @@ -0,0 +1,192 @@ +import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping'; +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, +} from './sourcemap-segment'; +import { parse } from './types'; + +import type { + DecodedSourceMap, + DecodedSourceMapXInput, + EncodedSourceMapXInput, + SectionedSourceMapXInput, + SectionedSourceMapInput, + SectionXInput, + Ro, +} from './types'; +import type { SourceMapSegment } from './sourcemap-segment'; + +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; + +export const FlattenMap: FlattenMap = function (map, mapUrl) { + const parsed = parse(map as SectionedSourceMapInput); + + if (!('sections' in parsed)) { + return new TraceMap(parsed as DecodedSourceMapXInput | EncodedSourceMapXInput, mapUrl); + } + + const mappings: SourceMapSegment[][] = []; + const sources: string[] = []; + const sourcesContent: (string | null)[] = []; + const names: string[] = []; + const ignoreList: number[] = []; + + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity, + ); + + const joined: DecodedSourceMap = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList, + }; + + return presortedDecodedMap(joined); +} as FlattenMap; + +function recurse( + input: SectionedSourceMapXInput, + mapUrl: string | null | undefined, + mappings: SourceMapSegment[][], + sources: string[], + sourcesContent: (string | null)[], + names: string[], + ignoreList: number[], + lineOffset: number, + columnOffset: number, + stopLine: number, + stopColumn: number, +) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc, + ); + } +} + +function addSection( + input: SectionXInput['map'], + mapUrl: string | null | undefined, + mappings: SourceMapSegment[][], + sources: string[], + sourcesContent: (string | null)[], + names: string[], + ignoreList: number[], + lineOffset: number, + columnOffset: number, + stopLine: number, + stopColumn: number, +) { + const parsed = parse(input); + if ('sections' in parsed) return recurse(...(arguments as unknown as Parameters)); + + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + + append(sources, resolvedSources); + append(names, map.names); + + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + + // We can only add so many lines before we step into the range that the next section's map + // controls. When we get to the last line, then we'll start checking the segments to see if + // they've crossed into the column range. But it may not have any columns that overstep, so we + // still need to check that we don't overstep lines, too. + if (lineI > stopLine) return; + + // The out line may already exist in mappings (if we're continuing the line started by a + // previous section). Or, we may have jumped ahead several lines to start this section. + const out = getLine(mappings, lineI); + // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the + // map can be multiple lines), it doesn't. + const cOffset = i === 0 ? columnOffset : 0; + + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + + // If this segment steps into the column range that the next section's map controls, we need + // to stop early. + if (lineI === stopLine && column >= stopColumn) return; + + if (seg.length === 1) { + out.push([column]); + continue; + } + + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 + ? [column, sourcesIndex, sourceLine, sourceColumn] + : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]], + ); + } + } +} + +function append(arr: T[], other: T[]) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} + +function getLine(arr: T[][], index: number): T[] { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/resolve.ts b/node_modules/@jridgewell/trace-mapping/src/resolve.ts new file mode 100644 index 0000000000000000000000000000000000000000..30bfa3b226f8990dc650a372d0fa8300b9521a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/resolve.ts @@ -0,0 +1,16 @@ +import resolveUri from '@jridgewell/resolve-uri'; +import stripFilename from './strip-filename'; + +type Resolve = (source: string | null) => string; +export default function resolver( + mapUrl: string | null | undefined, + sourceRoot: string | undefined, +): Resolve { + const from = stripFilename(mapUrl); + // The sourceRoot is always treated as a directory, if it's not empty. + // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 + // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 + const prefix = sourceRoot ? sourceRoot + '/' : ''; + + return (source) => resolveUri(prefix + (source || ''), from); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/sort.ts b/node_modules/@jridgewell/trace-mapping/src/sort.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d016cb78cfca482b736ec06d25f334d2ab849ff --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/sort.ts @@ -0,0 +1,45 @@ +import { COLUMN } from './sourcemap-segment'; + +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment'; + +export default function maybeSort( + mappings: SourceMapSegment[][], + owned: boolean, +): SourceMapSegment[][] { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + + // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If + // not, we do not want to modify the consumer's input array. + if (!owned) mappings = mappings.slice(); + + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} + +function nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} + +function isSorted(line: SourceMapSegment[]): boolean { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} + +function sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} + +export function sortComparator(a: T, b: T): number { + return a[COLUMN] - b[COLUMN]; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts b/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts new file mode 100644 index 0000000000000000000000000000000000000000..94f1b6ab0d675ecdf00cd0416bcb228cba1ba604 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts @@ -0,0 +1,23 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; + +type GeneratedLine = number; + +export type SourceMapSegment = + | [GeneratedColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; + +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; + +export const COLUMN = 0; +export const SOURCES_INDEX = 1; +export const SOURCE_LINE = 2; +export const SOURCE_COLUMN = 3; +export const NAMES_INDEX = 4; + +export const REV_GENERATED_LINE = 1; +export const REV_GENERATED_COLUMN = 2; diff --git a/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts b/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c889800e196e1728b8f4e6c50dd686b5f874376 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts @@ -0,0 +1,8 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export default function stripFilename(path: string | undefined | null): string { + if (!path) return ''; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts b/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b793d5bb342398516285157e8ed5bc09aef306d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts @@ -0,0 +1,502 @@ +import { encode, decode } from '@jridgewell/sourcemap-codec'; + +import resolver from './resolve'; +import maybeSort from './sort'; +import buildBySources from './by-source'; +import { + memoizedState, + memoizedBinarySearch, + upperBound, + lowerBound, + found as bsFound, +} from './binary-search'; +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, + REV_GENERATED_LINE, + REV_GENERATED_COLUMN, +} from './sourcemap-segment'; +import { parse } from './types'; + +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment'; +import type { + SourceMapV3, + DecodedSourceMap, + EncodedSourceMap, + InvalidOriginalMapping, + OriginalMapping, + InvalidGeneratedMapping, + GeneratedMapping, + SourceMapInput, + Needle, + SourceNeedle, + SourceMap, + EachMapping, + Bias, + XInput, + SectionedSourceMap, + Ro, +} from './types'; +import type { Source } from './by-source'; +import type { MemoState } from './binary-search'; + +export type { SourceMapSegment } from './sourcemap-segment'; +export type { + SourceMap, + DecodedSourceMap, + EncodedSourceMap, + Section, + SectionedSourceMap, + SourceMapV3, + Bias, + EachMapping, + GeneratedMapping, + InvalidGeneratedMapping, + InvalidOriginalMapping, + Needle, + OriginalMapping, + OriginalMapping as Mapping, + SectionedSourceMapInput, + SourceMapInput, + SourceNeedle, + XInput, + EncodedSourceMapXInput, + DecodedSourceMapXInput, + SectionedSourceMapXInput, + SectionXInput, +} from './types'; + +interface PublicMap { + _encoded: TraceMap['_encoded']; + _decoded: TraceMap['_decoded']; + _decodedMemo: TraceMap['_decodedMemo']; + _bySources: TraceMap['_bySources']; + _bySourceMemos: TraceMap['_bySourceMemos']; +} + +const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; +const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; + +export const LEAST_UPPER_BOUND = -1; +export const GREATEST_LOWER_BOUND = 1; + +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map'; + +export class TraceMap implements SourceMap { + declare version: SourceMapV3['version']; + declare file: SourceMapV3['file']; + declare names: SourceMapV3['names']; + declare sourceRoot: SourceMapV3['sourceRoot']; + declare sources: SourceMapV3['sources']; + declare sourcesContent: SourceMapV3['sourcesContent']; + declare ignoreList: SourceMapV3['ignoreList']; + + declare resolvedSources: string[]; + declare private _encoded: string | undefined; + + declare private _decoded: SourceMapSegment[][] | undefined; + declare private _decodedMemo: MemoState; + + declare private _bySources: Source[] | undefined; + declare private _bySourceMemos: MemoState[] | undefined; + + constructor(map: Ro, mapUrl?: string | null) { + const isString = typeof map === 'string'; + if (!isString && (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap; + + const parsed = parse(map as Exclude); + + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || (parsed as XInput).x_google_ignoreList || undefined; + + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + + const { mappings } = parsed; + if (typeof mappings === 'string') { + this._encoded = mappings; + this._decoded = undefined; + } else if (Array.isArray(mappings)) { + this._encoded = undefined; + this._decoded = maybeSort(mappings, isString); + } else if ((parsed as unknown as SectionedSourceMap).sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + + this._decodedMemo = memoizedState(); + this._bySources = undefined; + this._bySourceMemos = undefined; + } +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the map into a type + * with public access modifiers. + */ +function cast(map: unknown): PublicMap { + return map as any; +} + +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export function encodedMappings(map: TraceMap): EncodedSourceMap['mappings'] { + return (cast(map)._encoded ??= encode(cast(map)._decoded!)); +} + +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export function decodedMappings(map: TraceMap): Readonly { + return (cast(map)._decoded ||= decode(cast(map)._encoded!)); +} + +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export function traceSegment( + map: TraceMap, + line: number, + column: number, +): Readonly | null { + const decoded = decodedMappings(map); + + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) return null; + + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND, + ); + + return index === -1 ? null : segments[index]; +} + +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export function originalPositionFor( + map: TraceMap, + needle: Needle, +): OriginalMapping | InvalidOriginalMapping { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + + const decoded = decodedMappings(map); + + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) return OMapping(null, null, null, null); + + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND, + ); + + if (index === -1) return OMapping(null, null, null, null); + + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null, + ); +} + +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export function generatedPositionFor( + map: TraceMap, + needle: SourceNeedle, +): GeneratedMapping | InvalidGeneratedMapping { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} + +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[] { + const { source, line, column, bias } = needle; + // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} + +/** + * Iterates each mapping in generated position order. + */ +export function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name, + } as EachMapping); + } + } +} + +function sourceIndex(map: TraceMap, source: string): number { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} + +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export function sourceContentFor(map: TraceMap, source: string): string | null { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} + +/** + * Determines if the source is marked to ignore by the source map. + */ +export function isIgnored(map: TraceMap, source: string): boolean { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} + +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} + +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function decodedMap( + map: TraceMap, +): Omit & { mappings: readonly SourceMapSegment[][] } { + return clone(map, decodedMappings(map)); +} + +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function encodedMap(map: TraceMap): EncodedSourceMap { + return clone(map, encodedMappings(map)); +} + +function clone( + map: TraceMap | DecodedSourceMap, + mappings: T, +): T extends string ? EncodedSourceMap : DecodedSourceMap { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || (map as XInput).x_google_ignoreList, + } as any; +} + +function OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping; +function OMapping( + source: string, + line: number, + column: number, + name: string | null, +): OriginalMapping; +function OMapping( + source: string | null, + line: number | null, + column: number | null, + name: string | null, +): OriginalMapping | InvalidOriginalMapping { + return { source, line, column, name } as any; +} + +function GMapping(line: null, column: null): InvalidGeneratedMapping; +function GMapping(line: number, column: number): GeneratedMapping; +function GMapping( + line: number | null, + column: number | null, +): GeneratedMapping | InvalidGeneratedMapping { + return { line, column } as any; +} + +function traceSegmentInternal( + segments: SourceMapSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number; +function traceSegmentInternal( + segments: ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number; +function traceSegmentInternal( + segments: SourceMapSegment[] | ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number { + let index = memoizedBinarySearch(segments, column, memo, line); + if (bsFound) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + + if (index === -1 || index === segments.length) return -1; + return index; +} + +function sliceGeneratedPositions( + segments: ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): GeneratedMapping[] { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + + // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in + // insertion order) segment that matched. Even if we did respect the bias when tracing, we would + // still need to call `lowerBound()` to find the first segment, which is slower than just looking + // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the + // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to + // match LEAST_UPPER_BOUND. + if (!bsFound && bias === LEAST_UPPER_BOUND) min++; + + if (min === -1 || min === segments.length) return []; + + // We may have found the segment that started at an earlier column. If this is the case, then we + // need to slice all generated segments that match _that_ column, because all such segments span + // to our desired column. + const matchedColumn = bsFound ? column : segments[min][COLUMN]; + + // The binary search is not guaranteed to find the lower bound when a match wasn't found. + if (!bsFound) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} + +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: false, +): GeneratedMapping | InvalidGeneratedMapping; +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: true, +): GeneratedMapping[]; +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: boolean, +): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] { + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + + const { sources, resolvedSources } = map; + let sourceIndex = sources.indexOf(source); + if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source); + if (sourceIndex === -1) return all ? [] : GMapping(null, null); + + const bySourceMemos = (cast(map)._bySourceMemos ||= sources.map(memoizedState)); + const generated = (cast(map)._bySources ||= buildBySources(decodedMappings(map), bySourceMemos)); + + const segments = generated[sourceIndex][line]; + if (segments == null) return all ? [] : GMapping(null, null); + + const memo = bySourceMemos[sourceIndex]; + + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/types.ts b/node_modules/@jridgewell/trace-mapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..730a61fb5ca1e2a389b6bff8dc773828a0372421 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/types.ts @@ -0,0 +1,114 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping'; + +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} + +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} + +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} + +export interface Section { + offset: { line: number; column: number }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} + +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} + +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; + +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; + +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; + +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; + +export type XInput = { x_google_ignoreList?: SourceMapV3['ignoreList'] }; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; + +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; + +export type Needle = { line: number; column: number; bias?: Bias }; +export type SourceNeedle = { source: string; line: number; column: number; bias?: Bias }; + +export type EachMapping = + | { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; + } + | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; + }; + +export abstract class SourceMap { + declare version: SourceMapV3['version']; + declare file: SourceMapV3['file']; + declare names: SourceMapV3['names']; + declare sourceRoot: SourceMapV3['sourceRoot']; + declare sources: SourceMapV3['sources']; + declare sourcesContent: SourceMapV3['sourcesContent']; + declare resolvedSources: SourceMapV3['sources']; + declare ignoreList: SourceMapV3['ignoreList']; +} + +export type Ro = + T extends Array + ? V[] | Readonly | RoArray | Readonly> + : T extends object + ? T | Readonly | RoObject | Readonly> + : T; +type RoArray = Ro[]; +type RoObject = { [K in keyof T]: T[K] | Ro }; + +export function parse(map: T): Exclude { + return typeof map === 'string' ? JSON.parse(map) : (map as Exclude); +} diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..b7bb85c913b38b846273813e77c3c9aecbcaa3cd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts @@ -0,0 +1,33 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment.cts'; +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; +export declare let found: boolean; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number; +export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function memoizedState(): MemoState; +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number; +//# sourceMappingURL=binary-search.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..648e84c1e7a5c587e300fe348389c500fa2af2c6 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"binary-search.d.ts","sourceRoot":"","sources":["../src/binary-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5E,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,IAAI,KAAK,SAAQ,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,CAmBR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,aAAa,IAAI,SAAS,CAMzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAsBR"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..19e1e6b9eb4e26e90df2e4bc21d1e27ae149d132 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts @@ -0,0 +1,33 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment.mts'; +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; +export declare let found: boolean; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number; +export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function memoizedState(): MemoState; +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number; +//# sourceMappingURL=binary-search.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..648e84c1e7a5c587e300fe348389c500fa2af2c6 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"binary-search.d.ts","sourceRoot":"","sources":["../src/binary-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5E,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,IAAI,KAAK,SAAQ,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,CAmBR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,aAAa,IAAI,SAAS,CAMzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAsBR"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..da496939c7c9d357a14710fcf16254e54e129c17 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.cts'; +export type Source = ReverseSegment[][]; +export = function buildBySources(decoded: readonly SourceMapSegment[][], memos: unknown[]): Source[]; +//# sourceMappingURL=by-source.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..32d2a7a1a941010c0b0315b458ba23d53d839b35 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"by-source.d.ts","sourceRoot":"","sources":["../src/by-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,MAAM,MAAM,GAAG,cAAc,EAAE,EAAE,CAAC;AAIxC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EAAE,EACtC,KAAK,EAAE,OAAO,EAAE,GACf,MAAM,EAAE,CA4BV"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f36104955fbc695200a077cb96bc6019ec73c7c0 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.mts'; +export type Source = ReverseSegment[][]; +export default function buildBySources(decoded: readonly SourceMapSegment[][], memos: unknown[]): Source[]; +//# sourceMappingURL=by-source.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..32d2a7a1a941010c0b0315b458ba23d53d839b35 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"by-source.d.ts","sourceRoot":"","sources":["../src/by-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,MAAM,MAAM,GAAG,cAAc,EAAE,EAAE,CAAC;AAIxC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EAAE,EACtC,KAAK,EAAE,OAAO,EAAE,GACf,MAAM,EAAE,CA4BV"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..433d849b7c4a8cec8c2dc50013b26b2ebd5f61ad --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts @@ -0,0 +1,9 @@ +import { TraceMap } from './trace-mapping.cts'; +import type { SectionedSourceMapInput, Ro } from './types.cts'; +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; +export declare const FlattenMap: FlattenMap; +export {}; +//# sourceMappingURL=flatten-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..994b208adfdb40a78e7b788b3bb039ca5da41031 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"flatten-map.d.ts","sourceRoot":"","sources":["../src/flatten-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,iBAAiB,CAAC;AAUjF,OAAO,KAAK,EAKV,uBAAuB,EAEvB,EAAE,EACH,MAAM,SAAS,CAAC;AAGjB,KAAK,UAAU,GAAG;IAChB,KAAK,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IACzE,CAAC,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAsCV,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..444a1bed55f5210de610d9dd8360ce9c8db37f10 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts @@ -0,0 +1,9 @@ +import { TraceMap } from './trace-mapping.mts'; +import type { SectionedSourceMapInput, Ro } from './types.mts'; +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; +export declare const FlattenMap: FlattenMap; +export {}; +//# sourceMappingURL=flatten-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..994b208adfdb40a78e7b788b3bb039ca5da41031 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"flatten-map.d.ts","sourceRoot":"","sources":["../src/flatten-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,iBAAiB,CAAC;AAUjF,OAAO,KAAK,EAKV,uBAAuB,EAEvB,EAAE,EACH,MAAM,SAAS,CAAC;AAGjB,KAAK,UAAU,GAAG;IAChB,KAAK,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IACzE,CAAC,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAsCV,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..62aeedb5b381de715b75ad8d15553fae994ee079 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts @@ -0,0 +1,4 @@ +type Resolve = (source: string | null) => string; +export = function resolver(mapUrl: string | null | undefined, sourceRoot: string | undefined): Resolve; +export {}; +//# sourceMappingURL=resolve.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f155ace7bab5ceb34974af9ea919c4760c4e9a4 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC;AACjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAQT"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e2798a19ccb20ab2d94ffa7a8bd1bab03303fe69 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts @@ -0,0 +1,4 @@ +type Resolve = (source: string | null) => string; +export default function resolver(mapUrl: string | null | undefined, sourceRoot: string | undefined): Resolve; +export {}; +//# sourceMappingURL=resolve.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f155ace7bab5ceb34974af9ea919c4760c4e9a4 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC;AACjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAQT"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.cts b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..aa14c129008da878cf9443414951b8a9c2d0799f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.cts'; +export = function maybeSort(mappings: SourceMapSegment[][], owned: boolean): SourceMapSegment[][]; +export declare function sortComparator(a: T, b: T): number; +//# sourceMappingURL=sort.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..48b8e67418d400b7c68921231f0028b2cee0652a --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAC9B,KAAK,EAAE,OAAO,GACb,gBAAgB,EAAE,EAAE,CAYtB;AAuBD,wBAAgB,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAE9F"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.mts b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c5b94e64fd5595680120201212a03e905ebeb4c3 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.mts'; +export default function maybeSort(mappings: SourceMapSegment[][], owned: boolean): SourceMapSegment[][]; +export declare function sortComparator(a: T, b: T): number; +//# sourceMappingURL=sort.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..48b8e67418d400b7c68921231f0028b2cee0652a --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAC9B,KAAK,EAAE,OAAO,GACb,gBAAgB,EAAE,EAAE,CAYtB;AAuBD,wBAAgB,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAE9F"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..8d3cabc13032461848e6bcef75d702402517991f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts @@ -0,0 +1,17 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +type GeneratedLine = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export declare const REV_GENERATED_LINE = 1; +export declare const REV_GENERATED_COLUMN = 2; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..0c94a4610db499464df13dfe8456019983053a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,KAAK,aAAa,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8d3cabc13032461848e6bcef75d702402517991f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts @@ -0,0 +1,17 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +type GeneratedLine = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export declare const REV_GENERATED_LINE = 1; +export declare const REV_GENERATED_COLUMN = 2; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..0c94a4610db499464df13dfe8456019983053a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,KAAK,aAAa,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..8b3c0e9b9b8b4d94280c825ec48f41b4db0310a2 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts @@ -0,0 +1,5 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export = function stripFilename(path: string | undefined | null): string; +//# sourceMappingURL=strip-filename.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..17a25da0d4301a031587b6098f8a21f987b909f9 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"strip-filename.d.ts","sourceRoot":"","sources":["../src/strip-filename.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAI7E"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cbbaee0db3016c0532f2b10e6acc31ee28c8a48f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts @@ -0,0 +1,5 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export default function stripFilename(path: string | undefined | null): string; +//# sourceMappingURL=strip-filename.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..17a25da0d4301a031587b6098f8a21f987b909f9 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"strip-filename.d.ts","sourceRoot":"","sources":["../src/strip-filename.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAI7E"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..a40f305476fd50c93d8209b43a09cba84f4bc68d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts @@ -0,0 +1,80 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping, Ro } from './types.cts'; +export type { SourceMapSegment } from './sourcemap-segment.cts'; +export type { SourceMap, DecodedSourceMap, EncodedSourceMap, Section, SectionedSourceMap, SourceMapV3, Bias, EachMapping, GeneratedMapping, InvalidGeneratedMapping, InvalidOriginalMapping, Needle, OriginalMapping, OriginalMapping as Mapping, SectionedSourceMapInput, SourceMapInput, SourceNeedle, XInput, EncodedSourceMapXInput, DecodedSourceMapXInput, SectionedSourceMapXInput, SectionXInput, } from './types.cts'; +export declare const LEAST_UPPER_BOUND = -1; +export declare const GREATEST_LOWER_BOUND = 1; +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map.cts'; +export declare class TraceMap implements SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + ignoreList: SourceMapV3['ignoreList']; + resolvedSources: string[]; + private _encoded; + private _decoded; + private _decodedMemo; + private _bySources; + private _bySourceMemos; + constructor(map: Ro, mapUrl?: string | null); +} +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export declare function encodedMappings(map: TraceMap): EncodedSourceMap['mappings']; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export declare function decodedMappings(map: TraceMap): Readonly; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export declare function traceSegment(map: TraceMap, line: number, column: number): Readonly | null; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export declare function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[]; +/** + * Iterates each mapping in generated position order. + */ +export declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export declare function sourceContentFor(map: TraceMap, source: string): string | null; +/** + * Determines if the source is marked to ignore by the source map. + */ +export declare function isIgnored(map: TraceMap, source: string): boolean; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export declare function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function decodedMap(map: TraceMap): Omit & { + mappings: readonly SourceMapSegment[][]; +}; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function encodedMap(map: TraceMap): EncodedSourceMap; +//# sourceMappingURL=trace-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..b5a874c05a941f0f90a77a747f6ff27bd97200be --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.c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,GAAG,MAAM,GAAG,IAAI,CAK7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAIpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,GACZ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAA;CAAE,CAElF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CAE1D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bc2ff0f10ada49589f151943d011f212852abd81 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts @@ -0,0 +1,80 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping, Ro } from './types.mts'; +export type { SourceMapSegment } from './sourcemap-segment.mts'; +export type { SourceMap, DecodedSourceMap, EncodedSourceMap, Section, SectionedSourceMap, SourceMapV3, Bias, EachMapping, GeneratedMapping, InvalidGeneratedMapping, InvalidOriginalMapping, Needle, OriginalMapping, OriginalMapping as Mapping, SectionedSourceMapInput, SourceMapInput, SourceNeedle, XInput, EncodedSourceMapXInput, DecodedSourceMapXInput, SectionedSourceMapXInput, SectionXInput, } from './types.mts'; +export declare const LEAST_UPPER_BOUND = -1; +export declare const GREATEST_LOWER_BOUND = 1; +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map.mts'; +export declare class TraceMap implements SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + ignoreList: SourceMapV3['ignoreList']; + resolvedSources: string[]; + private _encoded; + private _decoded; + private _decodedMemo; + private _bySources; + private _bySourceMemos; + constructor(map: Ro, mapUrl?: string | null); +} +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export declare function encodedMappings(map: TraceMap): EncodedSourceMap['mappings']; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export declare function decodedMappings(map: TraceMap): Readonly; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export declare function traceSegment(map: TraceMap, line: number, column: number): Readonly | null; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export declare function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[]; +/** + * Iterates each mapping in generated position order. + */ +export declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export declare function sourceContentFor(map: TraceMap, source: string): string | null; +/** + * Determines if the source is marked to ignore by the source map. + */ +export declare function isIgnored(map: TraceMap, source: string): boolean; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export declare function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function decodedMap(map: TraceMap): Omit & { + mappings: readonly SourceMapSegment[][]; +}; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function encodedMap(map: TraceMap): EncodedSourceMap; +//# sourceMappingURL=trace-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..b5a874c05a941f0f90a77a747f6ff27bd97200be --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"trace-mapping.d.ts","sourceRoot":"","sources":["../src/trace-mapping.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,YAAY,EACZ,SAAS,EACT,WAAW,EAIX,EAAE,EACH,MAAM,SAAS,CAAC;AAIjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,MAAM,EACN,eAAe,EACf,eAAe,IAAI,OAAO,EAC1B,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,GACd,MAAM,SAA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,EACb,MAAM,EAAE,MAAM,GACb,eAAe,GAAG,sBAAsB,CAiC1C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,YAAY,GACnB,gBAAgB,GAAG,uBAAuB,CAG5C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE,CAIhG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAgCnF;AASD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAIpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,GACZ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAA;CAAE,CAElF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CAE1D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.cts b/node_modules/@jridgewell/trace-mapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..729c2c3218138386b9ac9e462ed46b2503c2407d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.cts @@ -0,0 +1,107 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping.cts'; +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} +export interface Section { + offset: { + line: number; + column: number; + }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; +export type XInput = { + x_google_ignoreList?: SourceMapV3['ignoreList']; +}; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; +export type Needle = { + line: number; + column: number; + bias?: Bias; +}; +export type SourceNeedle = { + source: string; + line: number; + column: number; + bias?: Bias; +}; +export type EachMapping = { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; +} | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; +}; +export declare abstract class SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: SourceMapV3['sources']; + ignoreList: SourceMapV3['ignoreList']; +} +export type Ro = T extends Array ? V[] | Readonly | RoArray | Readonly> : T extends object ? T | Readonly | RoObject | Readonly> : T; +type RoArray = Ro[]; +type RoObject = { + [K in keyof T]: T[K] | Ro; +}; +export declare function parse(map: T): Exclude; +export {}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..922478396d1e658b7b43c40a4e461bf1d3e327fd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEzF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,OAAO;I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WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC9C,eAAe,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACxC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,EAAE,CAAC,CAAC,IACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GACvD,CAAC,SAAS,MAAM,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GACrD,CAAC,CAAC;AACV,KAAK,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1B,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvD,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAEnD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.mts b/node_modules/@jridgewell/trace-mapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a26d1866b4832bbce021f14bdcd28af6eb5db464 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.mts @@ -0,0 +1,107 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping.mts'; +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} +export interface Section { + offset: { + line: number; + column: number; + }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; +export type XInput = { + x_google_ignoreList?: SourceMapV3['ignoreList']; +}; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; +export type Needle = { + line: number; + column: number; + bias?: Bias; +}; +export type SourceNeedle = { + source: string; + line: number; + column: number; + bias?: Bias; +}; +export type EachMapping = { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; +} | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; +}; +export declare abstract class SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: SourceMapV3['sources']; + ignoreList: SourceMapV3['ignoreList']; +} +export type Ro = T extends Array ? V[] | Readonly | RoArray | Readonly> : T extends object ? T | Readonly | RoObject | Readonly> : T; +type RoArray = Ro[]; +type RoObject = { + [K in keyof T]: T[K] | Ro; +}; +export declare function parse(map: T): Exclude; +export {}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..922478396d1e658b7b43c40a4e461bf1d3e327fd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEzF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,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,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC9C,eAAe,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACxC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,EAAE,CAAC,CAAC,IACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GACvD,CAAC,SAAS,MAAM,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GACrD,CAAC,CAAC;AACV,KAAK,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1B,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvD,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAEnD"} \ No newline at end of file diff --git a/node_modules/@mapbox/geojson-rewind/LICENSE.txt b/node_modules/@mapbox/geojson-rewind/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..707b7910f0c9fea85374a4e5d0394ac56eaf1623 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/LICENSE.txt @@ -0,0 +1,13 @@ +Copyright (c) 2020, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/@mapbox/geojson-rewind/README.md b/node_modules/@mapbox/geojson-rewind/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3cbba71891f3dfeeefa33e3a5d30a7500c7f10e3 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/README.md @@ -0,0 +1,32 @@ +[![Build Status](https://travis-ci.org/mapbox/geojson-rewind.png)](https://travis-ci.org/mapbox/geojson-rewind) + +# geojson-rewind + +The [GeoJSON](https://tools.ietf.org/html/rfc7946) specification is [picky about winding order](https://tools.ietf.org/html/rfc7946#section-3.1.6). + +This helps you generate compliant Polygon and MultiPolygon geometries. Furthermore it lets you use [Canvas](http://www.bit-101.com/blog/?p=3702) and other drawing libraries's default behavior to color the interior rings of Polygon and MultiPolygon features. + +## Usage + +As NPM module: + + npm install --save @mapbox/geojson-rewind + +As a console utility: + + # install + npm install -g @mapbox/geojson-rewind + # use + geojson-rewind foo.geojson + +As a browser library: [geojson-rewind.js](https://bundle.run/geojson-rewind) + +## API + +`rewind(geojson, clockwise)` + +Given a GeoJSON FeatureCollection, Feature, or Geometry, return a version +with inner and outer rings of different winding orders. + +If `clockwise` is `true`, the outer ring is clockwise, otherwise +it is counterclockwise. diff --git a/node_modules/@mapbox/geojson-rewind/geojson-rewind b/node_modules/@mapbox/geojson-rewind/geojson-rewind new file mode 100644 index 0000000000000000000000000000000000000000..d3352a1662c38955ecb61a8e94aa45ad830d0f2f --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/geojson-rewind @@ -0,0 +1,33 @@ +#!/usr/bin/env node + +var rewind = require('./'), + getStream = require('get-stream'), + fs = require('fs'), + argv = require('minimist')(process.argv.slice(2), { + boolean: 'clockwise' + }); + +const help = ` +usage: + + geojson-rewind < foo.geojson > foo.geojson + geojson-rewind foo.geojson > bar.geojson + +options: + + --clockwise + + if specified, set outer ring to clockwise + and inner rings to counterclockwise`.trim(); + +if (process.stdin.isTTY && !argv._[0]) { + console.log(help); + process.exit(1); +} + +getStream(argv._.length ? fs.createReadStream(argv._[0]) : process.stdin) + .then(convert); + +function convert(data) { + process.stdout.write(JSON.stringify(rewind(JSON.parse(data), argv.clockwise))); +} diff --git a/node_modules/@mapbox/geojson-rewind/index.js b/node_modules/@mapbox/geojson-rewind/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a0e31e9dd78b84b75e87ef13575fee9991006157 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/index.js @@ -0,0 +1,44 @@ + +module.exports = rewind; + +function rewind(gj, outer) { + var type = gj && gj.type, i; + + if (type === 'FeatureCollection') { + for (i = 0; i < gj.features.length; i++) rewind(gj.features[i], outer); + + } else if (type === 'GeometryCollection') { + for (i = 0; i < gj.geometries.length; i++) rewind(gj.geometries[i], outer); + + } else if (type === 'Feature') { + rewind(gj.geometry, outer); + + } else if (type === 'Polygon') { + rewindRings(gj.coordinates, outer); + + } else if (type === 'MultiPolygon') { + for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer); + } + + return gj; +} + +function rewindRings(rings, outer) { + if (rings.length === 0) return; + + rewindRing(rings[0], outer); + for (var i = 1; i < rings.length; i++) { + rewindRing(rings[i], !outer); + } +} + +function rewindRing(ring, dir) { + var area = 0, err = 0; + for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) { + var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]); + var m = area + k; + err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area; + area = m; + } + if (area + err >= 0 !== !!dir) ring.reverse(); +} diff --git a/node_modules/@mapbox/geojson-rewind/package.json b/node_modules/@mapbox/geojson-rewind/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b64cf8f7b490dfd05efb856bbe3675b28e977c9b --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/package.json @@ -0,0 +1,41 @@ +{ + "name": "@mapbox/geojson-rewind", + "version": "0.5.2", + "description": "enforce winding order for geojson", + "main": "index.js", + "bin": "geojson-rewind", + "directories": { + "test": "test" + }, + "scripts": { + "test": "tape test/rewind.js" + }, + "files": [ + "index.js", + "geojson-rewind" + ], + "repository": { + "type": "git", + "url": "git://github.com/mapbox/geojson-rewind.git" + }, + "keywords": [ + "geojson", + "winding", + "order", + "rendering", + "coordinates" + ], + "author": "Tom MacWright", + "license": "ISC", + "bugs": { + "url": "https://github.com/mapbox/geojson-rewind/issues" + }, + "homepage": "https://github.com/mapbox/geojson-rewind", + "dependencies": { + "get-stream": "^6.0.1", + "minimist": "^1.2.6" + }, + "devDependencies": { + "tape": "^5.5.3" + } +} diff --git a/node_modules/@mapbox/geojson-types/.flowconfig b/node_modules/@mapbox/geojson-types/.flowconfig new file mode 100644 index 0000000000000000000000000000000000000000..8ede2d1fbb9226ac7603b1b6a1bc581afeb68509 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/.flowconfig @@ -0,0 +1,17 @@ +[ignore] +.*/jsonlint-lines/.* + +[include] + +[libs] + +[lints] + +[options] + +[strict] +nonstrict-import +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import diff --git a/node_modules/@mapbox/geojson-types/LICENSE b/node_modules/@mapbox/geojson-types/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b039a712877a2bf4d16006c98db818cb9186bed0 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Mapbox + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@mapbox/geojson-types/README.md b/node_modules/@mapbox/geojson-types/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8c3baa1a784df94eaef66fd3303de48f0afc43ab --- /dev/null +++ b/node_modules/@mapbox/geojson-types/README.md @@ -0,0 +1,41 @@ +# geojson-types + +Flow type declarations for [GeoJSON](https://tools.ietf.org/html/rfc7946). + + +## Install + +``` +npm install @mapbox/geojson-types +``` + +## Use + +```js +// @flow + +import type { + GeoJSONFeatureCollection, + GeoJSONFeature, + + // specific geometries + GeoJSONPoint, + GeoJSONLineString, + GeoJSONPolygon, + GeoJSONMultiPoint, + GeoJSONMultiLineString, + GeoJSONMultiPolygon, + + // any geometry + GeoJSONGeometry, + + // any feature collection, feature, or geometry + GeoJSON, +} from '@mapbox/geojson-types'; + +function doSomething(data: GeoJSON) { + // ... +} +``` + + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..c1c1d01692d0fd6fc2f3499c85808d04b79fbce1 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow @@ -0,0 +1,13 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const wrongIdType: GeoJSONFeature = { + type: 'Feature', + geometry: null, + properties: {}, + id: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..901edf6100c78f31cec498817eb5127bb378e04f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow @@ -0,0 +1,12 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const wrongType: GeoJSONFeature = { + type: 'NotFeature', + geometry: null, + properties: {} +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..6e5e891a97b5d72350e084b7840e31426ab8b8b2 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow @@ -0,0 +1,10 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const noProperties: GeoJSONFeature = { + type: 'Feature', + geometry: null +}; diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..ab3b6206fc2ae7872fbda4c655db84ae542e7f8c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Invalid Geometry Type', + coordinates: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..788561136fcc2050f67e2a879ddfd689fe16aa03 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'LineString', + coordinates: [0, 0] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d8ef16860c4c2fe935f956aea79354c7df6f326e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'LineString', + coordinates: [[[0, 0], [1, 2]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..acba73856c11e6c312e500b116c9d4e3fcae2cd2 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiLineString', + coordinates: [[0, 0], [0, 0]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..5149162f126994cf37755336380deae4f3b9f2ee --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiLineString', + coordinates: [[[[0, 0], [1, 1]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..f4cdaae16d4eda0e416aca665863bda408e40a12 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPoint', + coordinates: [0, 0] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..883a309850482aceb2b19706c3eabf68102ae76e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPoint', + coordinates: [[[0, 0], [1, 1]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..2fa0afe5ef47fc82d5ec23426f7390a4bc22c70a --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPolygon', + coordinates: [[[0, 0], [1, 2]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..ba91e5b6b8656b92de70e9e5d67dd2071068852f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [[[[[0, 0], [1, 2]]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..f10ea3b3a5a038fdeb86462476125b8cebe1d316 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..e8304da2978096a7291047125e2ca9498c054fff --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [[0, 0], [1, 1]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d9116cb2ceeba6699d3d33aa30560bd3ad654e1c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Polygon', + coordinates: [[[[0, 0], [0, 0]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..a1412ff2ae4b4100a14068e4f2238d8b6f3f9a7e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Polygon', + coordinates: [[0, 0], [0, 0]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..9fb419ad4315e044532e607b0fdc586a725e2524 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow @@ -0,0 +1,22 @@ +// @flow + +import type { + GeoJSONFeatureCollection +} from '../../index'; + +const collection: GeoJSONFeatureCollection = { + type: "FeatureCollection", + features: [ + { + type: "Feature", + properties: {}, + geometry: { + "type": "Point", + "coordinates": [ + 100, + 0 + ] + } + } + ] +}; diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..a0a481d65a6efaa9972891f1f73c6a28810a1764 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow @@ -0,0 +1,38 @@ +// @flow +import type { + GeoJSONFeature +} from '../../index'; + +const geom = { + "type": "Point", + "coordinates": [ + 100, + 0 + ] +} + +const feature: GeoJSONFeature = { + id: 1, + type: "Feature", + properties: { + "number": 1, + "boolean": false, + "string": "hello", + "object": { "x": 1 }, + "array": [ 1, "a", false, null ], + "null": null + }, + geometry: geom +}; + +const nullGeometry: GeoJSONFeature = { + type: "Feature", + properties: {}, + geometry: null +}; + +const nullProperties: GeoJSONFeature = { + type: "Feature", + properties: null, + geometry: null +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..543152c02a4346e118b799a5a6df2ceaab2f976c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow @@ -0,0 +1,33 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ + 100, + 0, + 3 + ] + }, + { + "type": "LineString", + "coordinates": [ + [ + 101, + 0, + 5 + ], + [ + 102, + 1, + 8 + ] + ] + } + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..7d6d49283b179344344a7c73f2b9d0792eec3db0 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow @@ -0,0 +1,30 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ + 100, + 0 + ] + }, + { + "type": "LineString", + "coordinates": [ + [ + 101, + 0 + ], + [ + 102, + 1 + ] + ] + } + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..255fa5492ea77a919b71b2058acebdae35f6b34c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow @@ -0,0 +1,34 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 100, + 0, + 5.2 + ], + [ + 101, + 1, + 8.1 + ] + ], + [ + [ + 102, + 2, + 2.3 + ], + [ + 103, + 3, + 7.4 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..22f7d7c7b3b036a4561b6b26138d334767460f39 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow @@ -0,0 +1,30 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 1 + ] + ], + [ + [ + 102, + 2 + ], + [ + 103, + 3 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..7dbee19b35aa90cbca774059b7a2b83cf3b96920 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow @@ -0,0 +1,20 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPoint", + "coordinates": [ + [ + 100, + 0, + 1 + ], + [ + 101, + 1, + 2 + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..9908f32a7d124a5af3ef953ed73230677ace0b91 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow @@ -0,0 +1,18 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPoint", + "coordinates": [ + [ + 100, + 0 + ], + [ + 101, + 1 + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..06c5990692a6d88950d87d27e51125e786b48f78 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow @@ -0,0 +1,95 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 102, + 2, + 1 + ], + [ + 103, + 2, + 1 + ], + [ + 103, + 3, + 1 + ], + [ + 102, + 3, + 1 + ], + [ + 102, + 2, + 1 + ] + ] + ], + [ + [ + [ + 100, + 0, + 2 + ], + [ + 101, + 0, + 2 + ], + [ + 101, + 1, + 2 + ], + [ + 100, + 1, + 2 + ], + [ + 100, + 0, + 2 + ] + ], + [ + [ + 100.2, + 0.2, + 3 + ], + [ + 100.8, + 0.2, + 3 + ], + [ + 100.8, + 0.8, + 3 + ], + [ + 100.2, + 0.8, + 3 + ], + [ + 100.2, + 0.2, + 3 + ] + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d91e2b6cbab40b0ae169bdf8b7bbea1702a0e074 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow @@ -0,0 +1,80 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 102, + 2 + ], + [ + 103, + 2 + ], + [ + 103, + 3 + ], + [ + 102, + 3 + ], + [ + 102, + 2 + ] + ] + ], + [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ], + [ + [ + 100.2, + 0.2 + ], + [ + 100.8, + 0.2 + ], + [ + 100.8, + 0.8 + ], + [ + 100.2, + 0.8 + ], + [ + 100.2, + 0.2 + ] + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..667d4508ac12714a6417da118a13083f81c0e3f4 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow @@ -0,0 +1,13 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Point", + "coordinates": [ + 100, + 0, + 1 + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..db7985f9355b0a0e08aeeee5f82a38734161859d --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow @@ -0,0 +1,12 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Point", + "coordinates": [ + 100, + 0 + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..c67ada49967a5a29466ff5857b8387cd96d5140f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow @@ -0,0 +1,36 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + 0, + 1 + ], + [ + 101, + 0 + ], + [ + 101, + 1, + 1 + ], + [ + 100, + 1, + 1 + ], + [ + 100, + 0, + 1 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..29bb3adc070d9ac6d6ce994a8e9aacaa469b8390 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow @@ -0,0 +1,32 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] +}