Quentin GALLOUÉDEC commited on
Commit
51ead85
·
1 Parent(s): 8a4cbc9

all models

Browse files
Files changed (2) hide show
  1. app.py +7 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,8 +1,11 @@
1
  import gradio as gr
2
- from transformers import AutoModelForCausalLM, pipeline
 
3
 
4
- # Define the list of model names
5
- models = ["gia-project/gia2-small-untrained", "gpt2"] # Add more model names as needed
 
 
6
 
7
  # Dictionary to store loaded models and their pipelines
8
  model_pipelines = {}
@@ -28,7 +31,7 @@ def generate_text(model_name, input_text):
28
  iface = gr.Interface(
29
  fn=generate_text, # Function to be called on user input
30
  inputs=[
31
- gr.inputs.Dropdown(choices=models, label="Select Model", default=default_model_name), # Dropdown to select model
32
  gr.inputs.Textbox(lines=5, label="Input Text") # Textbox for entering text
33
  ],
34
  outputs=gr.outputs.Textbox(label="Generated Text"), # Textbox to display the generated text
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+ from huggingface_hub import HfApi, ModelFilter
4
 
5
+ # Get the list of models from the Hugging Face Hub
6
+ api = HfApi()
7
+ models = api.list_models(author="gia-project", filter=ModelFilter(tags="text-generation"))
8
+ models_names = [model.modelId for model in models]
9
 
10
  # Dictionary to store loaded models and their pipelines
11
  model_pipelines = {}
 
31
  iface = gr.Interface(
32
  fn=generate_text, # Function to be called on user input
33
  inputs=[
34
+ gr.inputs.Dropdown(choices=models_names, label="Select Model", default=default_model_name), # Dropdown to select model
35
  gr.inputs.Textbox(lines=5, label="Input Text") # Textbox for entering text
36
  ],
37
  outputs=gr.outputs.Textbox(label="Generated Text"), # Textbox to display the generated text
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  transformers
2
- torch
 
 
1
  transformers
2
+ torch
3
+ huggingface_hub