콘텐츠로 이동

멀티모달 AI 어시스턴트

필요한 모듈 설치하기

!pip install openai
!pip install gradio

멀티모달 AI 템플릿

import gradio as gr

def process_multimodal(text, image, audio):
    results = []

    if text:
        results.append(f"📝 Text analysis: {len(text)} characters processed")

    if image is not None:
        results.append("🖼️ Image uploaded and analyzed")

    if audio is not None:
        results.append("🎵 Audio file processed")

    return "\n".join(results) if results else "Please provide some input!"

with gr.Blocks(
    theme=gr.themes.Default(
        primary_hue="blue",
        secondary_hue="gray",
        neutral_hue="slate"
    ),
    css="""
    .gradio-container {
        font-family: 'Inter', sans-serif;
    }
    .tab-nav button {
        font-weight: 600;
    }
    """
) as demo:

    gr.Markdown("""
    # 🤖 Multimodal AI Assistant
    ### Upload text, images, or audio for AI analysis
    """)

    with gr.Row():
        with gr.Column():
            text_input = gr.Textbox(
                label="💬 Text Input",
                placeholder="Enter your text here...",
                lines=4
            )

            image_input = gr.Image(
                label="📸 Image Upload",
                type="pil"
            )

            audio_input = gr.Audio(
                label="🎤 Audio Upload",
                type="filepath"
            )

            process_btn = gr.Button(
                "🚀 Process All",
                variant="primary",
                size="lg"
            )

        with gr.Column():
            output = gr.Textbox(
                label="📊 Analysis Results",
                lines=10,
                interactive=False
            )

    process_btn.click(
        process_multimodal,
        inputs=[text_input, image_input, audio_input],
        outputs=output
    )

demo.launch()