Spaces:
Build error
Build error
pablorodriper
commited on
Commit
·
9aa94db
1
Parent(s):
b24dec4
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from huggingface_hub import from_pretrained_keras
|
4 |
+
|
5 |
+
description = "Keras implementation for Video Vision Transformer trained with OrganMNIST3D (CT videos)"
|
6 |
+
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>"
|
7 |
+
title = "Video Vision Transformer on OrganMNIST3D"
|
8 |
+
|
9 |
+
def infer(x):
|
10 |
+
return model.predict(tf.expand_dims(x, axis=0))[0]
|
11 |
+
|
12 |
+
model = from_pretrained_keras("keras-io/video-vision-transformer")
|
13 |
+
|
14 |
+
labels = ['liver', 'kidney-right', 'kidney-left', 'femur-right', 'femur-left', 'bladder', 'heart', 'lung-right', 'lung-left', 'spleen', 'pancreas']
|
15 |
+
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn = infer,
|
18 |
+
inputs = "video",
|
19 |
+
outputs = "number",
|
20 |
+
description = description,
|
21 |
+
title = title,
|
22 |
+
article = article
|
23 |
+
)
|
24 |
+
|
25 |
+
iface.launch()
|