new file: requirements.txt
This commit is contained in:
commit
a2c89ea04c
|
@ -0,0 +1,27 @@
|
|||
# please visit https://github.com/xfyun/aiges/releases to get stable and suitable iamges.
|
||||
|
||||
FROM iflyopensource/aiges-gpu:11.2-1.17-3.9.13-ubuntu1804-v3.3.2
|
||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
|
||||
RUN sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
|
||||
RUN --mount=target=/root/packages.txt,source=packages.txt apt-get update && xargs -r -a /root/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /home/user/app
|
||||
RUN useradd -m -u 1000 user
|
||||
RUN chown -R 1000.1000 /home/user
|
||||
|
||||
|
||||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
|
||||
RUN apt-get install git-lfs
|
||||
RUN git lfs install
|
||||
RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/
|
||||
|
||||
|
||||
RUN pip install --no-cache-dir pip==22.3.1
|
||||
RUN --mount=target=requirements.txt,source=requirements.txt pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY --chown=1000 ./ /home/user/app
|
||||
|
||||
RUN git clone http://172.16.59.16:3000/Seethal/sentiment_analysis_generic_dataset.git
|
||||
|
||||
CMD ["python3", "app.py"]
|
|
@ -0,0 +1,29 @@
|
|||
import gradio as gr
|
||||
from transformers import pipeline, AutoTokenizer, AutoConfig, AutoModelForSequenceClassification
|
||||
|
||||
modelName="sentiment_analysis_generic_dataset"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(modelName)
|
||||
#model = AutoModelForSequenceClassification.from_pretrained(modelName)
|
||||
sentimentPipeline = pipeline("sentiment-analysis", model=modelName, tokenizer=tokenizer)
|
||||
Label2Des = {
|
||||
"LABEL_0": "NEGATIVE",
|
||||
"LABEL_1": "NEUTRAL",
|
||||
"LABEL_2": "POSITIVE"
|
||||
}
|
||||
|
||||
def sentiment_analysis(text):
|
||||
results = sentimentPipeline(text)
|
||||
|
||||
return f"Sentiment: {Label2Des.get(results[0]['label'])}, Score: {results[0]['score']:.2f}"
|
||||
|
||||
demo = gr.Interface(fn=sentiment_analysis,
|
||||
inputs='text',
|
||||
outputs='text',
|
||||
title = "文本情感分析"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.queue(concurrency_count=3)
|
||||
demo.launch(server_name = "0.0.0.0")
|
|
@ -0,0 +1,2 @@
|
|||
git
|
||||
curl
|
|
@ -0,0 +1,4 @@
|
|||
gradio==3.21.0
|
||||
transformers==4.27.1
|
||||
torch==2.0.0
|
||||
timm
|
Loading…
Reference in New Issue