Spaces:
Runtime error
Runtime error
Quentin GALLOUÉDEC
commited on
Commit
·
8a4cbc9
1
Parent(s):
f593a46
up
Browse files
app.py
CHANGED
@@ -9,14 +9,14 @@ model_pipelines = {}
|
|
9 |
|
10 |
# Load a default model initially
|
11 |
default_model_name = "gia-project/gia2-small-untrained"
|
12 |
-
default_generator = pipeline("text-generation", model=default_model_name,
|
13 |
model_pipelines[default_model_name] = default_generator
|
14 |
|
15 |
def generate_text(model_name, input_text):
|
16 |
# Check if the selected model is already loaded
|
17 |
if model_name not in model_pipelines:
|
18 |
# Load the model and create a pipeline if it's not already loaded
|
19 |
-
generator = pipeline("text-generation", model=model_name,
|
20 |
model_pipelines[model_name] = generator
|
21 |
|
22 |
# Get the pipeline for the selected model and generate text
|
@@ -28,7 +28,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"), # 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
|
|
|
9 |
|
10 |
# Load a default model initially
|
11 |
default_model_name = "gia-project/gia2-small-untrained"
|
12 |
+
default_generator = pipeline("text-generation", model=default_model_name, trust_remote_code=True)
|
13 |
model_pipelines[default_model_name] = default_generator
|
14 |
|
15 |
def generate_text(model_name, input_text):
|
16 |
# Check if the selected model is already loaded
|
17 |
if model_name not in model_pipelines:
|
18 |
# Load the model and create a pipeline if it's not already loaded
|
19 |
+
generator = pipeline("text-generation", model=model_name, trust_remote_code=True)
|
20 |
model_pipelines[model_name] = generator
|
21 |
|
22 |
# Get the pipeline for the selected model and generate 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
|