Spaces:
Running
Running
badaoui
commited on
Commit
·
538326f
1
Parent(s):
bb3788c
fixing ui
Browse files
app.py
CHANGED
@@ -88,31 +88,30 @@ def neuron_export(model_id: str, task: str, oauth_token: gr.OAuthToken) -> str:
|
|
88 |
try:
|
89 |
api = HfApi(token=oauth_token.token)
|
90 |
|
91 |
-
error,
|
92 |
if error != "0":
|
93 |
return error
|
94 |
|
95 |
-
print("[
|
96 |
|
97 |
# Save in a private dataset if repo initialized
|
98 |
if repo is not None:
|
99 |
repo.git_pull(rebase=True)
|
100 |
with open(os.path.join(DATADIR, DATA_FILE), "a") as csvfile:
|
101 |
writer = csv.DictWriter(
|
102 |
-
csvfile, fieldnames=["model_id", "
|
103 |
)
|
104 |
writer.writerow(
|
105 |
{
|
106 |
"model_id": model_id,
|
107 |
-
"
|
108 |
"time": str(datetime.now()),
|
109 |
}
|
110 |
)
|
111 |
commit_url = repo.push_to_hub()
|
112 |
print("[dataset]", commit_url)
|
113 |
|
114 |
-
|
115 |
-
return f"#### Success 🔥 Yay! This model was successfully exported and a PR was opened using your token: [{commit_info.pr_url}]({commit_info.pr_url}). If you would like to use the exported model without waiting for the PR to be approved, head to https://huggingface.co/{model_id}/tree/{pr_revision}"
|
116 |
|
117 |
except Exception as e:
|
118 |
return f"#### Error: {e}"
|
@@ -209,12 +208,88 @@ CUSTOM_CSS = """
|
|
209 |
display: inline-block;
|
210 |
margin: 2px;
|
211 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
"""
|
213 |
|
214 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
215 |
# Login requirement notice and button
|
216 |
gr.Markdown("**You must be logged in to use this space**")
|
217 |
-
gr.LoginButton(min_width=250)
|
218 |
|
219 |
# Centered title and image
|
220 |
gr.HTML(TITLE_IMAGE)
|
@@ -239,7 +314,7 @@ with gr.Blocks(css=CUSTOM_CSS) as demo:
|
|
239 |
)
|
240 |
|
241 |
# Export button below the inputs
|
242 |
-
btn = gr.Button("Export to Neuron", size="lg")
|
243 |
|
244 |
# Output section
|
245 |
output = gr.Markdown(label="Output")
|
|
|
88 |
try:
|
89 |
api = HfApi(token=oauth_token.token)
|
90 |
|
91 |
+
error, result_info = convert(api=api, model_id=model_id, task=task, token=oauth_token.token)
|
92 |
if error != "0":
|
93 |
return error
|
94 |
|
95 |
+
print("[result_info]", result_info)
|
96 |
|
97 |
# Save in a private dataset if repo initialized
|
98 |
if repo is not None:
|
99 |
repo.git_pull(rebase=True)
|
100 |
with open(os.path.join(DATADIR, DATA_FILE), "a") as csvfile:
|
101 |
writer = csv.DictWriter(
|
102 |
+
csvfile, fieldnames=["model_id", "cache_info", "time"]
|
103 |
)
|
104 |
writer.writerow(
|
105 |
{
|
106 |
"model_id": model_id,
|
107 |
+
"cache_info": str(result_info),
|
108 |
"time": str(datetime.now()),
|
109 |
}
|
110 |
)
|
111 |
commit_url = repo.push_to_hub()
|
112 |
print("[dataset]", commit_url)
|
113 |
|
114 |
+
return f"#### Success 🔥 Yay! This model was successfully compiled and cached! The compilation artifacts have been synchronized to the optimum-neuron cache repository. You can now use this model with optimum-neuron and benefit from faster loading times. Model: {model_id}, Task: {task}"
|
|
|
115 |
|
116 |
except Exception as e:
|
117 |
return f"#### Error: {e}"
|
|
|
208 |
display: inline-block;
|
209 |
margin: 2px;
|
210 |
}
|
211 |
+
|
212 |
+
/* Primary button styling with warm colors */
|
213 |
+
button[variant="primary"] {
|
214 |
+
background: linear-gradient(135deg, #3B82F6, #10B981) !important;
|
215 |
+
color: white !important;
|
216 |
+
padding: 16px 32px !important;
|
217 |
+
font-size: 1.1rem !important;
|
218 |
+
font-weight: 700 !important;
|
219 |
+
border: none !important;
|
220 |
+
border-radius: 12px !important;
|
221 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5) !important;
|
222 |
+
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
|
223 |
+
position: relative;
|
224 |
+
overflow: hidden;
|
225 |
+
animation: glow 1.5s ease-in-out infinite alternate;
|
226 |
+
}
|
227 |
+
button[variant="primary"]::before {
|
228 |
+
content: "✨ ";
|
229 |
+
}
|
230 |
+
button[variant="primary"]:hover {
|
231 |
+
transform: translateY(-5px) scale(1.05) !important;
|
232 |
+
box-shadow: 0 10px 25px rgba(59, 130, 246, 0.7) !important;
|
233 |
+
}
|
234 |
+
@keyframes glow {
|
235 |
+
from {
|
236 |
+
box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
|
237 |
+
}
|
238 |
+
to {
|
239 |
+
box-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 30px rgba(16, 185, 129, 0.5);
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/* Login button styling with glow effect using warm colors */
|
245 |
+
#login-button {
|
246 |
+
background: linear-gradient(135deg, #FF7A00, #FFD700) !important; /* Orange to Gold */
|
247 |
+
color: white !important;
|
248 |
+
font-weight: 700 !important;
|
249 |
+
border: none !important;
|
250 |
+
border-radius: 12px !important;
|
251 |
+
box-shadow: 0 0 15px rgba(255, 165, 0, 0.5) !important; /* Warm glow */
|
252 |
+
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
|
253 |
+
position: relative;
|
254 |
+
overflow: hidden;
|
255 |
+
animation: glow 1.5s ease-in-out infinite alternate;
|
256 |
+
max-width: 300px !important;
|
257 |
+
margin: 0 auto !important;
|
258 |
+
}
|
259 |
+
|
260 |
+
#login-button::before {
|
261 |
+
content: "🔑 ";
|
262 |
+
display: inline-block !important;
|
263 |
+
vertical-align: middle !important;
|
264 |
+
margin-right: 5px !important;
|
265 |
+
line-height: normal !important;
|
266 |
+
}
|
267 |
+
|
268 |
+
#login-button:hover {
|
269 |
+
transform: translateY(-3px) scale(1.03) !important;
|
270 |
+
box-shadow: 0 10px 25px rgba(255, 140, 0, 0.7) !important; /* Deeper warm glow */
|
271 |
+
}
|
272 |
+
|
273 |
+
#login-button::after {
|
274 |
+
content: "";
|
275 |
+
position: absolute;
|
276 |
+
top: 0;
|
277 |
+
left: -100%;
|
278 |
+
width: 100%;
|
279 |
+
height: 100%;
|
280 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
281 |
+
transition: 0.5s;
|
282 |
+
}
|
283 |
+
|
284 |
+
#login-button:hover::after {
|
285 |
+
left: 100%;
|
286 |
+
}
|
287 |
"""
|
288 |
|
289 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
290 |
# Login requirement notice and button
|
291 |
gr.Markdown("**You must be logged in to use this space**")
|
292 |
+
gr.LoginButton(elem_id="login-button", elem_classes="center-button", min_width=250)
|
293 |
|
294 |
# Centered title and image
|
295 |
gr.HTML(TITLE_IMAGE)
|
|
|
314 |
)
|
315 |
|
316 |
# Export button below the inputs
|
317 |
+
btn = gr.Button("Export to Neuron", size="lg", variant="primary")
|
318 |
|
319 |
# Output section
|
320 |
output = gr.Markdown(label="Output")
|