Omnibus commited on
Commit
e9a5f22
·
verified ·
1 Parent(s): 5e9b025

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -2,12 +2,14 @@ import gradio as gr
2
  import json
3
  from huggingface_hub import HfApi, ModelFilter, list_models
4
  api = HfApi()
5
- def model_explorer(limit=100,task='text-generation'):
6
  # List all models
 
 
7
  out_box=[]
8
  filt = ModelFilter(task="text-generation")
9
 
10
- this = api.list_models(limit=limit,filter=filt,cardData=True)
11
 
12
  for i,mod in enumerate(this):
13
  out_box.append(mod)
@@ -80,8 +82,10 @@ def fix_json():
80
  if line.strip():
81
  print (line)
82
  with gr.Blocks() as app:
83
- limit=gr.Slider(minimum=1,maximum=100,value=100)
 
 
84
  btn=gr.Button()
85
  models_json=gr.JSON()
86
- btn.click(model_explorer,[limit],models_json)
87
  app.launch()
 
2
  import json
3
  from huggingface_hub import HfApi, ModelFilter, list_models
4
  api = HfApi()
5
+ def model_explorer(search, limit=100,task='text-generation'):
6
  # List all models
7
+ if not search:
8
+ search=None
9
  out_box=[]
10
  filt = ModelFilter(task="text-generation")
11
 
12
+ this = api.list_models(search=search,limit=limit,filter=filt,cardData=True)
13
 
14
  for i,mod in enumerate(this):
15
  out_box.append(mod)
 
82
  if line.strip():
83
  print (line)
84
  with gr.Blocks() as app:
85
+ with gr.Row():
86
+ search=gr.Textbox()
87
+ limit=gr.Slider(minimum=1,maximum=100,value=100)
88
  btn=gr.Button()
89
  models_json=gr.JSON()
90
+ btn.click(model_explorer,[search,limit],models_json)
91
  app.launch()