Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
# Cargar el modelo
|
4 |
-
modelo =
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
interfaz.launch()
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
+
import torch
|
4 |
|
5 |
+
# Cargar el modelo desde Hugging Face
|
6 |
+
modelo = AutoModelForSequenceClassification.from_pretrained("Devarshi/Brain_Tumor_Classification")
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("Devarshi/Brain_Tumor_Classification")
|
8 |
|
9 |
+
# Definir la funci贸n de inferencia
|
10 |
+
def clasificar_tumor(texto):
|
11 |
+
inputs = tokenizer(texto, return_tensors="pt")
|
12 |
+
outputs = modelo(**inputs)
|
13 |
+
logits = outputs.logits
|
14 |
+
return torch.argmax(logits).item()
|
15 |
+
|
16 |
+
# Definir la interfaz gr谩fica
|
17 |
+
interfaz = gr.Interface(fn=clasificar_tumor, inputs="text", outputs="text")
|
18 |
+
|
19 |
+
# Lanzar la interfaz
|
20 |
interfaz.launch()
|
21 |
+
|