enzer1992 commited on
Commit
5f81f2a
1 Parent(s): c45c024

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -1,7 +1,14 @@
1
- from transformers import pipeline
 
2
 
3
- messages = [
4
- {"role": "user", "content": "Who are you?"},
5
- ]
6
- pipe = pipeline("text-generation", model="enzer1992/AI-Guru")
7
- pipe(messages)
 
 
 
 
 
 
 
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()