Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import T5ForConditionalGeneration, RobertaTokenizer
|
3 |
+
|
4 |
+
# Load the quantized model and tokenizer from Hugging Face Hub
|
5 |
+
quantized_model = T5ForConditionalGeneration.from_pretrained("AbdulHadi806/codet5-finetuned-latest-quantized")
|
6 |
+
tokenizer = RobertaTokenizer.from_pretrained("AbdulHadi806/codet5-finetuned-latest-quantized")
|
7 |
+
|
8 |
+
def inference(input_text):
|
9 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
10 |
+
outputs = quantized_model.generate(**inputs)
|
11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
# Create Gradio interface
|
14 |
+
iface = gr.Interface(fn=inference, inputs="text", outputs="text")
|
15 |
+
|
16 |
+
# Launch the interface
|
17 |
+
iface.launch()
|