Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -48,13 +48,13 @@ def get_canny_filter(image):
|
|
48 |
image = np.concatenate([image, image, image], axis=2)
|
49 |
canny_image = Image.fromarray(image)
|
50 |
return canny_image
|
51 |
-
def generate_images(canvas):
|
52 |
base64_img = canvas
|
53 |
image_data = base64.b64decode(base64_img.split(',')[1])
|
54 |
input_img = Image.open(BytesIO(image_data)).convert(
|
55 |
'RGB').resize((512, 512))
|
56 |
input_img = input_img.filter(ImageFilter.GaussianBlur(radius=2))
|
57 |
-
input_img = get_canny_filter(input_img)
|
58 |
return input_img
|
59 |
def placeholder_fn(axis):
|
60 |
pass
|
@@ -64,6 +64,7 @@ with gr.Blocks() as b:
|
|
64 |
with gr.Column():
|
65 |
rotation_axis = gr.Radio(choices=["x", "y", "z"], value="x", label="Joint rotation axis")
|
66 |
pose_template = gr.Radio(choices=["regular", "ballet", "handstand", "split", "kick", "chilling"], value="regular", label="Pose template")
|
|
|
67 |
run_button = gr.Button("Generate")
|
68 |
out_im = gr.Image()
|
69 |
|
@@ -78,7 +79,7 @@ with gr.Blocks() as b:
|
|
78 |
queue=False,
|
79 |
_js=js_pose_template)
|
80 |
run_button.click(fn=generate_images,
|
81 |
-
inputs=[canvas],
|
82 |
outputs=[out_im],
|
83 |
_js=get_js_image)
|
84 |
b.load(None,None,None,_js=load_js)
|
|
|
48 |
image = np.concatenate([image, image, image], axis=2)
|
49 |
canny_image = Image.fromarray(image)
|
50 |
return canny_image
|
51 |
+
def generate_images(canvas,output_type):
|
52 |
base64_img = canvas
|
53 |
image_data = base64.b64decode(base64_img.split(',')[1])
|
54 |
input_img = Image.open(BytesIO(image_data)).convert(
|
55 |
'RGB').resize((512, 512))
|
56 |
input_img = input_img.filter(ImageFilter.GaussianBlur(radius=2))
|
57 |
+
input_img = get_canny_filter(input_img) if output_type == "Canny" else pass
|
58 |
return input_img
|
59 |
def placeholder_fn(axis):
|
60 |
pass
|
|
|
64 |
with gr.Column():
|
65 |
rotation_axis = gr.Radio(choices=["x", "y", "z"], value="x", label="Joint rotation axis")
|
66 |
pose_template = gr.Radio(choices=["regular", "ballet", "handstand", "split", "kick", "chilling"], value="regular", label="Pose template")
|
67 |
+
output_type = gr.Radio(choices=["Depth", "Canny"], value="Depth", label="Image Output")
|
68 |
run_button = gr.Button("Generate")
|
69 |
out_im = gr.Image()
|
70 |
|
|
|
79 |
queue=False,
|
80 |
_js=js_pose_template)
|
81 |
run_button.click(fn=generate_images,
|
82 |
+
inputs=[canvas,output_type],
|
83 |
outputs=[out_im],
|
84 |
_js=get_js_image)
|
85 |
b.load(None,None,None,_js=load_js)
|