entregable3 / app.py
MapacheFantasma's picture
Update app.py
3fd3ae1 verified
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 = "MapacheFantasma/entregable3"
learner = from_pretrained_fastai(repo_id)
labels = ["valoración negativa", "valoracion positiva"]
# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(text):
pred,pred_idx,probs = learner.predict(text)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
test1 = "Blind Date (Columbia Pictures, 1934), was a decent film, but I have a few issues with this film. First of all, I don't fault the actors in this film at all, but more or less, I have a problem with the script. Also, I understand that this film was made in the 1930's and people were looking to escape reality, but the script made Ann Sothern's character look weak. She kept going back and forth between suitors and I felt as though she should have stayed with Paul Kelly's character in the end. He truly did care about her and her family and would have done anything for her and he did by giving her up in the end to fickle Neil Hamilton who in my opinion was only out for a good time. Paul Kelly's character, although a workaholic was a man of integrity and truly loved Kitty (Ann Sothern) as opposed to Neil Hamilton, while he did like her a lot, I didn't see the depth of love that he had for her character. The production values were great, but the script could have used a little work."
test2 = "Julie Andrews plays a German spy who falls in love with an American pilot Rock Hudson, while on an assignment for Germany.<br /><br />The songs are beautiful. The two are well-paired. Julie demonstrates a more temperamental side in this film than the nice girl she normally plays. <br /><br />A half-German, half-English girl who sings beautiful and entertains the troops in WW I, Julie sings some endearing Mancini songs. <br /><br />I loved the film. Some will say it's a \"chick-flick,\" but so what. It's wonderful. <br /><br />Supporting characters are somewhat stereotyped. It may not be up to Rock's performance in Pillow Talk, Magnificent Obsession, or Giant.<br /><br />Blake Edwards shot the film in Ireland and authentic WW I -type planes were used in the film. Scenery for England and France is absolutely gorgeous."
# Creamos la interfaz y la lanzamos.
gr.Interface(fn=predict, inputs=gr.Text(), outputs=gr.Label(num_top_classes=2),examples=[test1, test2]).launch(share=False)