import gradio as gr from transformers import pipeline # Load models translation_pipeline = pipeline("translation", model="Helsinki-NLP/opus-mt-ta-en") text_generation_pipeline = pipeline("text-generation", model="gpt2") # Simulated image generation (replace with Hugging Face Diffusers or similar if needed) def generate_image(prompt: str) -> str: # You can integrate actual image generation here return f"https://via.placeholder.com/512?text={prompt.replace(' ', '+')}" # Main function def multimodal_pipeline(tamil_text: str): # Step 1: Translate Tamil to English translated = translation_pipeline(tamil_text)[0]["translation_text"] # Step 2: Generate English text generated = text_generation_pipeline(translated, max_length=50, do_sample=True)[0]["generated_text"] # Step 3: Generate Image (simulate) image_url = generate_image(generated) return translated, generated, image_url # Gradio Interface interface = gr.Interface( fn=multimodal_pipeline, inputs=gr.Textbox(label="Enter Tamil Text", placeholder="உங்கள் தமிழ் உரையை இங்கே உள்ளிடவும்"), outputs=[ gr.Textbox(label="English Translation"), gr.Textbox(label="Generated Prompt"), gr.Image(label="Generated Image"), ], title="Tamil to Image Multimodal App", description="This app translates Tamil to English, generates a descriptive sentence, and creates an image based on it." ) if __name__ == "__main__": interface.launch()