Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
import os
|
3 |
-
os.system("pip install openai")
|
4 |
from PIL import Image
|
5 |
import requests
|
6 |
import base64
|
@@ -8,11 +6,8 @@ import openai
|
|
8 |
openai.api_key = ""
|
9 |
openai.api_base = "https://api.deepinfra.com/v1/openai"
|
10 |
def todataimage(file, ext):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
dataurl = f'data:image/{ext};base64,{base64_utf8_str}'
|
15 |
-
return dataurl
|
16 |
def caption(file, ext):
|
17 |
response = requests.post("https://russellc-comparing-captioning-models.hf.space/run/predict", json={
|
18 |
"data": [
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from PIL import Image
|
3 |
import requests
|
4 |
import base64
|
|
|
6 |
openai.api_key = ""
|
7 |
openai.api_base = "https://api.deepinfra.com/v1/openai"
|
8 |
def todataimage(file, ext):
|
9 |
+
image_data_uri = "data:image/png;base64," + base64.b64encode(file)
|
10 |
+
return image_data_uri
|
|
|
|
|
|
|
11 |
def caption(file, ext):
|
12 |
response = requests.post("https://russellc-comparing-captioning-models.hf.space/run/predict", json={
|
13 |
"data": [
|