gokilashree commited on
Commit
0501446
·
verified ·
1 Parent(s): 5826cb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -59,7 +59,7 @@ def translate_text(input_text, src_lang="en"):
59
  return translated_text
60
 
61
  # Function to generate text using the GPT-Neo model
62
- def generate_text(prompt, max_length=150):
63
  generated_texts = text_generator(prompt, max_length=max_length, num_return_sequences=1)
64
  return generated_texts[0]["generated_text"]
65
 
@@ -70,10 +70,23 @@ def app_interface(input_text, src_language="en"):
70
  generated_text = generate_text(translated_text)
71
  return generated_text, generated_image
72
 
73
- # Launch the Gradio App
74
- gr.Interface(
75
- fn=app_interface,
76
- inputs=[gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), gr.inputs.Dropdown(["en", "fr", "de", "es"], default="en", label="Source Language")],
77
- outputs=[gr.outputs.Textbox(label="Generated Text"), gr.outputs.Image(label="Generated Image")],
78
- title="Multilingual Text-to-Image & Text Generation"
79
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  return translated_text
60
 
61
  # Function to generate text using the GPT-Neo model
62
+ def generate_text(prompt, max_length=50):
63
  generated_texts = text_generator(prompt, max_length=max_length, num_return_sequences=1)
64
  return generated_texts[0]["generated_text"]
65
 
 
70
  generated_text = generate_text(translated_text)
71
  return generated_text, generated_image
72
 
73
+ # Launch the Gradio App using the new Gradio components
74
+ with gr.Blocks() as demo:
75
+ gr.Markdown("# Multilingual Text-to-Image & Text Generation")
76
+
77
+ # Define Gradio components
78
+ input_text = gr.Textbox(lines=2, placeholder="Enter text here...")
79
+ src_language = gr.Dropdown(["en", "fr", "de", "es"], value="en", label="Source Language")
80
+
81
+ # Display outputs for text and image generation
82
+ generated_text_output = gr.Textbox(label="Generated Text")
83
+ generated_image_output = gr.Image(label="Generated Image")
84
+
85
+ # Button to trigger the processing
86
+ generate_button = gr.Button("Generate")
87
+
88
+ # Link the button to the function call
89
+ generate_button.click(fn=app_interface, inputs=[input_text, src_language], outputs=[generated_text_output, generated_image_output])
90
+
91
+ # Run the app
92
+ demo.launch()