Shanaman987 commited on
Commit
1d7f96c
1 Parent(s): 0c84e4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,16 +1,14 @@
1
- import gradio as gr
2
- from transformers import AutoTokenizer, ai4bharat/indic-KeyboardInterrupt
3
 
4
- # Load the model and tokenizer
5
- tokenizer = AutoTokenizer.from_pretrained("ai4bharat/indic-bert")
6
- model = AutoModelForCausalLM.from_pretrained("ai4bharat/indic-bert")
 
7
 
8
- # Function to generate Malayalam text
9
- def generate_text(prompt):
10
- inputs = tokenizer.encode(prompt, return_tensors="pt")
11
- outputs = model.generate(inputs, max_length=50, num_return_sequences=1)
12
- return tokenizer.decode(outputs[0], skip_special_tokens=True)
 
13
 
14
- # Build the Gradio interface
15
- interface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Malayalam Text Generator")
16
- interface.launch()
 
1
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
2
 
3
+ # Correctly load the tokenizer and model
4
+ model_name = "ai4bharat/indic-bert"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
 
8
+ # Example usage
9
+ input_text = "This is a sample sentence for classification."
10
+ inputs = tokenizer(input_text, return_tensors="pt")
11
+ outputs = model(**inputs)
12
+
13
+ print(outputs)
14