Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234564 unmodified lines11121314151617181920212223import gradio as grfrom transformers import pipelinedef load_model():# Load a pre-trained HuggingFace pipeline for sentiment analysismodel_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")4 unmodified linesresult = model(text)return resultdef main():# Load the modelmodel = load_model()# Define the Gradio interfaceinterface = gr.Interface(fn=lambda text: classify_text(model, text),inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),outputs="json",title="Text Classification with HuggingFace",1234567891011124 unmodified lines17181920212223242526272829303132333435import gradio as grfrom transformers import pipeline# Azure Text Analytics setupazure_endpoint = "https://t6langservice.cognitiveservices.azure.com/"azure_api_key = "3CU1gpUszvl7pLb90Ivdp1Kd5WZc56savzdXOK5GV40JHebnxnxoJQQJ99BAACYeBjFXJ3w3AAAaACOGkRT5"# Authenticate clienttext_analytics_client = TextAnalyticsClient(endpoint=azure_endpoint, credential=AzureKeyCredential(azure_api_key))def load_model():# Load a pre-trained HuggingFace pipeline for sentiment analysismodel_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")4 unmodified linesresult = model(text)return resultdef classify_text_azure(model, text):# Use the loaded model to classify textresult = text_analytics_client.analyze_sentiment(text)return resultdef main():# Load the modelmodel = load_model()# Define the Gradio interfaceinterface = gr.Interface(fn=lambda text: classify_text_azure(model, text),inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),outputs="json",title="Text Classification with HuggingFace",
app.py+13-1