Spaces:
Sleeping
Sleeping
[fix] fix vis_blob bugs
Browse files
examples/blobctrl/blobctrl_app.py
CHANGED
|
@@ -63,8 +63,6 @@ if not os.path.exists(Dino_path):
|
|
| 63 |
)
|
| 64 |
print(f"Dino checkpoints downloaded to {Dino_path}")
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
# download SAM model
|
| 69 |
SAM_path = "examples/blobctrl/models/sam/sam_vit_h_4b8939.pth"
|
| 70 |
if not os.path.exists(SAM_path):
|
|
@@ -173,13 +171,12 @@ head= r"""
|
|
| 173 |
descriptions = r"""
|
| 174 |
Official Gradio Demo for <a href=''><b>BlobCtrl: A Unified and Flexible Framework for Element-level Image Generation and Editing</b></a><br>
|
| 175 |
π¦ BlobCtrl enables precise, user-friendly element-level visual manipulation. <br>
|
| 176 |
-
Main Features: Element-level Add/Remove/Move/Replace/Enlarge/Shrink.
|
| 177 |
"""
|
| 178 |
|
| 179 |
|
| 180 |
citation = r"""
|
| 181 |
If BlobCtrl is helpful, please help to β the <a href='https://github.com/TencentARC/BlobCtrl' target='_blank'>Github Repo</a>. Thanks!
|
| 182 |
-
[](
|
| 183 |
---
|
| 184 |
π **Citation**
|
| 185 |
<br>
|
|
@@ -187,9 +184,9 @@ If our work is useful for your research, please consider citing:
|
|
| 187 |
```bibtex
|
| 188 |
@misc{li2025blobctrl,
|
| 189 |
title={BlobCtrl: A Unified and Flexible Framework for Element-level Image Generation and Editing},
|
| 190 |
-
author={Yaowei Li
|
| 191 |
year={2025},
|
| 192 |
-
eprint={
|
| 193 |
archivePrefix={arXiv},
|
| 194 |
primaryClass={cs.CV}
|
| 195 |
}
|
|
@@ -1771,7 +1768,7 @@ with block as demo:
|
|
| 1771 |
|
| 1772 |
remove_blob_box.change(
|
| 1773 |
remove_blob_box_func,
|
| 1774 |
-
[editable_blob, original_image, tracking_points, ellipse_lists, ori_result_gallery],
|
| 1775 |
[editable_blob, ellipse_lists, edited_result_gallery, ori_result_gallery, resize_blob_slider_maintain_aspect_ratio]
|
| 1776 |
)
|
| 1777 |
|
|
@@ -1804,7 +1801,7 @@ with block as demo:
|
|
| 1804 |
## upload user-specified object image
|
| 1805 |
init_object_image.upload(
|
| 1806 |
upload_object_image,
|
| 1807 |
-
[init_object_image, edited_result_gallery],
|
| 1808 |
[object_image_gallery, remove_blob_box]
|
| 1809 |
)
|
| 1810 |
|
|
|
|
| 63 |
)
|
| 64 |
print(f"Dino checkpoints downloaded to {Dino_path}")
|
| 65 |
|
|
|
|
|
|
|
| 66 |
# download SAM model
|
| 67 |
SAM_path = "examples/blobctrl/models/sam/sam_vit_h_4b8939.pth"
|
| 68 |
if not os.path.exists(SAM_path):
|
|
|
|
| 171 |
descriptions = r"""
|
| 172 |
Official Gradio Demo for <a href=''><b>BlobCtrl: A Unified and Flexible Framework for Element-level Image Generation and Editing</b></a><br>
|
| 173 |
π¦ BlobCtrl enables precise, user-friendly element-level visual manipulation. <br>
|
|
|
|
| 174 |
"""
|
| 175 |
|
| 176 |
|
| 177 |
citation = r"""
|
| 178 |
If BlobCtrl is helpful, please help to β the <a href='https://github.com/TencentARC/BlobCtrl' target='_blank'>Github Repo</a>. Thanks!
|
| 179 |
+
[]()
|
| 180 |
---
|
| 181 |
π **Citation**
|
| 182 |
<br>
|
|
|
|
| 184 |
```bibtex
|
| 185 |
@misc{li2025blobctrl,
|
| 186 |
title={BlobCtrl: A Unified and Flexible Framework for Element-level Image Generation and Editing},
|
| 187 |
+
author={Yaowei Li},
|
| 188 |
year={2025},
|
| 189 |
+
eprint={2502.09477},
|
| 190 |
archivePrefix={arXiv},
|
| 191 |
primaryClass={cs.CV}
|
| 192 |
}
|
|
|
|
| 1768 |
|
| 1769 |
remove_blob_box.change(
|
| 1770 |
remove_blob_box_func,
|
| 1771 |
+
[editable_blob, original_image, tracking_points, ellipse_lists, ori_result_gallery, remove_blob_box],
|
| 1772 |
[editable_blob, ellipse_lists, edited_result_gallery, ori_result_gallery, resize_blob_slider_maintain_aspect_ratio]
|
| 1773 |
)
|
| 1774 |
|
|
|
|
| 1801 |
## upload user-specified object image
|
| 1802 |
init_object_image.upload(
|
| 1803 |
upload_object_image,
|
| 1804 |
+
[init_object_image, edited_result_gallery, remove_blob_box],
|
| 1805 |
[object_image_gallery, remove_blob_box]
|
| 1806 |
)
|
| 1807 |
|
examples/blobctrl/utils/utils.py
CHANGED
|
@@ -211,7 +211,7 @@ def splat_features(
|
|
| 211 |
scores_viz = d_scores
|
| 212 |
|
| 213 |
n_gaussians = xs.shape[-1]
|
| 214 |
-
ret.update(visualize_features(
|
| 215 |
# from PIL import Image
|
| 216 |
# import numpy as np
|
| 217 |
# viz_colors = torch.load("BED_CONF_COLORS.pt")
|
|
@@ -243,7 +243,7 @@ def splat_features(
|
|
| 243 |
|
| 244 |
@torch.no_grad()
|
| 245 |
def visualize_features(viz_size=64, n_gaussians=None, scores=None,
|
| 246 |
-
viz_colors=None
|
| 247 |
n_gaussians = n_gaussians+1
|
| 248 |
|
| 249 |
rand_colors = viz_colors is None
|
|
|
|
| 211 |
scores_viz = d_scores
|
| 212 |
|
| 213 |
n_gaussians = xs.shape[-1]
|
| 214 |
+
ret.update(visualize_features(viz_size, n_gaussians, scores_viz, kwargs.get("viz_colors", None)))
|
| 215 |
# from PIL import Image
|
| 216 |
# import numpy as np
|
| 217 |
# viz_colors = torch.load("BED_CONF_COLORS.pt")
|
|
|
|
| 243 |
|
| 244 |
@torch.no_grad()
|
| 245 |
def visualize_features(viz_size=64, n_gaussians=None, scores=None,
|
| 246 |
+
viz_colors=None) -> Dict[str, Tensor]:
|
| 247 |
n_gaussians = n_gaussians+1
|
| 248 |
|
| 249 |
rand_colors = viz_colors is None
|