Sadjad Alikhani
Update app.py
5608218 verified
raw
history blame
1.5 kB
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 17 15:03:39 2024
@author: salikha4
"""
import gradio as gr
import os
from PIL import Image
# Paths to the images folder
RAW_PATH = os.path.join("images", "raw")
EMBEDDINGS_PATH = os.path.join("images", "embeddings")
# Function to load and display images based on user selection
def display_images(percentage, complexity):
# Generate the paths to the images
raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
# Load images using PIL
raw_image = Image.open(raw_image_path)
embeddings_image = Image.open(embeddings_image_path)
# Return the loaded images
return raw_image, embeddings_image
# Define the Gradio interface
data_percentage_options = [10, 30, 50, 70, 100]
task_complexity_options = [16, 32]
demo = gr.Interface(
fn=display_images,
inputs=[
gr.Dropdown(data_percentage_options, label="Percentage of Data for Training"),
gr.Radio(task_complexity_options, label="Task Complexity")
],
outputs=[
gr.Image(label="Raw Channels"),
gr.Image(label="Embeddings")
],
title="Raw vs. Embeddings Inference Results",
description="Select a data percentage and task complexity to view the corresponding inference result for raw channels and embeddings."
)
if __name__ == "__main__":
demo.launch()