mjwong commited on
Commit
a83cca7
·
verified ·
1 Parent(s): 0aa9235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -27
app.py CHANGED
@@ -47,35 +47,24 @@ footer {display:none !important}
47
  background: none rgb(66, 133, 244) !important;
48
  box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
49
  }
50
-
51
- /* Two-column layout for text and labels */
52
- .gr-blocks-container {
53
- display: flex;
54
- gap: 20px;
55
- }
56
- .gr-blocks-container .gr-block:first-child {
57
- flex: 1;
58
- }
59
- .gr-blocks-container .gr-block:last-child {
60
- flex: 1;
61
- }
62
  """
63
 
64
- iface = gr.Interface(
65
- fn=classify_text,
66
- inputs=[
67
- gr.Dropdown(AVAILABLE_MODELS, label="Choose Model"),
68
- gr.Row([
69
- gr.Textbox(label="Enter Text", placeholder="Type or paste text here..."),
70
- gr.Textbox(label="Enter Labels (comma-separated)", placeholder="e.g., sports, politics, technology")
71
- ])
72
- ],
73
- outputs=gr.Label(label="Classification Scores"),
74
- title="Zero-Shot Text Classifier",
75
- description="Select a model, enter text, and a set of labels to classify it using a zero-shot classification model.",
76
- examples=examples,
77
- css=css
78
- )
 
79
 
80
  # Launch the app
81
  if __name__ == "__main__":
 
47
  background: none rgb(66, 133, 244) !important;
48
  box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
50
  """
51
 
52
+ with gr.Blocks(css=css) as iface:
53
+ gr.Markdown("# Zero-Shot Text Classifier")
54
+ gr.Markdown("Select a model, enter text, and a set of labels to classify it using a zero-shot classification model.")
55
+
56
+ model_dropdown = gr.Dropdown(AVAILABLE_MODELS, label="Choose Model")
57
+
58
+ with gr.Row():
59
+ text_input = gr.Textbox(label="Enter Text", placeholder="Type or paste text here...")
60
+ label_input = gr.Textbox(label="Enter Labels (comma-separated)", placeholder="e.g., sports, politics, technology")
61
+
62
+ output_label = gr.Label(label="Classification Scores")
63
+
64
+ submit_button = gr.Button("Classify")
65
+ submit_button.click(fn=classify_text, inputs=[model_dropdown, text_input, label_input], outputs=output_label)
66
+
67
+ gr.Examples(examples, inputs=[text_input, label_input])
68
 
69
  # Launch the app
70
  if __name__ == "__main__":