Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ lock = RLock()
|
|
11 |
HF_TOKEN = os.environ.get("HF_TOKEN") if os.environ.get("HF_TOKEN") else None # If private or gated models aren't used, ENV setting is unnecessary.
|
12 |
# --- Step 2: Authenticate and fetch your models
|
13 |
|
14 |
-
|
15 |
api = HfApi()
|
16 |
user_info = whoami(token=HF_TOKEN)
|
17 |
username = user_info["name"]
|
@@ -26,23 +26,9 @@ def random_choices():
|
|
26 |
import random
|
27 |
random.seed()
|
28 |
return random.choices(models, k=num_models)
|
29 |
-
mymodels = list(api.list_models(author=username, token=HF_TOKEN))
|
30 |
-
model_ids = [m.modelId for m in mymodels]
|
31 |
-
if not model_ids:
|
32 |
-
raise ValueError(f"No models found for user '{username}'")
|
33 |
-
# --- Step 3: Build Gradio UI
|
34 |
-
def handle_model_selection(selected_models):
|
35 |
-
if not selected_models:
|
36 |
-
return "No models selected."
|
37 |
-
return "✅ Selected models:\n" + "\n".join(selected_models)
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
load_fn(default_models,HF_TOKEN)
|
46 |
|
47 |
|
48 |
'''
|
@@ -52,11 +38,6 @@ load_fn(default_models,HF_TOKEN)
|
|
52 |
|
53 |
|
54 |
with gr.Blocks(fill_width=True) as demo:
|
55 |
-
with gr.Row():
|
56 |
-
gr.Markdown(f"# ({username}) you are logged in")
|
57 |
-
model_selector = gr.CheckboxGroup(choices=model_ids,value=model_ids, label="your models", interactive=True, )
|
58 |
-
output_box = gr.Textbox(lines=10, label="Selected Models")
|
59 |
-
model_selector.change(fn=handle_model_selection, inputs=model_selector, outputs=output_box)
|
60 |
with gr.Tab(str(num_models) + ' Models'):
|
61 |
with gr.Column(scale=2):
|
62 |
with gr.Group():
|
@@ -92,7 +73,7 @@ with gr.Blocks(fill_width=True) as demo:
|
|
92 |
|
93 |
with gr.Column(scale=4):
|
94 |
with gr.Accordion('Model selection'):
|
95 |
-
model_choice = gr.CheckboxGroup(
|
96 |
model_choice.change(update_imgbox, model_choice, output)
|
97 |
model_choice.change(extend_choices, model_choice, current_models)
|
98 |
random_button.click(random_choices, None, model_choice)
|
|
|
11 |
HF_TOKEN = os.environ.get("HF_TOKEN") if os.environ.get("HF_TOKEN") else None # If private or gated models aren't used, ENV setting is unnecessary.
|
12 |
# --- Step 2: Authenticate and fetch your models
|
13 |
|
14 |
+
|
15 |
api = HfApi()
|
16 |
user_info = whoami(token=HF_TOKEN)
|
17 |
username = user_info["name"]
|
|
|
26 |
import random
|
27 |
random.seed()
|
28 |
return random.choices(models, k=num_models)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
+
load_fn(models,HF_TOKEN)
|
|
|
|
|
32 |
|
33 |
|
34 |
'''
|
|
|
38 |
|
39 |
|
40 |
with gr.Blocks(fill_width=True) as demo:
|
|
|
|
|
|
|
|
|
|
|
41 |
with gr.Tab(str(num_models) + ' Models'):
|
42 |
with gr.Column(scale=2):
|
43 |
with gr.Group():
|
|
|
73 |
|
74 |
with gr.Column(scale=4):
|
75 |
with gr.Accordion('Model selection'):
|
76 |
+
model_choice = gr.CheckboxGroup(models, label = f'Choose up to {int(num_models)} different models from the {len(models)} available!', value=models, interactive=True)
|
77 |
model_choice.change(update_imgbox, model_choice, output)
|
78 |
model_choice.change(extend_choices, model_choice, current_models)
|
79 |
random_button.click(random_choices, None, model_choice)
|