Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,15 +4,6 @@ from transformers import T5ForConditionalGeneration, RobertaTokenizer
|
|
| 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 generate_code(input_text):
|
| 9 |
-
print(input_text)
|
| 10 |
-
input_ids = tokenizer(input_text, return_tensors='pt', padding="max_length", truncation=True, max_length=128).input_ids.to(model.device)
|
| 11 |
-
outputs = model.generate(input_ids, max_length=128, num_beams=4, early_stopping=True)
|
| 12 |
-
predicted_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
-
cleaned_code = clean_generated_code(postprocess_output(predicted_text))
|
| 14 |
-
|
| 15 |
-
return cleaned_code
|
| 16 |
|
| 17 |
def preprocess_infer_input(text):
|
| 18 |
# Assuming the input is already a string, we don't need to access it as a dictionary
|
|
|
|
| 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 preprocess_infer_input(text):
|
| 9 |
# Assuming the input is already a string, we don't need to access it as a dictionary
|