|
import gradio as gr |
|
import pandas as pd |
|
import matplotlib.pyplot as plt |
|
import io |
|
import google.generativeai as genai |
|
from PIL import Image |
|
|
|
def process_file(api_key, file, instructions): |
|
|
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Default(spacing_size="lg")) as demo: |
|
gr.Markdown("# **HD Data Visualizer** πβ¨") |
|
|
|
with gr.Row(): |
|
api_key = gr.Textbox(label="π Gemini API Key", type="password") |
|
file = gr.File(label="π Upload Dataset", file_types=[".csv", ".xlsx"]) |
|
|
|
instructions = gr.Textbox(label="π‘ Custom Instructions (optional)", |
|
placeholder="E.g.: Focus on time series patterns...") |
|
submit = gr.Button("π Generate Visualizations", variant="primary") |
|
|
|
with gr.Row(): |
|
outputs = [gr.Image(label=f"Visualization {i+1}", width=600) for i in range(3)] |
|
|
|
submit.click( |
|
process_file, |
|
inputs=[api_key, file, instructions], |
|
outputs=outputs |
|
) |
|
|
|
demo.launch() |