Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
| 2 |
|
| 3 |
# Load the pre-trained WormGPT model and tokenizer
|
|
@@ -10,7 +11,16 @@ def generate_text(prompt, max_length=50):
|
|
| 10 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 11 |
return generated_text
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
| 3 |
|
| 4 |
# Load the pre-trained WormGPT model and tokenizer
|
|
|
|
| 11 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 12 |
return generated_text
|
| 13 |
|
| 14 |
+
def predict(input_text):
|
| 15 |
+
output = generate_text(input_text)
|
| 16 |
+
return output
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(
|
| 19 |
+
fn=predict,
|
| 20 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
|
| 21 |
+
outputs="text",
|
| 22 |
+
title="WormGPT Text Generation",
|
| 23 |
+
description="Generate text using the WormGPT model."
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
iface.launch()
|