Spaces:
Sleeping
Sleeping
Commit
·
43bcb71
1
Parent(s):
e783551
init
Browse files
app.py
CHANGED
@@ -15,24 +15,37 @@ examples = [
|
|
15 |
]
|
16 |
|
17 |
# Load interfaces for different models
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def inference(inputtext, model):
|
22 |
-
if model == "SteelBERT":
|
23 |
-
|
|
|
|
|
24 |
else:
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
gr.
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
examples=examples,
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
15 |
]
|
16 |
|
17 |
# Load interfaces for different models
|
18 |
+
try:
|
19 |
+
io1 = gr.Interface.load("MGE-LLMs/SteelBERT")
|
20 |
+
except Exception as e:
|
21 |
+
print(f"Failed to load SteelBERT: {e}")
|
22 |
+
io1 = None
|
23 |
+
|
24 |
+
try:
|
25 |
+
io2 = gr.Interface.load("huggingface/bert-base-uncased")
|
26 |
+
except Exception as e:
|
27 |
+
print(f"Failed to load bert-base-uncased: {e}")
|
28 |
+
io2 = None
|
29 |
|
30 |
def inference(inputtext, model):
|
31 |
+
if model == "SteelBERT" and io1 is not None:
|
32 |
+
return io1(inputtext)
|
33 |
+
elif model == "bert-base-uncased" and io2 is not None:
|
34 |
+
return io2(inputtext)
|
35 |
else:
|
36 |
+
return "Model not available."
|
37 |
+
|
38 |
+
with gr.Blocks() as demo:
|
39 |
+
gr.Markdown(f"# {title}")
|
40 |
+
gr.Markdown(description)
|
41 |
+
|
42 |
+
context = gr.Textbox(label="Context", lines=10)
|
43 |
+
model = gr.Dropdown(choices=["SteelBERT", "bert-base-uncased"], value="SteelBERT", label="Model")
|
44 |
+
output = gr.Textbox(label="Output")
|
45 |
+
|
46 |
+
examples_component = gr.Examples(examples=examples, inputs=[context, model])
|
47 |
+
|
48 |
+
btn = gr.Button("Run")
|
49 |
+
btn.click(fn=inference, inputs=[context, model], outputs=output)
|
50 |
+
|
51 |
+
demo.launch(enable_queue=True)
|