Skip to content

Jenishbh/AES-Automated-Essay-Scoring-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

AES-Automated-Essay-Scoring-

Week 11 Homework: Signature Project: Automated Essay Scoring System

Step 1: Develop and test the solution on a VM

Create an VM instance on GCP

we will use Ubuntu 20.04 LTS image, make sure there is an external IP, try to use with big size like 50 GB

Untitled

Install common package

  • command
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y build-essential python3-pip libxml-parser-perl unzip
sudo apt-get install -y pkg-config libpng-dev libfreetype6-dev freetype2-demos
pip3 install gdown
vi ~/.bashrc
  • .bashrc content
.....
export PATH="$PATH:$HOME/.local/bin"
  • command
source ~/.bashrc

Download and unzip the package

gdown https://drive.google.com/uc\?id\=1RxfZOYyNvzvCf37_vABfJMkohAsEZKtH
unzip rough.zip
wget https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-uncased.tar.gz

Untitled

Install and test ROUGE

sudo cpan install XML::Parser::PerlSAX
sudo cpan install XML::RegExp
sudo cpan install XML::DOM
cd RELEASE-1.5.5/
./runROUGE-test.pl

Untitled

Install pyrouge

cd
git clone https://github.com/bheinzerling/pyrouge.git
cd pyrouge
pip3 install -e .

Clone the project and change the hardcode path on BertParent.py line 48

git clone https://github.com/Quan25/flask-summary.git
pwd
vi flask-summary/summarizer/BertParent.py
  • change content
# from
self.model = BertModel.from_pretrained('/home/quan/Downloads/bert-large-uncased')
# to
self.model = BertModel.from_pretrained('/home/chen19606/bert-large-uncased.tar.gz')

Untitled

Install flask and related python package

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
pip3 install flask pandas sklearn nltk
pip3 install gensim==3.8.3
pip3 install pytorch-pretrained-bert
pip3 install matplotlib==3.0.1

create punktDownload.py

  • command
vi punktDownload.py
  • content
import nltk

nltk.download('punkt')
  • command
python3 punktDownload.py

Untitled

Run Flask app

cd flask-summary/
python3 app.py

Untitled

Fork the project and change the hardcode path for the dockerfile

Install docker on Ubuntu

https://docs.docker.com/engine/install/ubuntu/

Build Docker image with Dockerfile and push to the Dockerhub

  • command
cd
vi Dockerfile
  • content
FROM ubuntu:20.04

ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN mkdir -p /home/project/

COPY rough.zip /home/project/
COPY punktDownload.py /home/project/
COPY bert-large-uncased.tar.gz /home/project/

WORKDIR /home/project/
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y build-essential python3-pip libxml-parser-perl unzip git
RUN apt-get install -y pkg-config libpng-dev libfreetype6-dev freetype2-demos

RUN unzip rough.zip
RUN cpan install XML::Parser::PerlSAX
RUN cpan install XML::RegExp
RUN cpan install XML::DOM

WORKDIR /home/project/RELEASE-1.5.5
RUN ./runROUGE-test.pl

WORKDIR /home/project/
RUN git clone https://github.com/bheinzerling/pyrouge.git

WORKDIR /home/project/pyrouge
RUN pip install -e .

WORKDIR /home/project/
RUN git clone https://github.com/tchen0915/flask-summary.git
RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
RUN pip3 install flask pandas sklearn nltk
RUN pip3 install gensim==3.8.3
RUN pip3 install pytorch-pretrained-bert
RUN pip3 install matplotlib==3.0.1
RUN python3 punktDownload.py

WORKDIR /home/project/flask-summary
EXPOSE 5000
CMD ["python3", "app.py"]
  • command
sudo docker build -t tchen0915/aes .
# sudo docker run -p 5000:5000 -t tchen0915/aes
sudo docker login
sudo docker push tchen0915/aes

Step 2: Test your image on the GCP cloudshell

run the docker image

docker run -p 5000:5000 -t tchen0915/aes

Untitled

Use web Preview and change the port number to 5000

image

image

image

image

Step 3: Deploy this solution on Kubernetes using cloud shell

