detr-resnet-50
   Beta  
       
  Terminal window        
       
         
     Model ID:  @cf/facebook/detr-resnet-50 
DEtection TRansformer (DETR) model trained end-to-end on COCO 2017 object detection (118k annotated images).
Properties
Task Type: Object Detection
Code Examples
Workers - Typescript
  export interface Env {  AI: Ai;}
export default {  async fetch(request, env): Promise<Response> {    const res = await fetch("https://cataas.com/cat");    const blob = await res.arrayBuffer();
    const inputs = {      image: [...new Uint8Array(blob)],    };
    const response = await env.AI.run(      "@cf/facebook/detr-resnet-50",      inputs    );
    return new Response(JSON.stringify({ inputs: { image: [] }, response }));  },} satisfies ExportedHandler<Env>;curl
  curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/facebook/detr-resnet-50  \    -X POST  \    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \    --data-binary "@pedestrian-boulevard-manhattan-crossing.jpg"Response
This task returns a list of detected objects, each one containing a label, a probability score, and its surrounding box coordinates.
[  { "label":"cat" ,"score":0.4071170687675476, "box": { "xmin": 0, "ymin": 0, "xmax": 10, "ymax": 10 } },  { "label":"face", "score":0.22562485933303833, "box": { "xmin": 15, "ymin": 22, "xmax": 25, "ymax": 35 } },  { "label":"car", "score":0.033316344022750854, "box": { "xmin": 72, "ymin": 55, "xmax": 95, "ymax": 72 } }]API Schema
The following schema is based on JSON Schema
Input JSON Schema
  {  "oneOf": [    {      "type": "string",      "format": "binary"    },    {      "type": "object",      "properties": {        "image": {          "type": "array",          "items": {            "type": "number"          }        }      }    }  ]}Output JSON Schema
  {  "type": "array",  "contentType": "application/json",  "items": {    "type": "object",    "properties": {      "score": {        "type": "number"      },      "label": {        "type": "string"      },      "box": {        "type": "object",        "properties": {          "xmin": {            "type": "number"          },          "ymin": {            "type": "number"          },          "xmax": {            "type": "number"          },          "ymax": {            "type": "number"          }        }      }    }  }}