DebasishDhal99's picture
Update app.py
0dd565d
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import cv2
import gradio as gr
from channel_functions import individual_channel_image_final, individual_channel_image, channel_distribution_plotter, which_channel_dominates
description1 = '''This tab shows which channel dominates which part of an image\n
Upload an image or drag an online image to the upload section. Bring it to the rectangular area. Release it when the border becomes red'''
original_image_plot = gr.Radio(['yes','no'], label = "Do you want the original image be plotted in the background?")
original_image_opacity = gr.Slider(0,1, value = 0.3, label = "Opacity of the original image")
channel_opacity = gr.Slider(0,1, value = 0.7, label = "Opacity of the output channel-domination image")
individual_channel_choice = gr.Radio(['Red','Green','Blue', 'All'], label = 'Which channel do you want to see the image in?')
iface1 = gr.Interface(
fn = which_channel_dominates,
inputs = [gr.Image(), original_image_plot, original_image_opacity, channel_opacity],
outputs = "image",
title="Channel domination",
description=description1,
)
iface2 = gr.Interface(
fn = channel_distribution_plotter,
inputs = gr.Image(),
outputs = "image",
title = "Distribution of pixel counts in all channels",
description = 'Something random'
)
iface3 = gr.Interface(
fn = individual_channel_image_final,
inputs = [gr.Image(), individual_channel_choice],
outputs = "image" ,
title = "Images in individual channels",
description = "Something random"
)
combinedInterface = gr.TabbedInterface([iface1, iface2, iface3],['Channel domination', 'Channel distribution', "Individual channel"])
combinedInterface.launch(share=False)