Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model
|
5 |
+
model = pipeline("text-generation", model="vedant-jumle/gemma-alpaca-uncensored")
|
6 |
+
|
7 |
+
def generate_text(prompt, max_length=100, temperature=0.7):
|
8 |
+
"""Generate text based on the input prompt."""
|
9 |
+
generated = model(prompt, max_length=max_length, temperature=temperature, do_sample=True)[0]['generated_text']
|
10 |
+
return generated
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_text,
|
15 |
+
inputs=[
|
16 |
+
gr.Textbox(label="Enter your prompt"),
|
17 |
+
gr.Slider(minimum=10, maximum=500, value=100, step=1, label="Max Length"),
|
18 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.7, step=0.1, label="Temperature")
|
19 |
+
],
|
20 |
+
outputs=gr.Textbox(label="Generated Text"),
|
21 |
+
title="Gemma Alpaca Uncensored Text Generator",
|
22 |
+
description="Generate text using the vedant-jumle/gemma-alpaca-uncensored model."
|
23 |
+
)
|
24 |
+
|
25 |
+
# Launch the app
|
26 |
+
iface.launch()
|