Home>

I am trying out the Image Influence API and writing code to score meat images appropriately.
Recruit Image Influence API site ↓

Move it at the terminal
{'status&apos ;: 0,'message&apos ;:'ok&apos ;,'result&apos ;: {'score&apos ;: 4.195425987243652}}
I got a response.
Get status_code from now (200 for ok, 400 for error)
I want to branch if, but it should be ok, but 400 is obtained.
I can't go on and on now, but I feel uncomfortable.

Addition: pia3rt needs to be downloaded.
Addendum 2: Additional investigation
{"status" ;: 1000,"message" ;:"apikey is null"}
was.
Apparently the API key is not specified.
I use a key that has been issued. . .
Is there a cause in the code?

mport pya3rt
import requests
#APIkey
apikey = "** ※ It needs to be issued for your own APIkey **"
client = pya3rt.ImageInfluenceClient (apikey)
# set url
# Input image file name
image = input ('Enter image file name:')
# Prepare parameters
parameter = {'zipcode': image}
# Visit the site
r = requests.get (url, params = parameter)
#print (client.get_upload_url ())
print (r.status_code)
print (client.meat_score (image, 1))
  • Answer # 1

    Try various things
    Not HTTP status.
    Changed to get status.
    The code that had some problems was settled down.

    import pya3rt
    #APIkey
    apikey = ""
    client = pya3rt.ImageInfluenceClient (apikey)
    # Input image file name
    image = input ('Enter image file name:')
    r = client.meat_score (image, 1)
    if r ['status'] == 0:
        i = r ['result'] ['score']
        print (f'The score of this meat image is {round (i, 1)}. ')
    else:
        print ('ERROR')