leooj commited on
Commit
b12281c
·
1 Parent(s): e2d40b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -1,3 +1,31 @@
1
  import gradio as gr
 
2
 
3
- gr.load("models/kakaobank/kf-deberta-base").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoModel, AutoTokenizer
3
 
4
+ # Load the model and tokenizer
5
+ model = AutoModel.from_pretrained("kakaobank/kf-deberta-base")
6
+ tokenizer = AutoTokenizer.from_pretrained("kakaobank/kf-deberta-base")
7
+
8
+ def process_text(text):
9
+ # Tokenize the input text
10
+ tokens = tokenizer.tokenize(text)
11
+ token_output = f"Tokens: {tokens}"
12
+
13
+ # Generate model output
14
+ inputs = tokenizer(text, return_tensors="pt")
15
+ model_output = model(**inputs)
16
+
17
+ # You might want to format this output in a more readable way
18
+ model_output_str = str(model_output)
19
+
20
+ return token_output, model_output_str
21
+
22
+ # Create a Gradio interface
23
+ iface = gr.Interface(
24
+ fn=process_text,
25
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
26
+ outputs=[gr.outputs.Textbox(label="Tokenized Output"), gr.outputs.Textbox(label="Model Output")],
27
+ title="DeBERTa Model Text Processing",
28
+ description="This interface tokenizes the input text and processes it with the DeBERTa model."
29
+ )
30
+
31
+ iface.launch()