> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/deployment/ko/legacy/legacy-serverless/object-detection.md).

# 객체 감지

Hosted API(레거시)를 사용하여 객체 감지 추론을 실행하는 방법은 여러 가지가 있습니다. 다양한 SDK 중 하나를 사용하거나 호스티드 엔드포인트로 REST 요청을 보낼 수 있습니다.

{% tabs %}
{% tab title="Python" %}
종속성을 설치하려면, `pip install inference-sdk`.

```python
# inference-sdk 가져오기
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

CLIENT = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key="API_KEY"
).configure(InferenceConfiguration(api_key_transport="header"))

result = CLIENT.infer(your_image.jpg, model_id="football-players-detection-3zvbc/12")
```

{% endtab %}

{% tab title="cURL" %}
**Linux 또는 MacOS**

다음 이름의 로컬 파일에 대한 JSON 예측 가져오기 `YOUR_IMAGE.jpg`:

```bash
base64 YOUR_IMAGE.jpg | curl -d @- \\
-H "Authorization: Bearer YOUR_KEY" \\
"https://serverless.roboflow.com/your-model/42"
```

URL을 통해 웹의 다른 곳에 호스팅된 이미지에 대해 추론하기(잊지 말고 [URL 인코딩하세요](https://www.urlencoder.org/)):

```bash
curl -X POST \\
-H "Authorization: Bearer YOUR_KEY" \\
https://serverless.roboflow.com/your-model/42?
image=https%3A%2F%2Fi.imgur.com%2FPEEvqPN.png"
```

**Windows**

설치해야 합니다 [Windows용 curl](https://curl.se/windows/) 및 [Windows용 GNU의 base64 도구](http://gnuwin32.sourceforge.net/packages/coreutils.htm). 이를 하는 가장 쉬운 방법은 다음을 사용하는 것입니다. [git for Windows 설치 관리자](https://git-scm.com/downloads) 여기에는 또한 `curl` 및 `base64` 명령줄 도구가 포함됩니다. 설치 중 "Use Git and optional Unix tools from the Command Prompt"를 선택하면 됩니다.

그런 다음 위와 동일한 명령을 사용할 수 있습니다.
{% endtab %}

{% tab title="자바스크립트" %}
**Node.js**

이 예제들은 내장된 `fetch` API를 사용합니다. Node.js 18 이상 및 최신 브라우저에서 작동하므로 설치할 종속성이 없습니다.

**로컬 이미지에 대해 추론하기**

```javascript
const fs = require("fs");

const image = fs.readFileSync("YOUR_IMAGE.jpg", {
    encoding: "base64"
});

fetch("https://serverless.roboflow.com/your-model/42", {
    method: "POST",
    headers: {
        "Authorization": "Bearer YOUR_KEY",
        "Content-Type": "application/x-www-form-urlencoded"
    },
    body: image
})
    .then((response) => {
        if (!response.ok) throw new Error("Request failed with status " + response.status);
        return response.json();
    })
    .then((data) => {
        console.log(data);
    })
    .catch((error) => {
        console.log(error.message);
    });
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```javascript
fetch(
    "https://serverless.roboflow.com/your-model/42?image=" +
        encodeURIComponent("https://i.imgur.com/PEEvqPN.png"),
    {
        method: "POST",
        headers: {
            "Authorization": "Bearer YOUR_KEY"
        }
    }
)
    .then((response) => {
        if (!response.ok) throw new Error("Request failed with status " + response.status);
        return response.json();
    })
    .then((data) => {
        console.log(data);
    })
    .catch((error) => {
        console.log(error.message);
    });
```

**웹**

실시간 기기 내 추론을 다음을 통해 사용할 수 있습니다 `roboflow.js`; 자세한 내용은 [여기 문서를 참조하세요](/deployment/ko/self-hosted/sdks/web-browser.md).
{% endtab %}

{% tab title="Swift/iOS" %}
**Swift**

**로컬 이미지에 대해 추론하기**

```swift
import UIKit

// 이미지 로드 및 Base64로 변환
let image = UIImage(named: "your-image-path") // 업로드할 이미지 경로 예: image.jpg
let imageData = image?.jpegData(compressionQuality: 1)
let fileContent = imageData?.base64EncodedString()
let postData = fileContent!.data(using: .utf8)

// API_KEY, 모델, 모델 버전으로 Inference 서버 요청 초기화
var request = URLRequest(url: URL(string: "https://serverless.roboflow.com/your-model/your-model-version?name=YOUR_IMAGE.jpg")!,timeoutInterval: Double.infinity)
request.setValue("Bearer YOUR_APIKEY", forHTTPHeaderField: "Authorization")
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData

// POST 요청 실행
URLSession.shared.dataTask(with: request, completionHandler: { data, response, error in
    
    // 응답을 문자열로 파싱
    guard let data = data else {
        print(String(describing: error))
        return
    }
    
    // 응답 문자열을 딕셔너리로 변환
    do {
        let dict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
    } catch {
        print(error.localizedDescription)
    }
    
    // 문자열 응답 출력
    print(String(data: data, encoding: .utf8)!)
}).resume()
```

**Objective-C**

[Objective-C 스니펫을 요청하려면 여기를 클릭하세요.](https://app.roboflow.com/request/snippet.inference-objc)
{% endtab %}

{% tab title="Android" %}
**Kotlin**

**로컬 이미지에 대해 추론하기**

```kotlin
import java.io.*
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets
import java.util.*

fun main() {
    // 이미지 경로 가져오기
    val filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg"
    val file = File(filePath)

    // Base64 인코딩
    val encodedFile: String
    val fileInputStreamReader = FileInputStream(file)
    val bytes = ByteArray(file.length().toInt())
    fileInputStreamReader.read(bytes)
    encodedFile = String(Base64.getEncoder().encode(bytes), StandardCharsets.US_ASCII)
    val API_KEY = "" // API 키
    val MODEL_ENDPOINT = "dataset/v" // 모델 엔드포인트 설정 (데이터세트 URL에서 확인)

    // URL 구성
    val uploadURL ="https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?name=YOUR_IMAGE.jpg";

    // HTTP 요청
    var connection: HttpURLConnection? = null
    try {
        // URL에 연결 구성
        val url = URL(uploadURL)
        connection = url.openConnection() as HttpURLConnection
        connection.requestMethod = "POST"
        connection.setRequestProperty("Content-Type",
                "application/x-www-form-urlencoded")
        connection.setRequestProperty("Content-Length",
                Integer.toString(encodedFile.toByteArray().size))
        connection.setRequestProperty("Authorization", "Bearer " + API_KEY)
        connection.setRequestProperty("Content-Language", "en-US")
        connection.useCaches = false
        connection.doOutput = true

        // 요청 보내기
        val wr = DataOutputStream(
                connection.outputStream)
        wr.writeBytes(encodedFile)
        wr.close()

        // 응답 가져오기
        val stream = connection.inputStream
        val reader = BufferedReader(InputStreamReader(stream))
        var line: String?
        while (reader.readLine().also { line = it } != null) {
            println(line)
        }
        reader.close()
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        connection?.disconnect()
    }
}
main()
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```kotlin
import java.io.BufferedReader
import java.io.DataOutputStream
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.net.URLEncoder

fun main() {
    val imageURL = "https://i.imgur.com/PEEvqPN.png" // 이미지 URL로 교체
    val API_KEY = "" // API 키
    val MODEL_ENDPOINT = "dataset/v" // 모델 엔드포인트 설정

    // 업로드 URL
    val uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?image=" + URLEncoder.encode(imageURL, "utf-8");

    // HTTP 요청
    var connection: HttpURLConnection? = null
    try {
        // URL에 연결 구성
        val url = URL(uploadURL)
        connection = url.openConnection() as HttpURLConnection
        connection.requestMethod = "POST"
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
        connection.setRequestProperty("Content-Length", Integer.toString(uploadURL.toByteArray().size))
        connection.setRequestProperty("Authorization", "Bearer " + API_KEY)
        connection.setRequestProperty("Content-Language", "en-US")
        connection.useCaches = false
        connection.doOutput = true

        // 요청 보내기
        val wr = DataOutputStream(connection.outputStream)
        wr.writeBytes(uploadURL)
        wr.close()

        // 응답 가져오기
        val stream = connection.inputStream
        val reader = BufferedReader(InputStreamReader(stream))
        var line: String?
        while (reader.readLine().also { line = it } != null) {
            println(line)
        }
        reader.close()
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        connection?.disconnect()
    }
}

main()
```

**Java**

**로컬 이미지에 대해 추론하기**

```java
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class InferenceLocal {
    public static void main(String[] args) throws IOException {
        // 이미지 경로 가져오기
        String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg";
        File file = new File(filePath);

        // Base64 인코딩
        String encodedFile;
        FileInputStream fileInputStreamReader = new FileInputStream(file);
        byte[] bytes = new byte[(int) file.length()];
        fileInputStreamReader.read(bytes);
        encodedFile = new String(Base64.getEncoder().encode(bytes), StandardCharsets.US_ASCII);

        String API_KEY = ""; // API 키
        String MODEL_ENDPOINT = "dataset/v"; // 모델 엔드포인트

        // URL 구성
        String uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?name=YOUR_IMAGE.jpg";

        // HTTP 요청
        HttpURLConnection connection = null;
        try {
            // URL에 연결 구성
            URL url = new URL(uploadURL);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

            connection.setRequestProperty("Content-Length", Integer.toString(encodedFile.getBytes().length));
            connection.setRequestProperty("Authorization", "Bearer " + API_KEY);
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setUseCaches(false);
            connection.setDoOutput(true);

            // 요청 보내기
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(encodedFile);
            wr.close();

            // 응답 가져오기
            InputStream stream = connection.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }

    }

}
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```java
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class InferenceHosted {
    public static void main(String[] args) {
        String imageURL = "https://i.imgur.com/PEEvqPN.png"; // 이미지 URL로 교체
        String API_KEY = ""; // API 키
        String MODEL_ENDPOINT = "dataset/v"; // 모델 엔드포인트

        // 업로드 URL
        String uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?image="
                + URLEncoder.encode(imageURL, StandardCharsets.UTF_8);

        // HTTP 요청
        HttpURLConnection connection = null;
        try {
            // URL에 연결 구성
            URL url = new URL(uploadURL);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

            connection.setRequestProperty("Content-Length", Integer.toString(uploadURL.getBytes().length));
            connection.setRequestProperty("Authorization", "Bearer " + API_KEY);
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setUseCaches(false);
            connection.setDoOutput(true);

            // 요청 보내기
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(uploadURL);
            wr.close();

            // 응답 가져오기
            InputStream stream = connection.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
}
```

{% endtab %}

{% tab title="Ruby" %}
**Gemfile**

{% code title="Gemfile" %}

```ruby
source "https://rubygems.org"

gem "httparty", "~> 0.18.1"
gem "base64", "~> 0.1.0"
gem "cgi", "~> 0.2.1"
```

{% endcode %}

**Gemfile.lock**

{% code title="Gemfile.lock" %}

```ruby
GEM
  remote: https://rubygems.org/
  specs:
    base64 (0.1.0)
    cgi (0.2.1)
    httparty (0.18.1)
      mime-types (~> 3.0)
      multi_xml (>= 0.5.2)
    mime-types (3.3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2021.0225)
    multi_xml (0.6.0)

PLATFORMS
  x64-mingw32
  x86_64-linux

DEPENDENCIES
  base64 (~> 0.1.0)
  cgi (~> 0.2.1)
  httparty (~> 0.18.1)

BUNDLED WITH
   2.2.15
```

{% endcode %}

**로컬 이미지에 대해 추론하기**

```ruby
require 'base64'
require 'httparty'

encoded = Base64.encode64(File.open("YOUR_IMAGE.jpg", "rb").read)
model_endpoint = "dataset/v" # 모델 엔드포인트 설정
api_key = "" # API 키는 여기에

params = "?name=YOUR_IMAGE.jpg"

response = HTTParty.post(
    "https://serverless.roboflow.com/" + model_endpoint + params,
    body: encoded, 
    headers: {
    'Authorization' => "Bearer " + api_key,
    'Content-Type' => 'application/x-www-form-urlencoded',
    'charset' => 'utf-8'
  })

  puts response

 
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```ruby
require 'httparty'
require 'cgi'

model_endpoint = "dataset/v" # 모델 엔드포인트 설정
api_key = "" # API 키는 여기에
img_url = "https://i.imgur.com/PEEvqPN.png" # URL 구성

img_url = CGI::escape(img_url)

params =  "?image=" + img_url

response = HTTParty.post(
    "https://serverless.roboflow.com/" + model_endpoint + params,
    headers: {
    'Authorization' => "Bearer " + api_key,
    'Content-Type' => 'application/x-www-form-urlencoded',
    'charset' => 'utf-8'
  })

puts response
```

{% endtab %}

{% tab title="PHP" %}
**로컬 이미지에 대해 추론하기**

```php
<?php

// 이미지를 Base64로 인코딩
$data = base64_encode(file_get_contents("YOUR_IMAGE.jpg"));

$api_key = ""; // API 키 설정
$model_endpoint = "dataset/v"; // 모델 엔드포인트 설정 (데이터세트 URL에서 찾을 수 있음)

// HTTP 요청용 URL
$url = "https://serverless.roboflow.com/" . $model_endpoint
. "?name=YOUR_IMAGE.jpg";

// HTTP 요청 설정 및 전송
$options = array(
  'http' => array (
    'header' => "Content-type: application/x-www-form-urlencoded\r\n"
              . "Authorization: Bearer " . $api_key . "\r\n",
    'method'  => 'POST',
    'content' => $data
  ));

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```php
<?php

$api_key = ""; // API 키 설정
$model_endpoint = "dataset/v"; // 모델 엔드포인트 설정 (데이터세트 URL에서 찾을 수 있음)
$img_url = "https://i.imgur.com/PEEvqPN.png";

// HTTP 요청용 URL
$url =  "https://serverless.roboflow.com/" . $model_endpoint
. "?image=" . urlencode($img_url);

// HTTP 요청 설정 및 전송
$options = array(
  'http' => array (
    'header' => "Content-type: application/x-www-form-urlencoded\r\n"
              . "Authorization: Bearer " . $api_key . "\r\n",
    'method'  => 'POST'
  ));

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

{% endtab %}

{% tab title="Go" %}
**로컬 이미지에 대해 추론하기**

```go
package main

import (
    "bufio"
    "encoding/base64"
    "fmt"
    "io/ioutil"
    "os"
	"net/http"
	"strings"
)

func main() {
	api_key := ""  // API 키
	model_endpoint := "dataset/v" // 모델 엔드포인트 설정

    // 디스크에서 파일 열기.
    f, _ := os.Open("YOUR_IMAGE.jpg")

    // 전체 JPG를 바이트 슬라이스로 읽기.
    reader := bufio.NewReader(f)
    content, _ := ioutil.ReadAll(reader)

    // base64로 인코딩합니다.
    data := base64.StdEncoding.EncodeToString(content)
	uploadURL := "https://serverless.roboflow.com/" + model_endpoint + "?name=YOUR_IMAGE.jpg"

	req, _ := http.NewRequest("POST", uploadURL, strings.NewReader(data))
    req.Header.Set("Authorization", "Bearer "+api_key)
    req.Header.Set("Accept", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

   	bytes, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(bytes))

}
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```go
package main

import (
    "fmt"
	"net/http"
	"net/url"
  "io/ioutil"
)

func main() {
	api_key := ""  // API 키
	model_endpoint := "dataset/v" // 모델 엔드포인트 설정
	img_url := "https://i.ibb.co/jzr27x0/YOUR-IMAGE.jpg"


	uploadURL := "https://serverless.roboflow.com/" + model_endpoint + "?image=" + url.QueryEscape(img_url)

	req, _ := http.NewRequest("POST", uploadURL, nil)
    req.Header.Set("Authorization", "Bearer "+api_key)
    req.Header.Set("Accept", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

   	bytes, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(bytes))


}
```

{% endtab %}

{% tab title=".NET" %}
**로컬 이미지에 대해 추론하기**

```csharp
using System;
using System.IO;
using System.Net;
using System.Text;

namespace InferenceLocal
{
    class InferenceLocal
    {

        static void Main(string[] args)
        {
            byte[] imageArray = System.IO.File.ReadAllBytes(@"YOUR_IMAGE.jpg");
            string encoded = Convert.ToBase64String(imageArray);
            byte[] data = Encoding.ASCII.GetBytes(encoded);
            string API_KEY = ""; // API 키
            string MODEL_ENDPOINT = "dataset/v"; // 모델 엔드포인트 설정

            // URL 구성
            string uploadURL =
                    "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?name=YOUR_IMAGE.jpg";

            // 서비스 요청 설정
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // 요청 구성
            WebRequest request = WebRequest.Create(uploadURL);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", "Bearer " + API_KEY);
            request.ContentLength = data.Length;

            // 데이터 쓰기
            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            // 응답 가져오기
            string responseContent = null;
            using (WebResponse response = request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader sr99 = new StreamReader(stream))
                    {
                        responseContent = sr99.ReadToEnd();
                    }
                }
            }

            Console.WriteLine(responseContent);

        }
    }
}
```

**웹의 다른 곳에 호스팅된 이미지에 대해 URL을 통해 추론하기**

```csharp
using System;
using System.IO;
using System.Net;
using System.Web;

namespace InferenceHosted
{
    class InferenceHosted
    {
        static void Main(string[] args)
        {
            string API_KEY = ""; // API 키
            string imageURL = "https://i.ibb.co/jzr27x0/YOUR-IMAGE.jpg";
            string MODEL_ENDPOINT = "dataset/v"; // 모델 엔드포인트 설정

            // URL 구성
            string uploadURL =
                    "https://serverless.roboflow.com/" + MODEL_ENDPOINT
                    + "?image=" + HttpUtility.UrlEncode(imageURL);

            // 서비스 포인트 설정
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // HTTP 요청 구성
            WebRequest request = WebRequest.Create(uploadURL);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", "Bearer " + API_KEY);
            request.ContentLength = 0;

            // 응답 가져오기
            string responseContent = null;
            using (WebResponse response = request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader sr99 = new StreamReader(stream))
                    {
                        responseContent = sr99.ReadToEnd();
                    }
                }
            }

            Console.WriteLine(responseContent);

        }
    }
}
```

{% endtab %}

{% tab title="더 보기" %}
{% hint style="info" %}
AI 기반 챗봇인 Lenny에게 코드 샘플을 만들어 달라고 요청해 보세요!
{% endhint %}
{% endtab %}
{% endtabs %}

## API 참조

### URL

<mark style="color:녹색;">`POST`</mark> `https://serverless.roboflow.com/:projectId/:versionNumber`

<table data-search="false"><thead><tr><th width="157">이름</th><th width="101">유형</th><th>설명</th></tr></thead><tbody><tr><td>projectId</td><td>string</td><td>데이터셋 이름의 URL 안전 버전입니다. 모델을 학습한 후 데이터셋 버전의 학습 결과 섹션에서 메인 프로젝트 보기의 URL을 보거나 "Get curl command" 버튼을 클릭하면 웹 UI에서 찾을 수 있습니다.</td></tr><tr><td>version</td><td>number</td><td>데이터셋의 버전을 식별하는 버전 번호</td></tr></tbody></table>

{% hint style="info" %}
프로젝트 ID와 버전 번호를 가져오는 방법을 확인하세요 [여기](https://docs.roboflow.com/reference/authentication/authentication/workspace-and-project-ids#how-to-retrieve-a-project-id-and-version-number).
{% endhint %}

REST 요청을 통해 Hosted API(레거시)로 이미지를 보내는 방법은 두 가지가 있습니다:

* 다음을 첨부하세요: `base64` 인코딩된 이미지를 `POST` 요청 본문에
* 이미지 파일의 URL을 다음을 사용하여 보내세요: `image` URL 쿼리
  * 예: `https://serverless.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com`

#### 쿼리 매개변수

<table data-search="false"><thead><tr><th width="120">이름</th><th width="106">유형</th><th>설명</th></tr></thead><tbody><tr><td>image</td><td>string</td><td>추가할 이미지의 URL입니다. 이미지가 다른 곳에 호스팅되어 있는 경우 사용합니다. (요청 본문에 base64로 인코딩된 이미지를 POST하지 않는 경우 필요합니다.)<br><br><strong>참고:</strong> URL 인코딩하는 것을 잊지 마세요.</td></tr><tr><td>예측을 특정 클래스의 것들로만 제한합니다. 쉼표로 구분된 문자열로 제공하세요.</td><td>string</td><td>예시:<br><br><strong>dog,cat</strong> 기본값:<br><br><strong>기본값:</strong> overlap</td></tr><tr><td>overlap</td><td>number</td><td><p>같은 클래스의 바운딩 박스 예측이 하나의 박스로 결합되기 전에 서로 겹칠 수 있는 최대 비율(0~100)입니다.</p><p><strong>기본값:</strong> 30</p><p>이 매개변수는 RF-DETR 모델에는 영향을 주지 않습니다.</p></td></tr><tr><td>confidence</td><td>number</td><td><p>0~100 범위에서 반환되는 예측에 대한 임계값입니다. 숫자가 낮을수록 더 많은 예측이 반환되고, 숫자가 높을수록 더 적은 고신뢰도 예측이 반환됩니다.</p><p><strong>기본값:</strong> 40</p></td></tr><tr><td>예측 주위에 표시되는 바운딩 박스의 너비(픽셀 단위)입니다(다음 경우에만 효과가 있습니다</td><td>number</td><td><p>format <code>is</code> labels <code>image</code>).</p><p><strong>기본값:</strong> 1</p></td></tr><tr><td>boolean</td><td>예측에 텍스트 레이블을 표시할지 여부입니다(다음 경우에만 효과가 있습니다</td><td><p>false <code>is</code> labels <code>image</code>).</p><p><strong>기본값:</strong> json</p></td></tr><tr><td>is</td><td>string</td><td><p><strong>옵션:</strong></p><ul><li><strong>json:</strong> JSON 예측 배열을 반환합니다. (응답 형식 탭 참조).</li><li><strong>image:</strong> 주석이 달린 예측 결과가 포함된 이미지를 다음을 사용한 바이너리 blob으로 반환합니다. <code>의</code> image/jpeg <code>image_and_json</code>.</li></ul><p><strong>: json</strong>: <code>- JSON 예측 배열을 반환합니다. (응답 형식 탭을 참조하세요).</code></p></td></tr><tr><td>api_key</td><td>string</td><td>귀하의 API 키(작업 공간 API 설정 페이지에서 가져옴)</td></tr></tbody></table>

### 요청 본문

<table data-search="false"><thead><tr><th width="104">유형</th><th>설명</th></tr></thead><tbody><tr><td>string</td><td>base64로 인코딩된 이미지. (쿼리 매개변수에 이미지 URL을 전달하지 않을 때 필요합니다.)</td></tr></tbody></table>

콘텐츠 유형은 다음이어야 합니다: `application/x-www-form-urlencoded` 문자열 본문과 함께.

## 응답 형식

호스티드 API 추론 엔드포인트와 대부분의 SDK는 다음을 반환합니다. `JSON` 객체를 반환하며, 여기에는 예측 배열이 포함됩니다. 각 예측에는 다음 속성이 있습니다:

* `x` = 탐지된 객체의 가로 중심점
* `y` = 탐지된 객체의 세로 중심점
* `width` = 바운딩 박스의 너비
* `height` = 바운딩 박스의 높이
* `class` = 탐지된 객체의 클래스 레이블
* `confidence` = 탐지된 객체의 레이블과 위치 좌표가 올바르다고 모델이 판단하는 신뢰도

다음은 REST API의 응답 객체 예시입니다:

```json
{
    "predictions": [
        {
            "x": 189.5,
            "y": 100,
            "width": 163,
            "height": 186,
            "class": "helmet",
            "confidence": 0.544
        }
    ],
    "image": {
        "width": 2048,
        "height": 1371
    }
}
```

해당 `image` Inference API 매개변수

## Inference API JSON 출력에서 박스 그리기

바운딩 박스를 렌더링하는 프레임워크와 패키지는 위치 형식이 다를 수 있습니다. 응답 `JSON` 객체의 속성을 통해 바운딩 박스는 항상 다음 규칙들의 조합으로 그릴 수 있습니다:

* 중심점은 항상 (`x`,`y`)
* 모서리 점 `(x1, y1)` 및 `(x2, y2)` 다음을 사용하여 구할 수 있습니다:
  * `x1` = `x - (width/2)`
  * `y1` = `y - (height/2)`
  * `x2` = `x + (width/2)`
  * `y2` = `y + (height/2)`

모서리 점 접근 방식은 일반적인 패턴이며 다음과 같은 라이브러리에서 볼 수 있습니다. `Pillow` 다음을 빌드할 때 `박스` 바운딩 박스를 렌더링하기 위한 객체를 `이미지`.

예측을 다룰 때 발견된 모든 감지를 반복 처리하는 것을 잊지 마세요 `예측`!

```python
# Pillow 라이브러리의 박스 객체 예시
for bounding_box in detections:
    x1 = bounding_box['x'] - bounding_box['width'] / 2
    x2 = bounding_box['x'] + bounding_box['width'] / 2
    y1 = bounding_box['y'] - bounding_box['height'] / 2
    y2 = bounding_box['y'] + bounding_box['height'] / 2
    box = (x1, x2, y1, y2)
```
