Spaces:
Sleeping
Sleeping
File size: 1,158 Bytes
e9c4110 58c3a68 e638fa5 f3a0661 e8ef27f f3a0661 58c3a68 8af23e4 e9c4110 58c3a68 8af23e4 d05d8d7 df52915 63772a5 1377acd e638fa5 58c3a68 cda4669 7861741 ec26d1e e8ef27f ebdfa45 58c3a68 f3a0661 58c3a68 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import gradio as gr
from fastai.vision.all import *
from huggingface_hub import from_pretrained_fastai
import pathlib
# Enlace HTML con encabezado h1
html_link = '<h1><a href="" target="_blank">Link a la V2 (seleccionando presas)</a></h1>'
# Cargar el modelo preentrenado
repo_id = "ignaciobfp/moonboard_difficulty"
learner = from_pretrained_fastai(repo_id)
labels = learner.dls.vocab
# Función para realizar predicciones
def predict(img):
#img = PILImage.create(img)
pred,pred_idx,probs = learner.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
image_dir = pathlib.Path('images')
examples = [[path.as_posix()] for path in sorted(image_dir.glob('*.png'))]
iface = gr.Interface(
fn=predict,
inputs=gr.Image(height=144, width=144, label='Input', type='numpy'),
outputs=gr.Label(label='Output', num_top_classes=3),
title="Análisis de dificultad de imágenes de bloques Moonboard",
description="[Versión mejorada del modelo, seleccionando las presas](https://huggingface.co/spaces/Ignaciobfp/moonboard-2)",
examples=examples,
)
# Agregar el enlace al principio
iface.launch(share=False)
|