Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
|
|
2 |
|
3 |
# Load the pre-trained GPT2 model and tokenizer
|
4 |
model = GPT2LMHeadModel.from_pretrained("gpt2")
|
@@ -29,7 +30,16 @@ def generate_code(prompt, max_length=200):
|
|
29 |
|
30 |
return code
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
2 |
+
import gradio as gr
|
3 |
|
4 |
# Load the pre-trained GPT2 model and tokenizer
|
5 |
model = GPT2LMHeadModel.from_pretrained("gpt2")
|
|
|
30 |
|
31 |
return code
|
32 |
|
33 |
+
def predict(input_text):
|
34 |
+
output = generate_code(input_text)
|
35 |
+
return output
|
36 |
+
|
37 |
+
iface = gr.Interface(
|
38 |
+
fn=predict,
|
39 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your code generation prompt here..."),
|
40 |
+
outputs="text",
|
41 |
+
title="Code Generation with GPT2",
|
42 |
+
description="Generate Python code based on your input prompt."
|
43 |
+
)
|
44 |
+
|
45 |
+
iface.launch()
|