Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
|
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
|
|
@@ -13,7 +14,14 @@ def function(paramater):
|
|
| 13 |
response = json.loads(response.text)
|
| 14 |
image = requests.get(response["url"], headers=payload)
|
| 15 |
image = image.content
|
| 16 |
-
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
iface = gr.Interface(fn=function, inputs="text", outputs="text")
|
| 19 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
import base64
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
|
|
|
|
| 14 |
response = json.loads(response.text)
|
| 15 |
image = requests.get(response["url"], headers=payload)
|
| 16 |
image = image.content
|
| 17 |
+
image = base64.b64encode(image).decode('utf-8')
|
| 18 |
|
| 19 |
+
response = requests.post("https://tommy24-this-is-indeed-cool.hf.space/run/predict", json={
|
| 20 |
+
"data": [
|
| 21 |
+
f"data:image/png;base64,{image}==",
|
| 22 |
+
]}).json()
|
| 23 |
+
|
| 24 |
+
data = response["data"][0]
|
| 25 |
+
return data
|
| 26 |
iface = gr.Interface(fn=function, inputs="text", outputs="text")
|
| 27 |
iface.launch()
|