Spaces:
Runtime error
Runtime error
Logan Zoellner
commited on
Commit
·
1da0e2a
1
Parent(s):
f607082
convert file type
Browse files
app.py
CHANGED
@@ -5,6 +5,11 @@ import os
|
|
5 |
import re
|
6 |
import random
|
7 |
from words import *
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# GPT-J-6B API
|
10 |
API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B"
|
@@ -151,7 +156,14 @@ def desc_to_image_cf(desc):
|
|
151 |
im_prompt_weight =1
|
152 |
result = cf.fns[0].fn(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, range_scale, init_scale, seed, image_prompts,timestep_respacing, cutn, im_prompt_weight)
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
|
157 |
demo = gr.Blocks()
|
|
|
5 |
import re
|
6 |
import random
|
7 |
from words import *
|
8 |
+
from base64 import b64decode
|
9 |
+
from PIL import Image
|
10 |
+
import io
|
11 |
+
import numpy as np
|
12 |
+
|
13 |
|
14 |
# GPT-J-6B API
|
15 |
API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B"
|
|
|
156 |
im_prompt_weight =1
|
157 |
result = cf.fns[0].fn(text, init_image, skip_timesteps, clip_guidance_scale, tv_scale, range_scale, init_scale, seed, image_prompts,timestep_respacing, cutn, im_prompt_weight)
|
158 |
|
159 |
+
|
160 |
+
#convert result from dataurl to image
|
161 |
+
img=result[0]
|
162 |
+
header, encoded = img.split(",", 1)
|
163 |
+
data = b64decode(encoded)
|
164 |
+
image = Image.open(io.BytesIO(data))
|
165 |
+
image_np = np.array(image)
|
166 |
+
return image_np
|
167 |
|
168 |
|
169 |
demo = gr.Blocks()
|