Spaces:
Running
Running
MonkeyJuice
commited on
Commit
•
d3cab6f
1
Parent(s):
e48745e
Update cropImage style
Browse files- app.py +5 -4
- cropImage.py +2 -1
- style.css +7 -0
app.py
CHANGED
@@ -49,13 +49,14 @@ with gr.Blocks(css="style.css", js="script.js") as demo:
|
|
49 |
maximum=1,
|
50 |
step=0.1,
|
51 |
value=0.3)
|
52 |
-
run_button = gr.Button('Run')
|
53 |
-
|
54 |
-
|
55 |
-
crop_image = gr.Image(elem_classes='m5dd_image',
|
56 |
format='jpg',
|
57 |
show_label=False,
|
|
|
58 |
container=False)
|
|
|
59 |
with gr.Column(scale=2):
|
60 |
result_html = gr.HTML(value="")
|
61 |
with gr.Tab(label='Batch'):
|
|
|
49 |
maximum=1,
|
50 |
step=0.1,
|
51 |
value=0.3)
|
52 |
+
run_button = gr.Button('Run')
|
53 |
+
with gr.Accordion(label="Crop Image", open=False):
|
54 |
+
crop_image = gr.Image(elem_classes='m5dd_image2',
|
|
|
55 |
format='jpg',
|
56 |
show_label=False,
|
57 |
+
show_share_button=False,
|
58 |
container=False)
|
59 |
+
result_text = gr.HTML(value="")
|
60 |
with gr.Column(scale=2):
|
61 |
result_html = gr.HTML(value="")
|
62 |
with gr.Tab(label='Batch'):
|
cropImage.py
CHANGED
@@ -24,8 +24,9 @@ def cropImage(image: PIL.Image.Image):
|
|
24 |
else:
|
25 |
new_height = int(original_width * (target_height / target_width))
|
26 |
crop_box = (0, (original_height - new_height) // 2, original_width, (original_height + new_height) // 2)
|
27 |
-
cropped_image = image.crop(crop_box)
|
28 |
|
|
|
|
|
29 |
cropped_image = cropped_image.resize((target_width, target_height))
|
30 |
|
31 |
return cropped_image
|
|
|
24 |
else:
|
25 |
new_height = int(original_width * (target_height / target_width))
|
26 |
crop_box = (0, (original_height - new_height) // 2, original_width, (original_height + new_height) // 2)
|
|
|
27 |
|
28 |
+
cropped_image = image.convert("RGB")
|
29 |
+
cropped_image = cropped_image.crop(crop_box)
|
30 |
cropped_image = cropped_image.resize((target_width, target_height))
|
31 |
|
32 |
return cropped_image
|
style.css
CHANGED
@@ -27,3 +27,10 @@
|
|
27 |
.m5dd_image .upload-container .image-frame {
|
28 |
height: 20em;
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
.m5dd_image .upload-container .image-frame {
|
28 |
height: 20em;
|
29 |
}
|
30 |
+
|
31 |
+
.m5dd_image .upload-container .image-frame {
|
32 |
+
height: 20em;
|
33 |
+
}
|
34 |
+
.m5dd_image2 .image-container {
|
35 |
+
height: 20em;
|
36 |
+
}
|