djrana commited on
Commit
208d806
·
verified ·
1 Parent(s): 21b1c82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -8,25 +8,21 @@ pipe = pipeline(
8
  tokenizer="gpt2"
9
  )
10
 
11
- # Initialize a list to store the history of generated prompts
12
- history = []
13
-
14
- # Function to generate text based on input prompt and record the history
15
  def generate_text(prompt):
16
- generated_text = pipe(prompt, max_length=77)[0]["generated_text"]
17
- # Append the generated prompt and its result to the history list
18
- history.append({"prompt": prompt, "generated_text": generated_text})
19
- return generated_text
20
 
21
- # Create a Gradio interface with history recording
22
  iface = gr.Interface(
23
  fn=generate_text,
24
  inputs=gr.Textbox(lines=5, label="Prompt"),
25
- outputs=gr.Textbox(label="Output", show_copy_button=True),
26
  title="AI Art Prompt Generator",
27
- description="Art Prompt Generator is a user-friendly interface designed to optimize input for AI Art Generator or Creator. For faster generation speeds, it's recommended to load the model locally with GPUs, as the online demo at Hugging Face Spaces utilizes CPU, resulting in slower processing times.",
28
- api_name="predict"
29
  )
30
 
31
  # Launch the interface
32
- iface.launch(show_api=True)
 
8
  tokenizer="gpt2"
9
  )
10
 
11
+ # Function to generate text based on input prompt
 
 
 
12
  def generate_text(prompt):
13
+ # Generate multiple outputs for the same prompt
14
+ generated_texts = [pipe(prompt, max_length=77)[0]["generated_text"] for _ in range(5)]
15
+ return generated_texts
 
16
 
17
+ # Create a Gradio interface
18
  iface = gr.Interface(
19
  fn=generate_text,
20
  inputs=gr.Textbox(lines=5, label="Prompt"),
21
+ outputs=[gr.Textbox(label=f"Output {i+1}", readonly=True, multiline=True) for i in range(5)],
22
  title="AI Art Prompt Generator",
23
+ description="This tool generates multiple outputs for a given prompt using the AI Art Prompt Generator model.",
24
+ allow_flagging=False
25
  )
26
 
27
  # Launch the interface
28
+ iface.launch()