nsfwalex commited on
Commit
56a8f0f
โ€ข
1 Parent(s): 5de4fd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -114,8 +114,22 @@ body {
114
  }
115
  footer {display: none !important;}
116
  """
 
 
 
 
 
 
 
 
 
117
 
118
- with gr.Blocks(css=css) as demo:
 
 
 
 
 
119
  width=240
120
  height=340
121
 
@@ -130,6 +144,6 @@ with gr.Blocks(css=css) as demo:
130
  processed_img = inference(img)
131
  return processed_img
132
 
133
- process_button.click(update_status, inputs=image_input, outputs=image_input)
134
  demo.queue(max_size=10)
135
  demo.launch()
 
114
  }
115
  footer {display: none !important;}
116
  """
117
+ js='''
118
+ window.postMessageToParent = function(event, source, value) {
119
+ // Construct the message object with the provided parameters
120
+ console.log("post start",event, source, value)
121
+ const message = {
122
+ event: event,
123
+ source: source,
124
+ value: value
125
+ };
126
 
127
+ // Post the message to the parent window
128
+ window.parent.postMessage(message, '*');
129
+ console.log("post finish")
130
+ }
131
+ '''
132
+ with gr.Blocks(css=css, head=js) as demo:
133
  width=240
134
  height=340
135
 
 
144
  processed_img = inference(img)
145
  return processed_img
146
 
147
+ process_button.click(update_status, inputs=image_input, outputs=image_input, js='''() => window.postMessageToParent(event, source, value);''')
148
  demo.queue(max_size=10)
149
  demo.launch()