-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathimageSegmentation.ts
24 lines (22 loc) · 1.02 KB
/
imageSegmentation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { ImageSegmentationInput, ImageSegmentationOutput } from "@huggingface/tasks";
import { getProviderHelper } from "../../lib/getProviderHelper";
import type { BaseArgs, Options } from "../../types";
import { innerRequest } from "../../utils/request";
import { preparePayload, type LegacyImageInput } from "./utils";
export type ImageSegmentationArgs = BaseArgs & (ImageSegmentationInput | LegacyImageInput);
/**
* This task reads some image input and outputs the likelihood of classes & bounding boxes of detected objects.
* Recommended model: facebook/detr-resnet-50-panoptic
*/
export async function imageSegmentation(
args: ImageSegmentationArgs,
options?: Options
): Promise<ImageSegmentationOutput> {
const providerHelper = getProviderHelper(args.provider ?? "hf-inference", "image-segmentation");
const payload = preparePayload(args);
const { data: res } = await innerRequest<ImageSegmentationOutput>(payload, providerHelper, {
...options,
task: "image-segmentation",
});
return providerHelper.getResponse(res);
}