Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,56 +24,32 @@ def predict_sentiment(text):
|
|
24 |
return 'Positive'
|
25 |
|
26 |
def predict(sample, validate=True):
|
27 |
-
classifier = pipeline("text-classification", model=model_2, tokenizer=tokenizer_2)
|
28 |
pred = classifier(sample)[0]['label']
|
29 |
return pred
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
#
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
iface_2 = gradio.Interface(fn=predict,
|
58 |
-
inputs = [in_prompt_2],
|
59 |
-
outputs = [out_response_2],
|
60 |
-
title=title_2,
|
61 |
-
description=description_2
|
62 |
-
)
|
63 |
-
|
64 |
-
def combined_interface(input1, input2):
|
65 |
-
# Call individual model interfaces and combine results
|
66 |
-
model1_output = iface_1(input1)
|
67 |
-
model2_output = iface_2(input2)
|
68 |
-
|
69 |
-
combined_output = {
|
70 |
-
"model1_output": model1_output,
|
71 |
-
"model2_output": model2_output
|
72 |
-
}
|
73 |
-
|
74 |
-
return combined_output
|
75 |
-
|
76 |
-
parent_interface = gradio.Interface(fn=combined_interface, inputs=["text","text"], outputs=["model1_output", "model2_output"])
|
77 |
-
|
78 |
-
parent_interface.launch(debug = True)
|
79 |
-
#iface.launch(debug = True)#, server_name = "0.0.0.0", server_port = 8001) # Ref. for parameters: https://www.gradio.app/docs/interface
|
|
|
24 |
return 'Positive'
|
25 |
|
26 |
def predict(sample, validate=True):
|
|
|
27 |
pred = classifier(sample)[0]['label']
|
28 |
return pred
|
29 |
|
30 |
+
def make_block(dem):
|
31 |
+
with dem:
|
32 |
+
gr.Markdown("""
|
33 |
+
# Ejemplo de `space` multiclassifier: Curso Platzi""")
|
34 |
+
with gr.Tabs():
|
35 |
+
with gr.TabItem("Transcribe audio en español"):
|
36 |
+
with gr.Row():
|
37 |
+
in_prompt_1 = gradio.components.Textbox(lines=10, placeholder=None, label='Enter review text')
|
38 |
+
out_response_1 = gradio.components.Textbox(type="text", label='Sentiment')
|
39 |
+
b1 = gr.Button("Voz a Texto")
|
40 |
+
|
41 |
+
with gr.TabItem("Análisis de sentimiento en español"):
|
42 |
+
with gr.Row():
|
43 |
+
in_prompt_2 = gradio.components.Textbox(lines=2, label='Enter the Symptoms')
|
44 |
+
out_response_2 = gradio.components.Textbox(label='Disease')
|
45 |
+
b2 = gr.Button("Texto a Sentimiento")
|
46 |
+
b1.click(predict_sentiment, inputs=in_prompt_1, outputs=out_response_1)
|
47 |
+
b2.click(predict, inputs=in_prompt_2, outputs=out_response_2)
|
48 |
+
|
49 |
+
if __name__ == '__main__':
|
50 |
+
model_1 = pipeline(model= repo_path)
|
51 |
+
classifier = pipeline("text-classification", model=model_2, tokenizer=tokenizer_2)
|
52 |
+
|
53 |
+
demo = gr.Blocks()
|
54 |
+
make_block(demo)
|
55 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|