Spaces:
Running
on
Zero
Running
on
Zero
xinjie.wang
commited on
Commit
·
ca03543
1
Parent(s):
8598875
update
Browse files
app.py
CHANGED
@@ -41,12 +41,23 @@ with gr.Blocks(
|
|
41 |
type="pil",
|
42 |
visible=False,
|
43 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
image_prompt = gr.Image(
|
45 |
label="Input Image",
|
46 |
format="png",
|
47 |
image_mode="RGBA",
|
48 |
type="pil",
|
49 |
-
height=
|
|
|
50 |
)
|
51 |
gr.Markdown(
|
52 |
"""
|
@@ -59,7 +70,7 @@ with gr.Blocks(
|
|
59 |
with gr.Row():
|
60 |
with gr.Column(scale=1):
|
61 |
image_prompt_sam = gr.Image(
|
62 |
-
label="Input Image", type="numpy", height=
|
63 |
)
|
64 |
image_seg_sam = gr.Image(
|
65 |
label="SAM Seg Image",
|
@@ -445,4 +456,4 @@ with gr.Blocks(
|
|
445 |
|
446 |
if __name__ == "__main__":
|
447 |
demo.launch()
|
448 |
-
|
|
|
41 |
type="pil",
|
42 |
visible=False,
|
43 |
)
|
44 |
+
|
45 |
+
css = """
|
46 |
+
<style>
|
47 |
+
#img1 img {
|
48 |
+
object-fit: contain !important;
|
49 |
+
width: 100% !important;
|
50 |
+
height: 100% !important;
|
51 |
+
}
|
52 |
+
</style>
|
53 |
+
"""
|
54 |
image_prompt = gr.Image(
|
55 |
label="Input Image",
|
56 |
format="png",
|
57 |
image_mode="RGBA",
|
58 |
type="pil",
|
59 |
+
height=300,
|
60 |
+
elem_id="img1",
|
61 |
)
|
62 |
gr.Markdown(
|
63 |
"""
|
|
|
70 |
with gr.Row():
|
71 |
with gr.Column(scale=1):
|
72 |
image_prompt_sam = gr.Image(
|
73 |
+
label="Input Image", type="numpy", height=500
|
74 |
)
|
75 |
image_seg_sam = gr.Image(
|
76 |
label="SAM Seg Image",
|
|
|
456 |
|
457 |
if __name__ == "__main__":
|
458 |
demo.launch()
|
459 |
+
|
common.py
CHANGED
@@ -208,7 +208,7 @@ def preprocess_image_fn(
|
|
208 |
return image, image_cache
|
209 |
|
210 |
|
211 |
-
@spaces.GPU
|
212 |
def preprocess_sam_image_fn(
|
213 |
image: Image.Image
|
214 |
) -> tuple[Image.Image, Image.Image]:
|
@@ -251,6 +251,8 @@ def get_selected_image(
|
|
251 |
|
252 |
|
253 |
def get_cached_image(image_path: str) -> Image.Image:
|
|
|
|
|
254 |
return Image.open(image_path).resize((512, 512))
|
255 |
|
256 |
|
|
|
208 |
return image, image_cache
|
209 |
|
210 |
|
211 |
+
# @spaces.GPU
|
212 |
def preprocess_sam_image_fn(
|
213 |
image: Image.Image
|
214 |
) -> tuple[Image.Image, Image.Image]:
|
|
|
251 |
|
252 |
|
253 |
def get_cached_image(image_path: str) -> Image.Image:
|
254 |
+
if isinstance(image_path, Image.Image):
|
255 |
+
return image_path
|
256 |
return Image.open(image_path).resize((512, 512))
|
257 |
|
258 |
|