Akbartus commited on
Commit
31fd630
·
verified ·
1 Parent(s): 8e9288d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,6 +1,30 @@
1
  import gradio as gr
 
 
2
 
3
- gr.load("models/black-forest-labs/FLUX.1-schnell").launch(guidance_scale=0.0,
4
- num_inference_steps=4,
5
- max_sequence_length=256,
6
- generator=torch.Generator("cpu").manual_seed(0))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()