Staticaliza commited on
Commit
e564e9e
·
verified ·
1 Parent(s): 71096db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -133,7 +133,19 @@ def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATI
133
 
134
  print(nsfw_prediction)
135
 
136
- return image_paths, {item['label']: round(item['score'], 3) for item in nsfw_prediction}
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  def cloud():
139
  print("[CLOUD] | Space maintained.")
@@ -160,6 +172,7 @@ with gr.Blocks(css=css) as main:
160
  with gr.Column():
161
  output = gr.Gallery(columns=1, label="Image")
162
  output_2 = gr.Label()
 
163
 
164
  submit.click(generate, inputs=[input, filter_input, negative_input, model, height, width, steps, guidance, number, seed], outputs=[output, output_2], queue=False)
165
  maintain.click(cloud, inputs=[], outputs=[], queue=False)
 
133
 
134
  print(nsfw_prediction)
135
 
136
+ image = images[0].convert("RGBA")
137
+ image = image.resize((width, height))
138
+ json_data = []
139
+
140
+ for x in range(image.width):
141
+ json_data.append([])
142
+ for y in range(image.height):
143
+ r, g, b, a = image.getpixel((x, y))
144
+ json_data[x].append([r, g, b, a])
145
+
146
+ json_string = json.dumps(json_data)
147
+
148
+ return image_paths, {item['label']: round(item['score'], 3) for item in nsfw_prediction}, json_string
149
 
150
  def cloud():
151
  print("[CLOUD] | Space maintained.")
 
172
  with gr.Column():
173
  output = gr.Gallery(columns=1, label="Image")
174
  output_2 = gr.Label()
175
+ output_3 = gr.Textbox(lines=1, value="", label="Buffer")
176
 
177
  submit.click(generate, inputs=[input, filter_input, negative_input, model, height, width, steps, guidance, number, seed], outputs=[output, output_2], queue=False)
178
  maintain.click(cloud, inputs=[], outputs=[], queue=False)