Dongxu Li commited on
Commit
30474d6
1 Parent(s): 120a3c2

add headers

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -19,12 +19,16 @@ def query_api(image, prompt, decoding_method):
19
  # local host for testing
20
  url = "http://34.132.142.70:5000/api/generate"
21
 
 
 
 
 
22
  data = {"prompt": prompt, "use_nucleus_sampling": decoding_method == "Nucleus sampling"}
23
 
24
  image = encode_image(image)
25
  files = {"image": image}
26
 
27
- response = requests.post(url, data=data, files=files)
28
 
29
  if response.status_code == 200:
30
  return response.json()
 
19
  # local host for testing
20
  url = "http://34.132.142.70:5000/api/generate"
21
 
22
+ headers = {
23
+ 'User-Agent': 'BLIP-2 HuggingFace Space'
24
+ }
25
+
26
  data = {"prompt": prompt, "use_nucleus_sampling": decoding_method == "Nucleus sampling"}
27
 
28
  image = encode_image(image)
29
  files = {"image": image}
30
 
31
+ response = requests.post(url, data=data, files=files, headers=headers)
32
 
33
  if response.status_code == 200:
34
  return response.json()