Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
avivkri committed Aug 21, 2023
0 parents commit 3986527
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
Empty file added Dockerfile
Empty file.
52 changes: 52 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions polyaxonfiles/app.yaml
Original file line number Diff line number Diff line change
@@ -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]

15 changes: 15 additions & 0 deletions polyaxonfiles/build.yaml
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
streamlit==0.70.0
transformers==3.5.1
typing-extensions==3.7.4.3

0 comments on commit 3986527

Please sign in to comment.