Rerandaka commited on
Commit
76eebae
·
verified ·
1 Parent(s): bccfe08

update app.py 2

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -1,9 +1,4 @@
1
- import gradio as gr
2
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
- import torch
4
-
5
- # Load model
6
- model_id = "Rerandaka/Cild_safety_bigbird"
7
  tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
8
  model = AutoModelForSequenceClassification.from_pretrained(model_id)
9
 
@@ -15,12 +10,13 @@ def classify(text):
15
  predicted_class = torch.argmax(logits, dim=1).item()
16
  return str(predicted_class)
17
 
18
- # Create Gradio interface
19
- with gr.Blocks() as demo:
20
- txt_in = gr.Textbox(label="Enter text")
21
- txt_out = gr.Textbox(label="Prediction")
22
- btn = gr.Button("Classify")
23
- btn.click(classify, txt_in, txt_out)
24
 
25
- # Launch with API enabled
26
- demo.launch()
 
 
1
+ d = "Rerandaka/Cild_safety_bigbird"
 
 
 
 
 
2
  tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
3
  model = AutoModelForSequenceClassification.from_pretrained(model_id)
4
 
 
10
  predicted_class = torch.argmax(logits, dim=1).item()
11
  return str(predicted_class)
12
 
13
+ # Create API-ready interface
14
+ demo = gr.Interface(
15
+ fn=classify,
16
+ inputs=gr.Textbox(label="Enter text"),
17
+ outputs=gr.Textbox(label="Prediction")
18
+ )
19
 
20
+ # Enable queue and API support
21
+ demo.queue() # <-- Enables /queue/join
22
+ demo.launch(show_api=True) # <-- Enables gradio_client + /predict