Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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=
|
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.
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|