# gradio interface import gradio as gr def predict_sentiment(text): # Vectorisation et padding seq = tokenizer.texts_to_sequences([text]) padded = pad_sequences(seq, maxlen=x_train.shape[1]) pred = lstm_model.predict(padded) sentiment = "Positive" if pred[0][0] >= 0.5 else "Negative" return sentiment iface = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=2, label="Entrez un tweet en français"), outputs=gr.Textbox(label="Sentiment prédit"), title="Analyse de sentiment de tweets français", description="Entrez un tweet pour obtenir la prédiction du sentiment (Positive/Negative) par le modèle LSTM." ) iface.launch() def predict_sentiment(text): # Vectorisation et padding seq = tokenizer.texts_to_sequences([text]) padded = pad_sequences(seq, maxlen=x_train.shape[1]) pred = gru_model.predict(padded) sentiment = "Positive" if pred[0][0] >= 0.5 else "Negative" return sentiment iface = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=2, label="Entrez un tweet en français"), outputs=gr.Textbox(label="Sentiment prédit"), title="Analyse de sentiment de tweets français", description="Entrez un tweet pour obtenir la prédiction du sentiment (Positive/Negative) par le modèle LSTM." ) iface.launch() import gradio as gr def predict_sentiment(text): # Vectorisation et padding seq = tokenizer.texts_to_sequences([text]) padded = pad_sequences(seq, maxlen=x_train.shape[1]) pred = SimpleRNN_model.predict(padded) sentiment = "Positive" if pred[0][0] >= 0.5 else "Negative" return sentiment iface = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=2, label="Entrez un tweet en français"), outputs=gr.Textbox(label="Sentiment prédit"), title="Analyse de sentiment de tweets français", description="Entrez un tweet pour obtenir la prédiction du sentiment (Positive/Negative) par le modèle LSTM." ) iface.launch()