File size: 992 Bytes
d087cd4
 
 
 
 
 
861c573
d087cd4
 
 
 
 
 
e3aae26
d087cd4
 
 
 
 
 
0c5eff0
 
d087cd4
 
916075b
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
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *


# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
repo_id = "kylar55/entregable3_1"

learner = from_pretrained_fastai(repo_id)
labels = learner.dls.vocab

# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(text):
    pred,pred_idx,probs = learner.predict(text)
    if pred == "en":
        return "Ingles"
    if pred == "ja":
        return "Japonés"
    if pred == "es":
        return "Español"
    else:
        return "other"
    
# Creamos la interfaz y la lanzamos. 
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label(),examples=["娘が1歳になったので新しい知育玩具を探していたところリーズナブルで見た目も可愛いこちらの商品に辿りつきました。","Esta frase no es un meme","Highly recommend for those who don't like being spoon fed CGI garbage."]).launch(share=False)