Vehicle Make and Model Recognition

FREEMIUM
By AI Touch | Updated לפני חודש | Visual Recognition
Popularity

9.4 / 10

Latency

1,544ms

Service Level

100%

Health Check

N/A

Back to All Discussions

unable to call API using base64 input

Rapid account: Tkh 6425
tkh6425
לפני שנה

I get errors when calling the API using base64 image. Here is my code and please let me know if there is any problem. Thanks!

Trial 1:

import base64
import requests

filepath = "./my_image.jpg"
binary_fc = open(filepath, 'rb').read()  # fc aka file_content
base64_utf8_str = base64.b64encode(binary_fc).decode('utf-8')

ext = filepath.split('.')[-1]
data = f'data:image/{ext};base64,{base64_utf8_str}'

url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
files = { "inputimage": data }
headers = {
    "content-type": "application/x-www-form-urlencoded",
    "X-RapidAPI-Key": my_rapidapi_key,
    "X-RapidAPI-Host": "vehicle-make-and-model-recognition.p.rapidapi.com"
}
response = requests.post(url, files=files, headers=headers)
print(response.json())

return:
{'message': 'Parameter error', 'message_key': '78', 'service': 'vmmr', 'status': 'FAILED', 'version': '2.0'}

trial 2:

import base64
import requests

with open("./my_image.jpg", "rb") as image_file:
    data = base64.b64encode(image_file.read()).decode('utf-8')

url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"

payload = { "inputimage": data }
headers = {
    "content-type": "application/x-www-form-urlencoded",
    "X-RapidAPI-Key": my_rapidapi_key,
    "X-RapidAPI-Host": "vehicle-make-and-model-recognition.p.rapidapi.com"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())

return:
{'message': 'Parameter error', 'message_key': '78', 'service': 'vmmr', 'status': 'FAILED', 'version': '2.0'}

Rapid account: Tkh 6425
tkh6425 Commented לפני שנה

Sent you the image via email with title “Vehicle Make and Model Recognition Error image” from Hugo.

Rapid account: Dominonet L Tp EE 6 Z O Ne S
dominonet-lTpEE6zONeS Commented לפני שנה

Can you email me the problematic images (domino.net@gmail.com)?

Rapid account: Tkh 6425
tkh6425 Commented לפני שנה
import requests

url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
files = [
    ("inputimage", ("", open("/home/car_brand_recog_test/data/images/202306120003363210102L01C01.jpg", "rb"), "image/jpg"))
]
headers = {
    "X-RapidAPI-Key": my_rapidapi_key,
    "X-RapidAPI-Host": "vehicle-make-and-model-recognition.p.rapidapi.com"
}
response = requests.post(url, files=files, headers=headers)
print(response.json())

I ran this code but still got an error.

{'code': '400', 'message': 'Sorry,something was wrong,please try again later.'}

Rapid account: Dominonet L Tp EE 6 Z O Ne S
dominonet-lTpEE6zONeS Commented לפני שנה

#If it’s a file, look at this example

import requests
url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
files=[ (‘inputimage’,(’’,open(’/path/sample.jpeg’,‘rb’),‘image/jpeg’)) ]
headers = { “X-RapidAPI-Key”: “Your key”, “X-RapidAPI-Host”: “vehicle-make-and-model-recognition.p.rapidapi.com” }
response = requests.post(url, files=files, headers=headers) print(response.json())

#If it’s a base64 image or url, look at this example
import requests
url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
payload = {‘inputurl’: ‘data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/…’}
headers = { “X-RapidAPI-Key”: “Your key”, “X-RapidAPI-Host”: “vehicle-make-and-model-recognition.p.rapidapi.com” }
response = requests.post(url, data=payload, headers=headers) print(response.json())

#Please let me know if you have any other questions

Rapid account: Dominonet L Tp EE 6 Z O Ne S
dominonet-lTpEE6zONeS Commented לפני שנה

#If it’s a file, look at this example
import requests
url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
files=[
(‘inputimage’,(’’,open(’/path/sample.jpeg’,‘rb’),‘image/jpeg’))
]
headers = {
“X-RapidAPI-Key”: “Your key”,
“X-RapidAPI-Host”: “vehicle-make-and-model-recognition.p.rapidapi.com
}
response = requests.post(url, files=files, headers=headers)
print(response.json())

#If it’s a base64 image or url, look at this example
import requests
url = "https://vehicle-make-and-model-recognition.p.rapidapi.com/v1"
payload = {‘inputurl’: ‘data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/…’}
headers = {
“X-RapidAPI-Key”: “Your key”,
“X-RapidAPI-Host”: “vehicle-make-and-model-recognition.p.rapidapi.com
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())

#Please let me know if you have any other questions

Join in the discussion - add comment below:

Login / Signup to post new comments