lnyan commited on
Commit
1a412ba
1 Parent(s): bbcdb4a

Update index.html

Browse files
Files changed (2) hide show
  1. app.py +16 -1
  2. index.html +1 -1
app.py CHANGED
@@ -126,7 +126,22 @@ def run_outpaint(
126
  state,
127
  ):
128
  base64_str = "base64"
129
- return sel_buffer_str
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  if True:
131
  text2img, inpaint = get_model()
132
  if enable_safety:
 
126
  state,
127
  ):
128
  base64_str = "base64"
129
+ data = base64.b64decode(str(sel_buffer_str))
130
+ pil = Image.open(io.BytesIO(data))
131
+ sel_buffer = np.array(pil)
132
+ sel_buffer[:, :, 3]=255
133
+ sel_buffer[:, :, 0]=255
134
+ out_pil = Image.fromarray(sel_buffer)
135
+ out_buffer = io.BytesIO()
136
+ out_pil.save(out_buffer, format="PNG")
137
+ out_buffer.seek(0)
138
+ base64_bytes = base64.b64encode(out_buffer.read())
139
+ base64_str = base64_bytes.decode("ascii")
140
+ return (
141
+ gr.update(label=str(state + 1), value=base64_str,),
142
+ gr.update(label="Prompt"),
143
+ state + 1,
144
+ )
145
  if True:
146
  text2img, inpaint = get_model()
147
  if enable_safety:
index.html CHANGED
@@ -152,7 +152,7 @@ async def transfer_func(event):
152
  base.read_selection_from_buffer()
153
  sel_buffer=base.sel_buffer
154
  sel_buffer_str=base.numpy_to_base64(sel_buffer)
155
- parent.postMessage(["transfer",sel_buffer_str],"*")
156
 
157
  async def upload_func(event):
158
  base=base_lst[0]
 
152
  base.read_selection_from_buffer()
153
  sel_buffer=base.sel_buffer
154
  sel_buffer_str=base.numpy_to_base64(sel_buffer)
155
+ parent.postMessage(to_js(["transfer",str(sel_buffer_str)]),"*")
156
 
157
  async def upload_func(event):
158
  base=base_lst[0]