File size: 1,060 Bytes
9aa94db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import tensorflow as tf
from huggingface_hub import from_pretrained_keras

description = "Keras implementation for Video Vision Transformer trained with OrganMNIST3D (CT videos)"
article = "Classes: liver, kidney-right, kidney-left, femur-right, femur-left, bladder, heart, lung-right, lung-left, spleen, pancreas.\n\nAuthor:<a href=\"https://huggingface.co/pablorodriper/\"> Pablo Rodríguez</a>; Based on the keras example by <a href=\"https://keras.io/examples/vision/vivit/\">Aritra Roy Gosthipaty and Ayush Thakur</a>"
title = "Video Vision Transformer on OrganMNIST3D"

def infer(x):
    return model.predict(tf.expand_dims(x, axis=0))[0]

model = from_pretrained_keras("keras-io/video-vision-transformer")

labels = ['liver', 'kidney-right', 'kidney-left', 'femur-right', 'femur-left', 'bladder', 'heart', 'lung-right', 'lung-left', 'spleen', 'pancreas']

iface = gr.Interface(
    fn = infer,
    inputs = "video",
    outputs = "number",
    description = description,
    title = title,
    article = article
    )

iface.launch()