Spaces:
Sleeping
Sleeping
oauth
Browse files
README.md
CHANGED
@@ -4,9 +4,13 @@ emoji: π
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.27.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
hf_oauth: true
|
11 |
+
hf_oauth_scopes:
|
12 |
+
- read-repos
|
13 |
+
- write-repos
|
14 |
---
|
15 |
|
16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -45,7 +45,9 @@ you've downloaded from your Kaggle user account.
|
|
45 |
"""
|
46 |
|
47 |
|
48 |
-
def import_model(
|
|
|
|
|
49 |
runner = LogsViewRunner()
|
50 |
|
51 |
if not kaggle_model:
|
@@ -54,10 +56,9 @@ def import_model(kaggle_model: str, repo_name: str, token: str) -> Iterable[List
|
|
54 |
if not repo_name:
|
55 |
repo_name = kaggle_model.split("/")[-1]
|
56 |
if not token:
|
57 |
-
yield runner.log("
|
58 |
-
raise gr.Error("
|
59 |
-
api = HfApi(token=token)
|
60 |
-
|
61 |
|
62 |
yield runner.log(f"Creating HF repo {repo_name}")
|
63 |
repo_url = api.create_repo(repo_name, exist_ok=True)
|
@@ -102,32 +103,22 @@ with gr.Blocks() as demo:
|
|
102 |
gr.Markdown(MARKDOWN_DESCRIPTION)
|
103 |
|
104 |
with gr.Row():
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
with gr.Column():
|
117 |
-
token = gr.Textbox(
|
118 |
-
lines=1,
|
119 |
-
label="HF Write Token*",
|
120 |
-
info="https://hf.co/settings/token",
|
121 |
-
type="password",
|
122 |
-
placeholder="hf_***",
|
123 |
-
)
|
124 |
|
125 |
button = gr.Button("Import", variant="primary")
|
126 |
logs = LogsView(label="Terminal output")
|
127 |
|
128 |
-
button.click(
|
129 |
-
fn=import_model, inputs=[kaggle_model, repo_name, token], outputs=[logs]
|
130 |
-
)
|
131 |
|
132 |
|
133 |
demo.queue(default_concurrency_limit=1).launch()
|
|
|
45 |
"""
|
46 |
|
47 |
|
48 |
+
def import_model(
|
49 |
+
kaggle_model: str, repo_name: str, token: gr.OAuthToken | None
|
50 |
+
) -> Iterable[List[Log]]:
|
51 |
runner = LogsViewRunner()
|
52 |
|
53 |
if not kaggle_model:
|
|
|
56 |
if not repo_name:
|
57 |
repo_name = kaggle_model.split("/")[-1]
|
58 |
if not token:
|
59 |
+
yield runner.log("You must sign in with HF before proceeding.", level="ERROR")
|
60 |
+
raise gr.Error("Authentication is required.")
|
61 |
+
api = HfApi(token=token.token)
|
|
|
62 |
|
63 |
yield runner.log(f"Creating HF repo {repo_name}")
|
64 |
repo_url = api.create_repo(repo_name, exist_ok=True)
|
|
|
103 |
gr.Markdown(MARKDOWN_DESCRIPTION)
|
104 |
|
105 |
with gr.Row():
|
106 |
+
kaggle_model = gr.Textbox(
|
107 |
+
lines=1,
|
108 |
+
label="Kaggle Model*",
|
109 |
+
placeholder="keras/codegemma/keras/code_gemma_7b_en",
|
110 |
+
)
|
111 |
+
repo_name = gr.Textbox(
|
112 |
+
lines=1,
|
113 |
+
label="Repo name",
|
114 |
+
placeholder="Optional. Will infer from Kaggle Model if empty.",
|
115 |
+
)
|
116 |
+
gr.LoginButton()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
button = gr.Button("Import", variant="primary")
|
119 |
logs = LogsView(label="Terminal output")
|
120 |
|
121 |
+
button.click(fn=import_model, inputs=[kaggle_model, repo_name], outputs=[logs])
|
|
|
|
|
122 |
|
123 |
|
124 |
demo.queue(default_concurrency_limit=1).launch()
|