Create cluster

gcloud container clusters create kubia --num-nodes=1 --machine-type=c2-standard-4 --region=us-west1-a

Untitled

Create deployment

  • command
vi aes-deployment.yaml
  • content
apiVersion: apps/v1
kind: Deployment
metadata:
  name: aes-deployment
spec:
  selector:
    matchLabels:
      app: aes-deployment
  replicas: 1
  template:
    metadata:
      labels:
        app: aes-deployment
    spec:
      containers:
      - name: aes-deployment
        image: tchen0915/aes
        ports:
        - containerPort: 5000
  • command
kubectl create -f aes-deployment.yaml

image

Create service

  • command
vi aes-service.yaml
  • content
apiVersion: v1
kind: Service
metadata:
  name: aes-service
spec:
  selector:
    app: aes-deployment
  ports:
  - protocol: TCP
    port: 5000
    targetPort: 5000
  • command
kubectl create -f aes-service.yaml

image

Create ingress

  • command
vi aes-ingress.yaml
  • content
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: aes-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    - host: aes.wifrost.top
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: aes-service
                port:
                  number: 5000
  • command
kubectl create -f aes-ingress.yaml

image

Check status

kubectl get pods
kubectl get svc
kubectl get ingress

Untitled

Test it with random wiki paragraph (I tried google wiki)

Google LLC is an American multinational technology company that specializes in Internet-related services and products, which include a search engine, online advertising, cloud computing, software, artificial intelligence,[10] quantum computing,[11] and hardware. It has been referred to as the "most powerful company in the world" and one of the world's most valuable brands due to its market dominance, data collection, and technological advantages in the area of artificial intelligence.[12][13][14] It is considered one of the Big Five American information technology companies, alongside Amazon, Apple, Meta, and Microsoft.

Google was founded on September 4, 1998, by Larry Page and Sergey Brin while they were PhD students at Stanford University in California. Together they own about 14% of its publicly listed shares and control 56% of the stockholder voting power through super-voting stock. The company went public via an initial public offering (IPO) in 2004. In 2015, Google was reorganized as a wholly-owned subsidiary of Alphabet Inc.. Google is Alphabet's largest subsidiary and is a holding company for Alphabet's Internet properties and interests. Sundar Pichai was appointed CEO of Google on October 24, 2015, replacing Larry Page, who became the CEO of Alphabet. On December 3, 2019, Pichai also became the CEO of Alphabet.[15]

The company has since rapidly grown to offer a multitude of products and services beyond Google Search, many of which hold dominant market positions. These products address a wide range of use cases including email (Gmail), navigation (Maps), cloud computing (Cloud), web browsing (Chrome), video sharing (YouTube), productivity (Workspace), operating systems (Android), cloud storage (Drive), language translation (Translate), photo storage (Photo), video calling (Meet), smart home (Nest), smartphones (Pixel), wearable technology (Fitbit), gaming (Stadia), music streaming (YouTube Music), video on demand (TV), artificial intelligence (Assistant), machine learning (TensorFlow), AI chips (TPU), and more. The company is also notorious for its vast portfolio of discontinued or replaced products,[16][17] which includes Google+, Reader, Play Music, Nexus, Hangouts, and Inbox by Gmail.

Google is well-known for it highly ambitious technological innovations aimed at solving humanity's biggest problems.[18] Some of these innovations include quantum computing (Sycamore), self-driving cars (Waymo, formerly the Google self-driving project), and smart cities (Sidewalk Labs), transformer models (Google Brain).

Google.com and YouTube.com are the two most visited websites worldwide followed by Facebook and Twitter. Google is also the largest search engine, mapping and navigation service, email provider, office suite, video sharing platform, photo and cloud storage provider, mobile operating system, web browser, ML framework, and AI virtual assistant provider in the world as measured by market share. On the list of most valuable brands, Google is ranked second by Forbes[19] and fourth by Interbrand.[20] It has received significant criticism involving issues such as privacy concerns, tax avoidance, censorship, search neutrality, antitrust and abuse of its monopoly position.

image

Click submit button

image

Click Grade Students button

image

Reference

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published