Update app.py
Browse files
app.py
CHANGED
|
@@ -183,7 +183,7 @@ def segment_frame(evt: gr.SelectData, label, video_state):
|
|
| 183 |
video_state["input_labels"].append(label_value)
|
| 184 |
height, width = video_state["origin_images"][0].shape[0:2]
|
| 185 |
scaled_points = []
|
| 186 |
-
for pt in video_state["input_points"]:
|
| 187 |
sx = pt[0] / width
|
| 188 |
sy = pt[1] / height
|
| 189 |
scaled_points.append([sx, sy])
|
|
@@ -270,7 +270,7 @@ def segment_ref_frame(evt: gr.SelectData, label, ref_state):
|
|
| 270 |
h, w = img.shape[:2]
|
| 271 |
|
| 272 |
scaled_points = []
|
| 273 |
-
for pt in ref_state["input_points"]:
|
| 274 |
sx = pt[0] / w
|
| 275 |
sy = pt[1] / h
|
| 276 |
scaled_points.append([sx, sy])
|
|
@@ -542,68 +542,6 @@ with gr.Blocks() as demo:
|
|
| 542 |
}
|
| 543 |
)
|
| 544 |
|
| 545 |
-
demo.css = """
|
| 546 |
-
.gradio-container {
|
| 547 |
-
max-width: 60% !important;
|
| 548 |
-
margin: 0 auto !important;
|
| 549 |
-
}
|
| 550 |
-
|
| 551 |
-
#my-btn {
|
| 552 |
-
width: 60% !important;
|
| 553 |
-
margin: 0 auto;
|
| 554 |
-
}
|
| 555 |
-
#my-video1 {
|
| 556 |
-
width: 60% !important;
|
| 557 |
-
height: 35% !important;
|
| 558 |
-
margin: 0 auto;
|
| 559 |
-
}
|
| 560 |
-
#my-video {
|
| 561 |
-
width: 60% !important;
|
| 562 |
-
height: 35% !important;
|
| 563 |
-
margin: 0 auto;
|
| 564 |
-
}
|
| 565 |
-
#my-md {
|
| 566 |
-
margin: 0 auto;
|
| 567 |
-
}
|
| 568 |
-
#my-btn2 {
|
| 569 |
-
width: 60% !important;
|
| 570 |
-
margin: 0 auto;
|
| 571 |
-
}
|
| 572 |
-
#my-btn2 button {
|
| 573 |
-
width: 120px !important;
|
| 574 |
-
max-width: 120px !important;
|
| 575 |
-
min-width: 120px !important;
|
| 576 |
-
height: 70px !important;
|
| 577 |
-
max-height: 70px !important;
|
| 578 |
-
min-height: 70px !important;
|
| 579 |
-
margin: 8px !important;
|
| 580 |
-
border-radius: 8px !important;
|
| 581 |
-
overflow: hidden !important;
|
| 582 |
-
white-space: normal !important;
|
| 583 |
-
}
|
| 584 |
-
#my-btn3 {
|
| 585 |
-
width: 60% !important;
|
| 586 |
-
margin: 0 auto;
|
| 587 |
-
}
|
| 588 |
-
#ref_title {
|
| 589 |
-
text-align: center;
|
| 590 |
-
}
|
| 591 |
-
#ref-image {
|
| 592 |
-
width: 60% !important;
|
| 593 |
-
height: 35% !important;
|
| 594 |
-
margin: 0 auto;
|
| 595 |
-
}
|
| 596 |
-
#ref-mask {
|
| 597 |
-
width: 60% !important;
|
| 598 |
-
height: 35% !important;
|
| 599 |
-
margin: 0 auto;
|
| 600 |
-
}
|
| 601 |
-
#mesh-row {
|
| 602 |
-
width: 60% !important;
|
| 603 |
-
margin: 0 auto;
|
| 604 |
-
}
|
| 605 |
-
"""
|
| 606 |
-
|
| 607 |
gr.Markdown(f"<div style='text-align:center;'>{text}</div>")
|
| 608 |
|
| 609 |
with gr.Column():
|
|
@@ -630,6 +568,63 @@ with gr.Blocks() as demo:
|
|
| 630 |
elem_id="my-video",
|
| 631 |
)
|
| 632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
with gr.Row(elem_id="my-btn"):
|
| 634 |
point_prompt = gr.Radio(
|
| 635 |
["Positive", "Negative"], label="Click Type", value="Positive"
|
|
|
|
| 183 |
video_state["input_labels"].append(label_value)
|
| 184 |
height, width = video_state["origin_images"][0].shape[0:2]
|
| 185 |
scaled_points = []
|
| 186 |
+
for pt in video_state["input_points"]):
|
| 187 |
sx = pt[0] / width
|
| 188 |
sy = pt[1] / height
|
| 189 |
scaled_points.append([sx, sy])
|
|
|
|
| 270 |
h, w = img.shape[:2]
|
| 271 |
|
| 272 |
scaled_points = []
|
| 273 |
+
for pt in ref_state["input_points"]):
|
| 274 |
sx = pt[0] / w
|
| 275 |
sy = pt[1] / h
|
| 276 |
scaled_points.append([sx, sy])
|
|
|
|
| 542 |
}
|
| 543 |
)
|
| 544 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
gr.Markdown(f"<div style='text-align:center;'>{text}</div>")
|
| 546 |
|
| 547 |
with gr.Column():
|
|
|
|
| 568 |
elem_id="my-video",
|
| 569 |
)
|
| 570 |
|
| 571 |
+
demo.css = """
|
| 572 |
+
#my-btn {
|
| 573 |
+
width: 60% !important;
|
| 574 |
+
margin: 0 auto;
|
| 575 |
+
}
|
| 576 |
+
#my-video1 {
|
| 577 |
+
width: 60% !important;
|
| 578 |
+
height: 35% !important;
|
| 579 |
+
margin: 0 auto;
|
| 580 |
+
}
|
| 581 |
+
#my-video {
|
| 582 |
+
width: 60% !important;
|
| 583 |
+
height: 35% !important;
|
| 584 |
+
margin: 0 auto;
|
| 585 |
+
}
|
| 586 |
+
#my-md {
|
| 587 |
+
margin: 0 auto;
|
| 588 |
+
}
|
| 589 |
+
#my-btn2 {
|
| 590 |
+
width: 60% !important;
|
| 591 |
+
margin: 0 auto;
|
| 592 |
+
}
|
| 593 |
+
#my-btn2 button {
|
| 594 |
+
width: 120px !important;
|
| 595 |
+
max-width: 120px !important;
|
| 596 |
+
min-width: 120px !important;
|
| 597 |
+
height: 70px !important;
|
| 598 |
+
max-height: 70px !important;
|
| 599 |
+
min-height: 70px !important;
|
| 600 |
+
margin: 8px !important;
|
| 601 |
+
border-radius: 8px !important;
|
| 602 |
+
overflow: hidden !important;
|
| 603 |
+
white-space: normal !important;
|
| 604 |
+
}
|
| 605 |
+
#my-btn3 {
|
| 606 |
+
width: 60% !important;
|
| 607 |
+
margin: 0 auto;
|
| 608 |
+
}
|
| 609 |
+
#ref_title {
|
| 610 |
+
text-align: center;
|
| 611 |
+
}
|
| 612 |
+
#ref-image {
|
| 613 |
+
width: 60% !important;
|
| 614 |
+
height: 35% !important;
|
| 615 |
+
margin: 0 auto;
|
| 616 |
+
}
|
| 617 |
+
#ref-mask {
|
| 618 |
+
width: 60% !important;
|
| 619 |
+
height: 35% !important;
|
| 620 |
+
margin: 0 auto;
|
| 621 |
+
}
|
| 622 |
+
#mesh-row {
|
| 623 |
+
width: 60% !important;
|
| 624 |
+
margin: 0 auto;
|
| 625 |
+
}
|
| 626 |
+
"""
|
| 627 |
+
|
| 628 |
with gr.Row(elem_id="my-btn"):
|
| 629 |
point_prompt = gr.Radio(
|
| 630 |
["Positive", "Negative"], label="Click Type", value="Positive"
|