Spaces:
No application file
No application file
import gradio as gr | |
import pandas as pd | |
import os | |
import cv2 | |
# from inference import inference | |
from PIL import Image, ImageFilter | |
def prueba_inferencia(img): | |
df = pd.DataFrame({"Cell type": ["rbc", "wbc", "platelets"], "Count": [28, 55, 43]}) | |
# Aplicar filtro gaussiano | |
img = cv2.imread(img, cv2.IMREAD_COLOR) | |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
return [img, df] | |
def run(): | |
# Crear la interfaz de Gradio | |
interface = gr.Interface( | |
fn=prueba_inferencia,#inference | |
inputs=gr.Image(type="filepath"), | |
outputs=[gr.Image(type="pil"), | |
gr.BarPlot( | |
x="Cell type", | |
y="Count", | |
x_title="Cell type", | |
y_title="Count", | |
title="Cell Count", | |
tooltip=["Cell type", "Count"], | |
vertical=False, | |
y_lim=[0, 100], | |
)], | |
examples=[os.path.join("./data", img) for img in os.listdir("./data")], | |
title="Detección de Células Sanguíneas", | |
description="Sube una imagen de microscopio de células sanguíneas para detectar RBC, WBC y platelets." | |
) | |
# Ejecutar la aplicación | |
interface.launch(server_name="0.0.0.0", server_port=7860) # Se encuentra en http://127.0.0.1:7860/ | |
if __name__ == "__main__": | |
run() | |