Youtube Link: https://youtu.be/N_WTppKuK4E
For this assignment, you will be creating a publicly accessible auto-scaling container using Azure App Services and Flask. This project provides an opportunity to apply your Flask knowledge from our Data Engineering Class and gain experience with building and deploying scalable web-hosted applications.
The Flask application utilizes the Hugging Face Transformers library to implement a text summarization tool powered by the GPT-2 language model. Users input text through a form on the homepage ('/'), and the application, upon a POST request to '/generate', encodes the input using GPT-2 tokenizer, generates a summary with the model, and displays the original input alongside the generated text on the 'result.html' page. The GPT-2 model, loaded from Hugging Face's Transformers, is fine-tuned for language modeling, ensuring coherent and contextually relevant text generation. The app runs in debug mode, making it accessible at 'http://localhost:5000/'.
- This link only works when you run the command python app.py as it starts a development server and makes the specified port (by default, it's usually 5000) accessible on your local machine.
- This repository contains a simple web application built for generative sentence completion. The application utilizes Flask, a Python web framework, to create an interface for users to input text and receive an autocompleted sentence generated by a language model.
-
app.py: The main Python script that defines the Flask application. It handles incoming requests, processes user input, and generates autocompleted sentences using a pre-trained language model.
-
index.html: The HTML template for the user interface. It provides a form where users can input text for summarization.
-
result.html: Another HTML template that displays the original input text and the autocompleted sentence generated by the application.
-
Input Text: Users can enter a text snippet into the provided textarea on the home page.
-
Generate Summary: Clicking the "Generate Summary" button sends the user's input to the server, which processes the text and generates an autocompleted sentence.
-
View Result: The result page displays both the original input text and the autocompleted sentence, providing a convenient way for users to compare the input and output.
- The user interface is designed with a clean and user-friendly layout using HTML and CSS. The form elements are styled for readability and ease of use.
The application can be deployed on a server to make it publicly accessible. The Flask web framework handles the server-side logic, allowing users to interact with the application through a web browser.
Please note that the provided HTML files focus on the user interface, and the primary logic for autocompletion resides in the Python script (app.py).
- If you click on this Link to signup for DockerHub.
- You click on Create Repository
- Select a Name and Description for the Repository.
- Public or Private Repository Visibility.
- Create
- This code is important to push docker images to DockerHub: You can push a new image to this repository using the CLI
docker tag local-image:tagname new-repo:tagname
docker push new-repo:tagname
- Here is a representation of what the image looks like in DockerHub:
- This DockerFile is different from the one in the dev container as it is specific to my app that I am trying to containerize.
Here is a list of commands to create a docker image:
docker build -t dockerusername/imagetag .
docker images
docker push dockerusername/imagetag
docker login -u dockerusername -p dockerpassword
Here is a representation what the image looks like from the terminal:
Here is a representation of the image in Dockerhub specifics:
-
First you must go to this site: CreateWebApp.
-
Once there you need to create a resource group which should be aligned to the project or web app you are creating
-
Name of the instance should be the name of the web app name of your website
-
Publish using DOCKER CONTAINER
-
Operating System is Linux
-
Region should be East US but if you run into the issue that scheduled features are not working use Japan East.
-
Then go to the DOCKER tab - single container and use the repository/image tag
-
Create and Review
Here is a representation of what the web app looks like once deployed:(mine is currently stopped to save money):