Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,51 +44,29 @@ def combine_images(dress_image, design_image, position, size):
|
|
44 |
|
45 |
def interface():
|
46 |
with gr.Blocks() as demo:
|
47 |
-
gr.Markdown("## Image Editor with
|
48 |
dress_image = gr.Image(type="pil", label="Upload Dress Image")
|
49 |
-
design_image = gr.Image(type="pil", label="Upload Design Image"
|
50 |
-
|
51 |
position = gr.Textbox(placeholder="Enter position as x,y", value="100,100", label="Position")
|
52 |
size = gr.Textbox(placeholder="Enter size as width,height", value="200,200", label="Size")
|
53 |
-
|
54 |
btn = gr.Button("Fit Design")
|
55 |
output = gr.Image(type="pil", label="Final Output")
|
56 |
|
57 |
-
#
|
58 |
btn.click(
|
59 |
combine_images,
|
60 |
inputs=[dress_image, design_image, position, size],
|
61 |
outputs=output
|
62 |
)
|
63 |
|
64 |
-
#
|
65 |
gr.HTML("""
|
66 |
<script>
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
designImg.addEventListener('mousedown', (e) => {
|
72 |
-
startX = e.clientX;
|
73 |
-
startY = e.clientY;
|
74 |
-
initialX = designImg.offsetLeft;
|
75 |
-
initialY = designImg.offsetTop;
|
76 |
-
|
77 |
-
document.onmousemove = (e) => {
|
78 |
-
const dx = e.clientX - startX;
|
79 |
-
const dy = e.clientY - startY;
|
80 |
-
designImg.style.position = 'absolute';
|
81 |
-
designImg.style.left = (initialX + dx) + 'px';
|
82 |
-
designImg.style.top = (initialY + dy) + 'px';
|
83 |
-
}
|
84 |
-
});
|
85 |
-
|
86 |
-
document.onmouseup = () => {
|
87 |
-
document.onmousemove = document.onmouseup = null;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
window.onload = initDragAndDrop;
|
92 |
</script>
|
93 |
""")
|
94 |
|
|
|
44 |
|
45 |
def interface():
|
46 |
with gr.Blocks() as demo:
|
47 |
+
gr.Markdown("## Image Editor with Basic Interaction")
|
48 |
dress_image = gr.Image(type="pil", label="Upload Dress Image")
|
49 |
+
design_image = gr.Image(type="pil", label="Upload Design Image")
|
50 |
+
|
51 |
position = gr.Textbox(placeholder="Enter position as x,y", value="100,100", label="Position")
|
52 |
size = gr.Textbox(placeholder="Enter size as width,height", value="200,200", label="Size")
|
53 |
+
|
54 |
btn = gr.Button("Fit Design")
|
55 |
output = gr.Image(type="pil", label="Final Output")
|
56 |
|
57 |
+
# Button click function
|
58 |
btn.click(
|
59 |
combine_images,
|
60 |
inputs=[dress_image, design_image, position, size],
|
61 |
outputs=output
|
62 |
)
|
63 |
|
64 |
+
# Add JavaScript for additional interactivity (basic example)
|
65 |
gr.HTML("""
|
66 |
<script>
|
67 |
+
// JavaScript code for drag-and-drop functionality
|
68 |
+
// This code needs to be customized based on how images are rendered
|
69 |
+
// and will likely require additional adjustments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
</script>
|
71 |
""")
|
72 |
|