Spaces:
Sleeping
Sleeping
emielclopterop
commited on
Commit
•
25f8ce5
1
Parent(s):
59394f8
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def classify_text(text, labels):
|
|
25 |
return {label: float(f"{prob:.4f}") for label, prob in zip(results["labels"], results["scores"])}
|
26 |
|
27 |
def translate_text(text):
|
28 |
-
return translation_pipeline(text)[0]['translation_text'] if text else "No translation
|
29 |
|
30 |
def classify_topic(text):
|
31 |
results = topic_classification_pipeline(text)
|
@@ -50,14 +50,14 @@ def multi_model_interaction(text):
|
|
50 |
with gr.Blocks() as demo:
|
51 |
with gr.Tab("Single Models"):
|
52 |
with gr.Column():
|
53 |
-
gr.Markdown("### Question
|
54 |
context = gr.Textbox(label="Context")
|
55 |
question = gr.Textbox(label="Question")
|
56 |
answer_output = gr.Text(label="Answer")
|
57 |
gr.Button("Answer").click(answer_question, inputs=[context, question], outputs=answer_output)
|
58 |
|
59 |
with gr.Column():
|
60 |
-
gr.Markdown("### Zero-Shot
|
61 |
text_zsc = gr.Textbox(label="Text")
|
62 |
labels = gr.Textbox(label="Labels (comma separated)")
|
63 |
classification_result = gr.JSON(label="Classification Results")
|
@@ -69,18 +69,18 @@ with gr.Blocks() as demo:
|
|
69 |
translated_text = gr.Text(label="Translated Text")
|
70 |
gr.Button("Translate").click(translate_text, inputs=[text_to_translate], outputs=translated_text)
|
71 |
|
72 |
-
with gr.Column():
|
73 |
-
gr.Markdown("### Sentiment Analysis")
|
74 |
-
text_for_sentiment = gr.Textbox(label="Text for Sentiment Analysis")
|
75 |
-
sentiment_result = gr.Text(label="Sentiment")
|
76 |
-
gr.Button("Classify Sentiment").click(classify_topic, inputs=[text_for_sentiment], outputs=sentiment_result)
|
77 |
-
|
78 |
with gr.Column():
|
79 |
gr.Markdown("### Summarization")
|
80 |
text_to_summarize = gr.Textbox(label="Text")
|
81 |
summary = gr.Text(label="Summary")
|
82 |
gr.Button("Summarize").click(summarize_text, inputs=[text_to_summarize], outputs=summary)
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
with gr.Tab("Multi-Model"):
|
85 |
gr.Markdown("### Multi-Model")
|
86 |
input_text = gr.Textbox(label="Enter Text for Multi-Model Analysis")
|
|
|
25 |
return {label: float(f"{prob:.4f}") for label, prob in zip(results["labels"], results["scores"])}
|
26 |
|
27 |
def translate_text(text):
|
28 |
+
return translation_pipeline(text)[0]['translation_text'] if text else "No translation"
|
29 |
|
30 |
def classify_topic(text):
|
31 |
results = topic_classification_pipeline(text)
|
|
|
50 |
with gr.Blocks() as demo:
|
51 |
with gr.Tab("Single Models"):
|
52 |
with gr.Column():
|
53 |
+
gr.Markdown("### Question")
|
54 |
context = gr.Textbox(label="Context")
|
55 |
question = gr.Textbox(label="Question")
|
56 |
answer_output = gr.Text(label="Answer")
|
57 |
gr.Button("Answer").click(answer_question, inputs=[context, question], outputs=answer_output)
|
58 |
|
59 |
with gr.Column():
|
60 |
+
gr.Markdown("### Zero-Shot")
|
61 |
text_zsc = gr.Textbox(label="Text")
|
62 |
labels = gr.Textbox(label="Labels (comma separated)")
|
63 |
classification_result = gr.JSON(label="Classification Results")
|
|
|
69 |
translated_text = gr.Text(label="Translated Text")
|
70 |
gr.Button("Translate").click(translate_text, inputs=[text_to_translate], outputs=translated_text)
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
with gr.Column():
|
73 |
gr.Markdown("### Summarization")
|
74 |
text_to_summarize = gr.Textbox(label="Text")
|
75 |
summary = gr.Text(label="Summary")
|
76 |
gr.Button("Summarize").click(summarize_text, inputs=[text_to_summarize], outputs=summary)
|
77 |
|
78 |
+
with gr.Column():
|
79 |
+
gr.Markdown("### Sentiment Analysis")
|
80 |
+
text_for_sentiment = gr.Textbox(label="Text for Sentiment Analysis")
|
81 |
+
sentiment_result = gr.Text(label="Sentiment")
|
82 |
+
gr.Button("Classify Sentiment").click(classify_topic, inputs=[text_for_sentiment], outputs=sentiment_result)
|
83 |
+
|
84 |
with gr.Tab("Multi-Model"):
|
85 |
gr.Markdown("### Multi-Model")
|
86 |
input_text = gr.Textbox(label="Enter Text for Multi-Model Analysis")
|