Darius Morawiec
commited on
Commit
·
76a03fa
1
Parent(s):
376dc00
chore: Update UI
Browse files
app.py
CHANGED
|
@@ -16,6 +16,8 @@ from transformers import (
|
|
| 16 |
Qwen3VLForConditionalGeneration,
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
| 19 |
# Handle spaces.GPU decorator for GPU allocation in Spaces
|
| 20 |
if "SPACES_ZERO_GPU" in os.environ.keys():
|
| 21 |
import spaces
|
|
@@ -143,7 +145,7 @@ def image_to_base64(image):
|
|
| 143 |
return img_str
|
| 144 |
|
| 145 |
|
| 146 |
-
with gr.Blocks() as demo:
|
| 147 |
gr.Markdown("# Qwen-VL Object-Detection")
|
| 148 |
gr.Markdown(
|
| 149 |
"Compare [Qwen3-VL](https://huggingface.co/collections/Qwen/qwen3-vl), [Qwen2.5-VL](https://huggingface.co/collections/Qwen/qwen25-vl) and [Qwen2-VL](https://huggingface.co/collections/Qwen/qwen2-vl) models by [Qwen](https://huggingface.co/Qwen) for object detection."
|
|
@@ -396,10 +398,13 @@ with gr.Blocks() as demo:
|
|
| 396 |
],
|
| 397 |
)
|
| 398 |
|
|
|
|
|
|
|
| 399 |
if DEVICE != "cuda":
|
| 400 |
gr.Markdown(
|
| 401 |
"👉 It's recommended to run this application on a machine with a CUDA-compatible GPU for optimal performance. You can clone this space locally or duplicate this space with a CUDA-enabled runtime."
|
| 402 |
)
|
|
|
|
| 403 |
|
| 404 |
# Connect the button to the detection function
|
| 405 |
run_button.click(
|
|
@@ -421,5 +426,5 @@ with gr.Blocks() as demo:
|
|
| 421 |
|
| 422 |
if __name__ == "__main__":
|
| 423 |
demo.launch(
|
| 424 |
-
|
| 425 |
)
|
|
|
|
| 16 |
Qwen3VLForConditionalGeneration,
|
| 17 |
)
|
| 18 |
|
| 19 |
+
from kofi import SCRIPT
|
| 20 |
+
|
| 21 |
# Handle spaces.GPU decorator for GPU allocation in Spaces
|
| 22 |
if "SPACES_ZERO_GPU" in os.environ.keys():
|
| 23 |
import spaces
|
|
|
|
| 145 |
return img_str
|
| 146 |
|
| 147 |
|
| 148 |
+
with gr.Blocks(js=SCRIPT) as demo:
|
| 149 |
gr.Markdown("# Qwen-VL Object-Detection")
|
| 150 |
gr.Markdown(
|
| 151 |
"Compare [Qwen3-VL](https://huggingface.co/collections/Qwen/qwen3-vl), [Qwen2.5-VL](https://huggingface.co/collections/Qwen/qwen25-vl) and [Qwen2-VL](https://huggingface.co/collections/Qwen/qwen2-vl) models by [Qwen](https://huggingface.co/Qwen) for object detection."
|
|
|
|
| 398 |
],
|
| 399 |
)
|
| 400 |
|
| 401 |
+
with gr.Row():
|
| 402 |
+
with gr.Column():
|
| 403 |
if DEVICE != "cuda":
|
| 404 |
gr.Markdown(
|
| 405 |
"👉 It's recommended to run this application on a machine with a CUDA-compatible GPU for optimal performance. You can clone this space locally or duplicate this space with a CUDA-enabled runtime."
|
| 406 |
)
|
| 407 |
+
gr.HTML('<div id="kofi" style="text-align: center;"></div>')
|
| 408 |
|
| 409 |
# Connect the button to the detection function
|
| 410 |
run_button.click(
|
|
|
|
| 426 |
|
| 427 |
if __name__ == "__main__":
|
| 428 |
demo.launch(
|
| 429 |
+
share=False,
|
| 430 |
)
|
kofi.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SCRIPT = """
|
| 2 |
+
async function loadKofi() {
|
| 3 |
+
var kofiwidget2 = kofiwidget2 ||
|
| 4 |
+
(function () {
|
| 5 |
+
var style = "";
|
| 6 |
+
var html = "";
|
| 7 |
+
var color = "";
|
| 8 |
+
var text = "";
|
| 9 |
+
var id = "";
|
| 10 |
+
return {
|
| 11 |
+
init: function (pText, pColor, pId) {
|
| 12 |
+
color = pColor;
|
| 13 |
+
text = pText;
|
| 14 |
+
id = pId;
|
| 15 |
+
style =
|
| 16 |
+
"img.kofiimg{display: initial!important;vertical-align:middle;height:13px!important;width:20px!important;padding-top:0!important;padding-bottom:0!important;border:none;margin-top:0;margin-right:7px!important;margin-left:0!important;margin-bottom:3px!important;content:url('https://storage.ko-fi.com/cdn/cup-border.png')}.kofiimg:after{vertical-align:middle;height:25px;padding-top:0;padding-bottom:0;border:none;margin-top:0;margin-right:6px;margin-left:0;margin-bottom:4px!important;content:url('https://storage.ko-fi.com/cdn/whitelogo.svg')}.btn-container{display:inline-block!important;white-space:nowrap;min-width:160px}span.kofitext{color:#fff !important;letter-spacing: -0.15px!important;text-wrap:none;vertical-align:middle;line-height:30px !important;padding:0;text-align:center;text-decoration:none!important; text-shadow: 0 1px 1px rgba(34, 34, 34, 0.05);}.kofitext a{color:#fff !important;text-decoration:none:important;}.kofitext a:hover{color:#fff !important;text-decoration:none}a.kofi-button{box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);line-height:27px!important;min-width:150px;display:inline-block!important;background-color:#29abe0;padding:2px 12px !important;text-align:center !important;border-radius:7px;color:#fff;cursor:pointer;overflow-wrap:break-word;vertical-align:middle;border:0 none #fff !important;font-family:'Quicksand',Helvetica,Century Gothic,sans-serif !important;text-decoration:none;text-shadow:none;font-weight:700!important;font-size:14px !important}a.kofi-button:visited{color:#fff !important;text-decoration:none !important}a.kofi-button:hover{opacity:.85;color:#f5f5f5 !important;text-decoration:none !important}a.kofi-button:active{color:#f5f5f5 !important;text-decoration:none !important}.kofitext img.kofiimg {height:15px!important;width:22px!important;display: initial;animation: kofi-wiggle 3s infinite;}";
|
| 17 |
+
style = style + "@keyframes kofi-wiggle{0%{transform:rotate(0) scale(1)}60%{transform:rotate(0) scale(1)}75%{transform:rotate(0) scale(1.12)}80%{transform:rotate(0) scale(1.1)}84%{transform:rotate(-10deg) scale(1.1)}88%{transform:rotate(10deg) scale(1.1)}92%{transform:rotate(-10deg) scale(1.1)}96%{transform:rotate(10deg) scale(1.1)}100%{transform:rotate(0) scale(1)}}";
|
| 18 |
+
style = "<style>" + style + "</style>";
|
| 19 |
+
html =
|
| 20 |
+
"<link href='https://fonts.googleapis.com/css?family=Quicksand:400,700' rel='stylesheet' type='text/css'>";
|
| 21 |
+
html +=
|
| 22 |
+
'<div class=btn-container><a title="Support me on ko-fi.com" class="kofi-button" style="background-color:[color]; text-decoration: none;" href="https://ko-fi.com/[id]" target="_blank"> <span class="kofitext"><img src="https://storage.ko-fi.com/cdn/cup-border.png" alt="Ko-fi donations" class="kofiimg"/>[text]</span></a></div>';
|
| 23 |
+
},
|
| 24 |
+
getHTML: function () {
|
| 25 |
+
var rtn = style + html.replace("[color]", color).replace("[text]", text).replace("[id]", id);
|
| 26 |
+
return rtn;
|
| 27 |
+
},
|
| 28 |
+
draw: function () {
|
| 29 |
+
document.writeln(style + html.replace("[color]", color).replace("[text]", text).replace("[id]", id));
|
| 30 |
+
}
|
| 31 |
+
};
|
| 32 |
+
}());
|
| 33 |
+
const checkElement = setInterval(() => {
|
| 34 |
+
const kofiDiv = document.getElementById('kofi');
|
| 35 |
+
if (kofiDiv) {
|
| 36 |
+
clearInterval(checkElement);
|
| 37 |
+
kofiwidget2.init('Buy me a coffee', '#f87316', 'Y8Y0STZND');
|
| 38 |
+
kofiDiv.innerHTML = kofiwidget2.getHTML();
|
| 39 |
+
}
|
| 40 |
+
}, 100);
|
| 41 |
+
}
|
| 42 |
+
"""
|