Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,30 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Load your model pipeline (e.g., text generation or similar tasks)
|
| 6 |
+
model = pipeline("text-generation", model="black-forest-labs/FLUX.1-schnell")
|
| 7 |
+
|
| 8 |
+
# Define a function that includes parameters
|
| 9 |
+
def generate_text(prompt, seed, num_inference_steps):
|
| 10 |
+
# Set the random seed for reproducibility
|
| 11 |
+
generator = torch.manual_seed(seed)
|
| 12 |
+
|
| 13 |
+
# Generate text with additional parameters
|
| 14 |
+
output = model(prompt, num_return_sequences=1, max_length=256,
|
| 15 |
+
do_sample=True, generator=generator)
|
| 16 |
+
return output[0]['generated_text']
|
| 17 |
+
|
| 18 |
+
# Create a Gradio interface
|
| 19 |
+
interface = gr.Interface(
|
| 20 |
+
fn=generate_text,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Textbox(label="Input Prompt"),
|
| 23 |
+
gr.Number(label="Seed", default=0),
|
| 24 |
+
gr.Number(label="Inference Steps", default=50)
|
| 25 |
+
],
|
| 26 |
+
outputs=gr.Textbox(label="Generated Text")
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# Launch the interface
|
| 30 |
+
interface.launch()
|