Commit
·
2a24d84
1
Parent(s):
34a45fa
added requirements and fleshed out UI
Browse files- app.py +23 -4
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,7 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load your fine-tuned model from Hugging Face Hub
|
| 5 |
+
model_id = "peterjandre/finetuned-codet5-vbnet-csharp"
|
| 6 |
|
| 7 |
+
# Use text2text-generation pipeline (suitable for CodeT5)
|
| 8 |
+
generator = pipeline("text2text-generation", model=model_id)
|
| 9 |
+
|
| 10 |
+
def generate_code(prompt):
|
| 11 |
+
if not prompt:
|
| 12 |
+
return "Please enter a prompt."
|
| 13 |
+
outputs = generator(prompt, max_length=256, num_return_sequences=1)
|
| 14 |
+
return outputs[0]['generated_text']
|
| 15 |
+
|
| 16 |
+
# Build Gradio interface
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
fn=generate_code,
|
| 19 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter code prompt here..."),
|
| 20 |
+
outputs="textbox",
|
| 21 |
+
title="CodeT5 VBNet/C# Code Generator",
|
| 22 |
+
description="Generate VB.NET or C# code from your prompt using a fine-tuned CodeT5 model."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|