Spaces:
Sleeping
Sleeping
Merge branch 'main' into gradio-5.29.0
Browse files- app.py +19 -14
- gradio_dualvision/app_template.py +19 -0
app.py
CHANGED
|
@@ -21,21 +21,26 @@ class ImageFiltersApp(DualVisionApp):
|
|
| 21 |
gr.Markdown(
|
| 22 |
f"""
|
| 23 |
## {self.title}
|
| 24 |
-
|
| 25 |
-
<a title="Github" href="https://github.com/toshas/gradio-dualvision" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
| 26 |
-
<img src="https://img.shields.io/github/stars/toshas/gradio-dualvision?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
|
| 27 |
-
</a>
|
| 28 |
-
<a title="Social" href="https://twitter.com/antonobukhov1" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
| 29 |
-
<img src="https://shields.io/twitter/follow/:?label=Subscribe%20for%20updates!" alt="social">
|
| 30 |
-
</a>
|
| 31 |
-
</p>
|
| 32 |
-
<p align="center" style="margin-top: 0px;">
|
| 33 |
-
Upload a photo or select an example to process the input in real time.
|
| 34 |
-
Use the slider to reveal areas of interest.
|
| 35 |
-
Use the radio-buttons to switch between modalities.
|
| 36 |
-
</p>
|
| 37 |
-
"""
|
| 38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
def build_user_components(self):
|
| 41 |
"""
|
|
|
|
| 21 |
gr.Markdown(
|
| 22 |
f"""
|
| 23 |
## {self.title}
|
| 24 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
+
with gr.Row(elem_classes="remove-elements"):
|
| 27 |
+
gr.Markdown(
|
| 28 |
+
f"""
|
| 29 |
+
<p align="center">
|
| 30 |
+
<a title="Github" href="https://github.com/toshas/gradio-dualvision" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
| 31 |
+
<img src="https://img.shields.io/github/stars/toshas/gradio-dualvision?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
|
| 32 |
+
</a>
|
| 33 |
+
<a title="Social" href="https://twitter.com/antonobukhov1" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
| 34 |
+
<img src="https://shields.io/twitter/follow/:?label=Subscribe%20for%20updates!" alt="social">
|
| 35 |
+
</a>
|
| 36 |
+
</p>
|
| 37 |
+
<p align="center" style="margin-top: 0px;">
|
| 38 |
+
Upload a photo or select an example to process the input in real time.
|
| 39 |
+
Use the slider to reveal areas of interest.
|
| 40 |
+
Use the radio-buttons to switch between modalities.
|
| 41 |
+
</p>
|
| 42 |
+
"""
|
| 43 |
+
)
|
| 44 |
|
| 45 |
def build_user_components(self):
|
| 46 |
"""
|
gradio_dualvision/app_template.py
CHANGED
|
@@ -117,6 +117,25 @@ class DualVisionApp(gr.Blocks):
|
|
| 117 |
# fmt: off
|
| 118 |
self.head = (
|
| 119 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
<script>
|
| 121 |
let observerFooterButtons = new MutationObserver((mutationsList, observer) => {
|
| 122 |
const origButtonShowAPI = document.querySelector(".show-api");
|
|
|
|
| 117 |
# fmt: off
|
| 118 |
self.head = (
|
| 119 |
"""
|
| 120 |
+
<script>
|
| 121 |
+
window.addEventListener("message", (event) => {
|
| 122 |
+
if (event.data?.type === "remove-elements") {
|
| 123 |
+
const removeTargets = () => {
|
| 124 |
+
const targets = document.querySelectorAll(".remove-elements");
|
| 125 |
+
targets.forEach(el => el.remove());
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
removeTargets();
|
| 129 |
+
const observer = new MutationObserver(() => {
|
| 130 |
+
removeTargets();
|
| 131 |
+
});
|
| 132 |
+
observer.observe(document.body, { childList: true, subtree: true });
|
| 133 |
+
|
| 134 |
+
event.source?.postMessage({ type: "ack-remove-elements", source: "gradio-app" }, event.origin);
|
| 135 |
+
console.log("Processed event remove-elements");
|
| 136 |
+
}
|
| 137 |
+
});
|
| 138 |
+
</script>
|
| 139 |
<script>
|
| 140 |
let observerFooterButtons = new MutationObserver((mutationsList, observer) => {
|
| 141 |
const origButtonShowAPI = document.querySelector(".show-api");
|