Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
02a9af1
1
Parent(s):
054782c
Update app.py
Browse files
app.py
CHANGED
|
@@ -441,17 +441,21 @@ def run_captioning(*inputs):
|
|
| 441 |
yield final_captions
|
| 442 |
|
| 443 |
def check_token(token):
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
gr.Warning("
|
| 448 |
else:
|
| 449 |
-
|
| 450 |
-
|
|
|
|
| 451 |
else:
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
with gr.Blocks() as demo:
|
| 457 |
dataset_folder = gr.State()
|
|
|
|
| 441 |
yield final_captions
|
| 442 |
|
| 443 |
def check_token(token):
|
| 444 |
+
try:
|
| 445 |
+
api = HfApi(token=token)
|
| 446 |
+
except Exception as e:
|
| 447 |
+
gr.Warning("Invalid user token. Make sure to get your Hugging Face")
|
| 448 |
else:
|
| 449 |
+
user_data = api.whoami()
|
| 450 |
+
if (username['auth']['accessToken']['role'] != "write"):
|
| 451 |
+
gr.Warning("Oops, you've uploaded a `Read` token. You need to use a Write token!")
|
| 452 |
else:
|
| 453 |
+
if user_data['canPay']:
|
| 454 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 455 |
+
else:
|
| 456 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 457 |
+
|
| 458 |
+
return gr.update(visible=False), gr.update(visible=False)
|
| 459 |
|
| 460 |
with gr.Blocks() as demo:
|
| 461 |
dataset_folder = gr.State()
|