abdulsamad commited on
Commit
c05c698
·
1 Parent(s): 9d0734f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -1,7 +1,35 @@
1
  import gradio as gr
2
  import requests, json
 
 
 
 
 
3
 
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  def greet(name):
6
  return "Hello " + name + "!!"
7
 
 
1
  import gradio as gr
2
  import requests, json
3
+ import os
4
+ import io
5
+ import IPython.display
6
+ from PIL import Image
7
+ import base64
8
 
9
 
10
+ # Helper functions
11
+ import requests, json
12
+
13
+ #Image-to-text endpoint
14
+ def get_completion(inputs, parameters=None, ENDPOINT_URL="http://internal-aws-prod-internal-revproxy-alb-11660607.us-west-1.elb.amazonaws.com/rev-proxy/huggingface/itt"]):
15
+ headers = {
16
+ "Authorization": f"Bearer {HF_KEY}",
17
+ "Content-Type": "application/json"
18
+ }
19
+ data = { "inputs": inputs }
20
+ if parameters is not None:
21
+ data.update({"parameters": parameters})
22
+ response = requests.request("POST",
23
+ ENDPOINT_URL,
24
+ headers=headers,
25
+ data=json.dumps(data))
26
+ return json.loads(response.content.decode("utf-8"))
27
+
28
+
29
+ image_url = "https://free-images.com/sm/9596/dog_animal_greyhound_983023.jpg"
30
+ display(IPython.display.Image(url=image_url))
31
+ get_completion(image_url)
32
+
33
  def greet(name):
34
  return "Hello " + name + "!!"
35