helloway commited on
Commit
2cfe540
1 Parent(s): ef16984

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import requests
3
  import numpy as np
4
  from PIL import Image
5
  import gradio as gr
 
6
 
7
 
8
  def gen_image(desc: str):
@@ -15,7 +16,8 @@ def gen_image(desc: str):
15
  access_token = os.environ['token']
16
  headers = {'content-type': "application/json", 'X-Subject-Token': access_token}
17
 
18
- url = f"https://a2f051d4cabf45f885d7b0108edc9b9c.infer.ovaijisuan.com/v1/infers/dce9ad51-7cde-4eeb-8291-ae29f267ed2c/wukong-hf"
 
19
  body = {
20
  "desc": desc,
21
  "style": ""
@@ -24,8 +26,11 @@ def gen_image(desc: str):
24
  resp_data = requests.post(url, json=body, headers=headers)
25
  if resp_data['status'] != 200:
26
  return []
27
- img_np = resp_data['output_image_list'][0]
28
- image = Image.fromarray(np.uint8(img_np))
 
 
 
29
  return [image]
30
 
31
 
 
3
  import numpy as np
4
  from PIL import Image
5
  import gradio as gr
6
+ from io import BytesIO
7
 
8
 
9
  def gen_image(desc: str):
 
16
  access_token = os.environ['token']
17
  headers = {'content-type': "application/json", 'X-Subject-Token': access_token}
18
 
19
+ # url = f"https://a2f051d4cabf45f885d7b0108edc9b9c.infer.ovaijisuan.com/v1/infers/dce9ad51-7cde-4eeb-8291-ae29f267ed2c/wukong-hf"
20
+ url = f"https://a2f051d4cabf45f885d7b0108edc9b9c.infer.ovaijisuan.com/v1/infers/975eedfd-6e15-4571-8ca9-b945da0da24b/wukong-hf"
21
  body = {
22
  "desc": desc,
23
  "style": ""
 
26
  resp_data = requests.post(url, json=body, headers=headers)
27
  if resp_data['status'] != 200:
28
  return []
29
+ # img_np = np.array(resp_data['output_image_list'][0])
30
+ # image = Image.fromarray(np.uint8(img_np))
31
+ img_rep = requests.get(resp_data['output_image_url'][0])
32
+ image = Image.open(BytesIO(img_rep.content))
33
+
34
  return [image]
35
 
36