Spaces:
Sleeping
Sleeping
Download app.py from humellad/Entregable3: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/humellad/Entregable3/resolve/main/app.py
- Command line
-
hf download hf://spaces/humellad/Entregable3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/humellad/Entregable3/resolve/main/app.py
796 Bytes
| import gradio as gr | |
| from fastai.text.all import * | |
| from huggingface_hub import from_pretrained_fastai | |
| repo_id = "humellad/entregable_3" | |
| learn = from_pretrained_fastai(repo_id) | |
| def predict(text): | |
| pred, pred_idx, probs = learn.predict(text) | |
| vocab = learn.dls.vocab[1] | |
| return {vocab[i]: float(probs[i]) for i in range(len(vocab))} | |
| sample_examples = [ | |
| ["i never make her separate from me because i don t ever want her to feel like i m ashamed with her"], | |
| ["This makes me feel very sad and lonely."], | |
| ["I am absolutely furious about the delay."], | |
| ["It's a beautiful day to go for a walk in the park."], | |
| ["I feel a bit nervous about the upcoming presentation."] | |
| ] | |
| gr.Interface(fn=predict, inputs="text", outputs="label", examples=sample_examples).launch() |