ultralytics / hub

Ultralytics HUB tutorials and support
https://hub.ultralytics.com
GNU Affero General Public License v3.0
138 stars 14 forks source link

Getting same response regardless of request body for prediction #862

Open NightLance opened 1 month ago

NightLance commented 1 month ago

Search before asking

Question

Hi,

I am using the predict inference API and I seem to be getting the same response regardless of how I change the request body. If I change the model, input image or other parameters, I get the same response. Even if the image URL is a bad URL, I still get the same response.

This is my request:

const ULTRALYTICS_API_HOST = 'https://predict.ultralytics.com'
const API_KEY = '<API-KEY>'

const interiorImage = '<URL-IMAGE>'

const segmentation = async () => {
  const data = new FormData()

  data.append(
    'model',
    'https://hub.ultralytics.com/models/kxDiCRYHGZ5ErGeE49Yi'
  )
  data.append('file', interiorImage)
  data.append('imgsz', '1000')
  data.append('conf', '0.95')
  data.append('iou', '0.88')

  const request = await fetch(ULTRALYTICS_API_HOST, {
    method: 'POST',
    body: data,
    headers: {
      'Content-Type': 'multipart/form-data',
      'x-api-key': API_KEY
    }
  })

  return request.json()
}

This is my input image:

image

In the results I get a bus person & stop sign every time. Please see below:


  {
    "results": [
      {
        "box": {
          "x1": 22.87127,
          "x2": 805.00269,
          "y1": 231.27731,
          "y2": 756.84045
        },
        "class": 5,
        "confidence": 0.87345,
        "name": "bus"
      },
      {
        "box": {
          "x1": 48.55044,
          "x2": 245.3456,
          "y1": 398.55231,
          "y2": 902.7027
        },
        "class": 0,
        "confidence": 0.86569,
        "name": "person"
      },
      {
        "box": {
          "x1": 669.4729,
          "x2": 809.72015,
          "y1": 392.18594,
          "y2": 877.03546
        },
        "class": 0,
        "confidence": 0.85284,
        "name": "person"
      },
      {
        "box": {
          "x1": 221.51729,
          "x2": 344.97061,
          "y1": 405.79865,
          "y2": 857.53662
        },
        "class": 0,
        "confidence": 0.82522,
        "name": "person"
      },
      {
        "box": {
          "x1": 0,
          "x2": 63.0069,
          "y1": 550.52502,
          "y2": 873.44293
        },
        "class": 0,
        "confidence": 0.26111,
        "name": "person"
      },
      {
        "box": {
          "x1": 0.05817,
          "x2": 32.55741,
          "y1": 254.45938,
          "y2": 324.87418
        },
        "class": 11,
        "confidence": 0.25507,
        "name": "stop sign"
      }
    ],
    "shape": [
      1080,
      810
    ],
    "speed": {
      "inference": 180.41897,
      "postprocess": 0.81754,
      "preprocess": 7.67398
    }
  }
]```

### Additional

_No response_
UltralyticsAssistant commented 1 month ago

πŸ‘‹ Hello @NightLance, thank you for bringing this to our attention! This is an automated response, but don't worryβ€”an Ultralytics engineer will assist you soon 😊.

For immediate guidance, you might find our Ultralytics HUB Docs helpful:

Since this seems like a πŸ› bug report, could you please provide a minimum reproducible example (MRE) of the issue? This helps us diagnose the problem more efficiently. You might also want to include any relevant headers or additional context that could assist our team in identifying the root cause.

Thank you for your patience while we look into this! πŸš€

sergiuwaxmann commented 1 month ago

@NightLance Looks like you are passing an URL, not an image file to the file key. If you want to pass an URL, try sending it in the source key and remove the file key.

NightLance commented 1 month ago

hi @sergiuwaxmann,

I am actually getting the same response. See below how I am attaching the image blob:

  const imageRequest = await fetch(interiorImage)
  const imageBlob = await imageRequest.blob()

  data.append('file', imageBlob)

EDIT:

I tried with the source key and its still the same result from my initial issue