From 39865278bc309bd348bffd684d6f77af3aa9f54e Mon Sep 17 00:00:00 2001 From: Krishnan Authi Narayanan Date: Mon, 21 Aug 2023 20:15:17 +0200 Subject: [PATCH] initial --- Dockerfile | 0 app.py | 52 ++++++++++++++++++++++++++++++++++++++++ polyaxonfiles/app.yaml | 12 ++++++++++ polyaxonfiles/build.yaml | 15 ++++++++++++ requirements.txt | 3 +++ 5 files changed, 82 insertions(+) create mode 100644 Dockerfile create mode 100644 app.py create mode 100644 polyaxonfiles/app.yaml create mode 100644 polyaxonfiles/build.yaml create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/app.py b/app.py new file mode 100644 index 0000000..056f427 --- /dev/null +++ b/app.py @@ -0,0 +1,52 @@ +import streamlit as st +from transformers import pipeline + +option = st.selectbox( + "Select an Option", + [ + "Classify Text", + "Question Answering", + "Text Generation", + "Named Entity Recognition", + "Summarization", + "Translation", + ], +) + +if option == "Classify Text": + text = st.text_area(label="Enter text") + if text: + classifier = pipeline("sentiment-analysis") + answer = classifier(text) + st.write(answer) +elif option == "Question Answering": + q_a = pipeline("question-answering") + context = st.text_area(label="Enter context") + question = st.text_area(label="Enter question") + if context and question: + answer = q_a({"question": question, "context": context}) + st.write(answer) +elif option == "Text Generation": + text = st.text_area(label="Enter text") + if text: + text_generator = pipeline("text-generation") + answer = text_generator(text) + st.write(answer) +elif option == "Named Entity Recognition": + text = st.text_area(label="Enter text") + if text: + ner = pipeline("ner") + answer = ner(text) + st.write(answer) +elif option == "Summarization": + summarizer = pipeline("summarization") + article = st.text_area(label="Paste Article") + if article: + summary = summarizer(article, max_length=400, min_length=30) + st.write(summary) +elif option == "Translation": + translator = pipeline("translation_en_to_de") + text = st.text_area(label="Enter text") + if text: + translation = translator(text) + st.write(translation) diff --git a/polyaxonfiles/app.yaml b/polyaxonfiles/app.yaml new file mode 100644 index 0000000..20242d6 --- /dev/null +++ b/polyaxonfiles/app.yaml @@ -0,0 +1,12 @@ +version: 1.1 +kind: component +name: plx-streamlit-huggingface-app +tags: [streamlit, huggingface] +run: + kind: service + ports: [8501] + rewritePath: true + container: + image: avivkri/polyaxon-examples:plx-streamlit-huggingface-app + command: [streamlit, run, app.py] + diff --git a/polyaxonfiles/build.yaml b/polyaxonfiles/build.yaml new file mode 100644 index 0000000..463a789 --- /dev/null +++ b/polyaxonfiles/build.yaml @@ -0,0 +1,15 @@ +version: 1.1 +kind: operation +name: build-plx-streamlit-huggingface-app +params: + destination: + connection: "docker-connection" + value: polyaxon-examples:plx-streamlit-huggingface-app + context: + value: "{{ globals.artifacts_path }}/plx-streamlit-huggingface-app" +runPatch: + init: + - git: + url: "https://github.com/avivkri/plx-streamlit-huggingface-app" +hubRef: kaniko + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0559111 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +streamlit==0.70.0 +transformers==3.5.1 +typing-extensions==3.7.4.3