Spaces:
Running
Running
improves interface.py
Browse files- interface.py +51 -12
interface.py
CHANGED
@@ -26,6 +26,7 @@ import json
|
|
26 |
import shlex
|
27 |
import traceback
|
28 |
import importlib.util
|
|
|
29 |
from dataclasses import dataclass
|
30 |
from datetime import datetime
|
31 |
from pathlib import Path
|
@@ -138,6 +139,14 @@ def duplicate_space_hint() -> str:
|
|
138 |
)
|
139 |
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
def _write_generated_config(filename: str, content: str) -> Path:
|
142 |
"""Write a generated config under config/ and return the full path."""
|
143 |
cfg_dir = PROJECT_ROOT / "config"
|
@@ -814,6 +823,12 @@ def ui_defaults(family: str) -> Tuple[str, str, str, str]:
|
|
814 |
return exp, repo_short, default_desc, trackio_space_name
|
815 |
|
816 |
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
def on_family_change(family: str) -> Tuple[list[str], str, str, str, str]:
|
818 |
confs = list(get_config_map(family).keys())
|
819 |
exp, repo_short, desc, space = ui_defaults(family)
|
@@ -879,19 +894,43 @@ with gr.Blocks(title="SmolLM3 / GPT-OSS Fine-tuning Pipeline") as demo:
|
|
879 |
# GPU/driver detection banner
|
880 |
has_gpu, gpu_msg = detect_nvidia_driver()
|
881 |
if has_gpu:
|
882 |
-
gr.
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
else:
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
895 |
|
896 |
with gr.Row():
|
897 |
model_family = gr.Dropdown(choices=MODEL_FAMILIES, value="SmolLM3", label="Model family")
|
|
|
26 |
import shlex
|
27 |
import traceback
|
28 |
import importlib.util
|
29 |
+
import re
|
30 |
from dataclasses import dataclass
|
31 |
from datetime import datetime
|
32 |
from pathlib import Path
|
|
|
139 |
)
|
140 |
|
141 |
|
142 |
+
def markdown_links_to_html(text: str) -> str:
|
143 |
+
"""Convert simple Markdown links [text](url) to HTML anchors for UI rendering."""
|
144 |
+
try:
|
145 |
+
return re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r'<a href="\2" target="_blank" rel="noopener noreferrer">\1</a>', text)
|
146 |
+
except Exception:
|
147 |
+
return text
|
148 |
+
|
149 |
+
|
150 |
def _write_generated_config(filename: str, content: str) -> Path:
|
151 |
"""Write a generated config under config/ and return the full path."""
|
152 |
cfg_dir = PROJECT_ROOT / "config"
|
|
|
823 |
return exp, repo_short, default_desc, trackio_space_name
|
824 |
|
825 |
|
826 |
+
joinus = """
|
827 |
+
## Join us :
|
828 |
+
🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/qdfnvSPcqP) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Build Tonic](https://git.tonic-ai.com/contribute)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
829 |
+
"""
|
830 |
+
|
831 |
+
|
832 |
def on_family_change(family: str) -> Tuple[list[str], str, str, str, str]:
|
833 |
confs = list(get_config_map(family).keys())
|
834 |
exp, repo_short, desc, space = ui_defaults(family)
|
|
|
894 |
# GPU/driver detection banner
|
895 |
has_gpu, gpu_msg = detect_nvidia_driver()
|
896 |
if has_gpu:
|
897 |
+
gr.HTML(
|
898 |
+
f"""
|
899 |
+
<div style="background-color: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 8px; padding: 12px; margin-bottom: 16px; text-align: center;">
|
900 |
+
<p style="color: rgb(59, 130, 246); margin: 0; font-size: 14px; font-weight: 600;">
|
901 |
+
✅ NVIDIA GPU ready — {gpu_msg}
|
902 |
+
</p>
|
903 |
+
<p style="color: rgb(59, 130, 246); margin: 6px 0 0; font-size: 12px;">
|
904 |
+
Reads tokens from environment: <code>HF_WRITE_TOKEN</code> (required), <code>HF_READ_TOKEN</code> (optional)
|
905 |
+
</p>
|
906 |
+
<p style="color: rgb(59, 130, 246); margin: 4px 0 0; font-size: 12px;">
|
907 |
+
Select a config and run training; optionally deploy Trackio and push to Hub
|
908 |
+
</p>
|
909 |
+
</div>
|
910 |
+
"""
|
911 |
+
)
|
912 |
+
gr.Markdown(joinus)
|
913 |
else:
|
914 |
+
hint_html = markdown_links_to_html(duplicate_space_hint())
|
915 |
+
gr.HTML(
|
916 |
+
f"""
|
917 |
+
<div style="background-color: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); border-radius: 8px; padding: 12px; margin-bottom: 16px; text-align: center;">
|
918 |
+
<p style="color: rgb(234, 88, 12); margin: 0; font-size: 14px; font-weight: 600;">
|
919 |
+
⚠️ No NVIDIA GPU/driver detected — training requires a GPU runtime
|
920 |
+
</p>
|
921 |
+
<p style="color: rgb(234, 88, 12); margin: 6px 0 0; font-size: 12px;">
|
922 |
+
{hint_html}
|
923 |
+
</p>
|
924 |
+
<p style="color: rgb(234, 88, 12); margin: 4px 0 0; font-size: 12px;">
|
925 |
+
Reads tokens from environment: <code>HF_WRITE_TOKEN</code> (required), <code>HF_READ_TOKEN</code> (optional)
|
926 |
+
</p>
|
927 |
+
<p style="color: rgb(234, 88, 12); margin: 4px 0 0; font-size: 12px;">
|
928 |
+
You can still configure and push, but training requires a GPU runtime.
|
929 |
+
</p>
|
930 |
+
</div>
|
931 |
+
"""
|
932 |
+
)
|
933 |
+
gr.Markdown(joinus)
|
934 |
|
935 |
with gr.Row():
|
936 |
model_family = gr.Dropdown(choices=MODEL_FAMILIES, value="SmolLM3", label="Model family")
|