Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,14 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
3 |
|
4 |
+
model_name = "enzer1992/AI-Guru"
|
5 |
+
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
6 |
+
model = GPT2LMHeadModel.from_pretrained(model_name)
|
7 |
+
|
8 |
+
def generate_text(prompt):
|
9 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(inputs, max_length=100, num_return_sequences=1)
|
11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
14 |
+
interface.launch()
|