Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.text.all import * | |
| from huggingface_hub import from_pretrained_fastai | |
| repo_id = "almangad/entregable3" | |
| learner = from_pretrained_fastai(repo_id) | |
| print("vocab:", learner.dls.vocab) | |
| print("tipo:", type(learner.dls.vocab)) | |
| def predict_text(texto): | |
| pred_class, pred_idx, probs = learner.predict(texto) | |
| vocab = learner.dls.vocab[1] | |
| return {str(vocab[i]): float(probs[i]) for i in range(len(probs))} | |
| demo = gr.Interface( | |
| fn=predict_text, | |
| inputs=gr.Textbox(lines=3, placeholder="Text here..."), | |
| outputs=gr.Label(num_top_classes=6), | |
| examples=[ | |
| ["im feeling quite sad and sorry for myself but ill snap out of it soon"], | |
| ["i am feeling grouchy"] | |
| ], | |
| cache_examples=False | |
| ) | |
| demo.launch() |