Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,10 @@ import json
|
|
8 |
import re
|
9 |
import base64
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def get_image_data(fig):
|
13 |
buf = io.BytesIO()
|
@@ -59,7 +63,8 @@ def gpt_inference(base_url, model, openai_key, prompt):
|
|
59 |
print("Response JSON:", response.json())
|
60 |
code = response.json()["choices"][0]["message"]["content"]
|
61 |
print(f"code:{code}")
|
62 |
-
|
|
|
63 |
return img
|
64 |
|
65 |
iface = gr.Interface(
|
|
|
8 |
import re
|
9 |
import base64
|
10 |
|
11 |
+
def decode_image(img_b64):
|
12 |
+
img_data = base64.b64decode(img_b64)
|
13 |
+
img = Image.open(io.BytesIO(img_data))
|
14 |
+
return img
|
15 |
|
16 |
def get_image_data(fig):
|
17 |
buf = io.BytesIO()
|
|
|
63 |
print("Response JSON:", response.json())
|
64 |
code = response.json()["choices"][0]["message"]["content"]
|
65 |
print(f"code:{code}")
|
66 |
+
img_b64 = execute_code(code)
|
67 |
+
img = decode_image(img_b64)
|
68 |
return img
|
69 |
|
70 |
iface = gr.Interface(
|