Fetching metadata from the HF Docker repository...
-
Create sentiment_analyzer.py
import streamlit as st
from transformers import pipeline
import matplotlib.pyplot as plt
from PIL import Image, ImageFilter
import numpy as np
from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2, preprocess_input, decode_predictions
from tensorflow.keras.preprocessing.image import img_to_array
# Chargement du modèle d'analyse de sentiments et de reconnaissance d'images
sentiment_pipeline = pipeline("sentiment-analysis")
image_model = MobileNetV2(weights='imagenet')
def plot_sentiment(sentiment):
""" Dessine un graphique en camembert pour l'analyse de sentiments. """
labels = ['Positive', 'Negative']
sizes = [sentiment['score'], 1 - sentiment['score']]
colors = ['#ff9999','#66b3ff']
fig, ax = plt.subplots()
ax.pie(sizes, colors=colors, labels=labels, autopct='%1.1f%%', startangle=90)
ax.axis('equal')
return fig
def classify_image(image):
""" Classifie l'image et retourne les prédictions. """
image = image.resize((224, 224))
i… -
initial commit