Spaces:
Sleeping
Sleeping
Create Gpt1
Browse files
Gpt1
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
# Load the uncensoredgpt model and tokenizer
|
5 |
+
model_name = "gpt2" # Replace with the actual uncensoredgpt model name if available
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
|
9 |
+
def generate_text(prompt, max_length=100):
|
10 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
11 |
+
outputs = model.generate(inputs, max_length=max_length, num_return_sequences=1)
|
12 |
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
+
return generated_text
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=generate_text,
|
18 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
|
19 |
+
outputs="text",
|
20 |
+
title="UncensoredGPT",
|
21 |
+
description="A simple interface for the uncensoredgpt model."
|
22 |
+
)
|
23 |
+
|
24 |
+
# Launch the interface
|
25 |
+
iface.launch()
|