fixing clear button
Browse files- S2I/commons/controller.py +1 -1
- app.py +3 -39
S2I/commons/controller.py
CHANGED
@@ -70,7 +70,7 @@ class Sketch2ImageController():
|
|
70 |
|
71 |
if type_flag == 'live-sketch':
|
72 |
img = Image.fromarray(np.array(image["composite"])[:, :, -1])
|
73 |
-
elif type_flag == '
|
74 |
img = image["composite"]
|
75 |
|
76 |
img = img.convert("RGB")
|
|
|
70 |
|
71 |
if type_flag == 'live-sketch':
|
72 |
img = Image.fromarray(np.array(image["composite"])[:, :, -1])
|
73 |
+
elif type_flag == 'url-sketch':
|
74 |
img = image["composite"]
|
75 |
|
76 |
img = img.convert("RGB")
|
app.py
CHANGED
@@ -102,29 +102,6 @@ def get_meta_from_image(input_img, type_image):
|
|
102 |
return img_pil
|
103 |
|
104 |
|
105 |
-
# def get_meta_from_image(input_img, type_image):
|
106 |
-
# if input_img is None:
|
107 |
-
# return gr.update(value=None)
|
108 |
-
|
109 |
-
# file_content, _ = read_temp_file(input_img)
|
110 |
-
|
111 |
-
# # Read the image using Pillow
|
112 |
-
# img = Image.open(io.BytesIO(file_content)).convert("RGB")
|
113 |
-
# img_np = np.array(img)
|
114 |
-
|
115 |
-
# if type_image == 'RGB':
|
116 |
-
# sketch = convert_to_pencil_sketch(img_np)
|
117 |
-
# processed_img = 255 - sketch
|
118 |
-
# elif type_image == 'SKETCH':
|
119 |
-
# processed_img = 255 - img_np
|
120 |
-
|
121 |
-
# # Convert the processed image back to PIL Image
|
122 |
-
# img_pil = Image.fromarray(processed_img.astype('uint8'))
|
123 |
-
|
124 |
-
# return img_pil
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
with gr.Blocks(css=css, theme="NoCrypt/miku@1.2.1") as demo:
|
129 |
gr.HTML(
|
130 |
"""
|
@@ -259,7 +236,7 @@ with gr.Blocks(css=css, theme="NoCrypt/miku@1.2.1") as demo:
|
|
259 |
label="Type of Image (Color Image or Sketch Image)",
|
260 |
interactive=True)
|
261 |
input_type = gr.Radio(
|
262 |
-
choices=["live-sketch", "
|
263 |
value="live-sketch",
|
264 |
label="Type Sketch2Image models",
|
265 |
interactive=True)
|
@@ -315,15 +292,6 @@ with gr.Blocks(css=css, theme="NoCrypt/miku@1.2.1") as demo:
|
|
315 |
outputs = [result, download_sketch]
|
316 |
prompt.submit(fn=assign_gpu, inputs=inputs, outputs=outputs, api_name=False)
|
317 |
|
318 |
-
# input_image.change(
|
319 |
-
# fn=get_meta_from_image,
|
320 |
-
# inputs=[
|
321 |
-
# input_image, type_image
|
322 |
-
# ],
|
323 |
-
# outputs=[
|
324 |
-
# image
|
325 |
-
# ]
|
326 |
-
# )
|
327 |
|
328 |
style.change(
|
329 |
lambda x: controller.styles[x],
|
@@ -337,16 +305,12 @@ with gr.Blocks(css=css, theme="NoCrypt/miku@1.2.1") as demo:
|
|
337 |
outputs=outputs,
|
338 |
api_name=False,
|
339 |
)
|
340 |
-
clear_button.click(fn=clear_session, inputs=[], outputs=[image, result])
|
341 |
-
fn=assign_gpu,
|
342 |
-
inputs=inputs,
|
343 |
-
outputs=outputs,
|
344 |
-
api_name=False,
|
345 |
-
)
|
346 |
val_r.change(assign_gpu, inputs=inputs, outputs=outputs, queue=False, api_name=False)
|
347 |
run_button.click(fn=assign_gpu, inputs=inputs, outputs=outputs, api_name=False)
|
348 |
image.change(assign_gpu, inputs=inputs, outputs=outputs, queue=False, api_name=False)
|
349 |
url_image.submit(fn=get_meta_from_image, inputs=[url_image, type_image], outputs=[image])
|
|
|
350 |
if __name__ == '__main__':
|
351 |
demo.queue()
|
352 |
demo.launch(debug=True, share=False)
|
|
|
102 |
return img_pil
|
103 |
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
with gr.Blocks(css=css, theme="NoCrypt/miku@1.2.1") as demo:
|
106 |
gr.HTML(
|
107 |
"""
|
|
|
236 |
label="Type of Image (Color Image or Sketch Image)",
|
237 |
interactive=True)
|
238 |
input_type = gr.Radio(
|
239 |
+
choices=["live-sketch", "url-sketch"],
|
240 |
value="live-sketch",
|
241 |
label="Type Sketch2Image models",
|
242 |
interactive=True)
|
|
|
292 |
outputs = [result, download_sketch]
|
293 |
prompt.submit(fn=assign_gpu, inputs=inputs, outputs=outputs, api_name=False)
|
294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
style.change(
|
297 |
lambda x: controller.styles[x],
|
|
|
305 |
outputs=outputs,
|
306 |
api_name=False,
|
307 |
)
|
308 |
+
clear_button.click(fn=clear_session, inputs=[], outputs=[image, result])
|
|
|
|
|
|
|
|
|
|
|
309 |
val_r.change(assign_gpu, inputs=inputs, outputs=outputs, queue=False, api_name=False)
|
310 |
run_button.click(fn=assign_gpu, inputs=inputs, outputs=outputs, api_name=False)
|
311 |
image.change(assign_gpu, inputs=inputs, outputs=outputs, queue=False, api_name=False)
|
312 |
url_image.submit(fn=get_meta_from_image, inputs=[url_image, type_image], outputs=[image])
|
313 |
+
url_image.change(fn=get_meta_from_image, inputs=[url_image, type_image], outputs=[image])
|
314 |
if __name__ == '__main__':
|
315 |
demo.queue()
|
316 |
demo.launch(debug=True, share=False)
|