Spaces:
Sleeping
Sleeping
Project Progress Log
This document tracks the step-by-step process of creating and deploying the Simple Sentiment Analyzer application.
1. Prerequisites & Initial Setup
- Goal: Build and deploy a sentiment analysis web application using Hugging Face.
- Accounts: A new Hugging Face account was created and verified via email. A GitHub account was already available.
- Tools: Confirmed that
pythonandgitwere installed locally on the Ubuntu system.
2. Local Project Initialization
- Directory: Created a project directory named
sentiment-app. - Dependency Management: Chose to use
Poetryfor modern Python package and environment management. - Poetry Setup:
- Initialized the project with
poetry init, creating thepyproject.tomlconfiguration file. - Added the required libraries (
transformers,torch, andgradio) using thepoetry addcommand. This automatically created a virtual environment and installed the dependencies.
- Initialized the project with
3. Application Development
Main Application (
app.py):- Created the
app.pyfile. - Wrote the Python code to load a pre-trained sentiment analysis model using the
transformerspipeline. - Wrote a function
analyze_sentimentto process user input and return the model's prediction. - Built a web user interface using
Gradio, creating a title, description, and a simple textbox input/output.
- Created the
Deployment Dependencies (
requirements.txt):- To ensure compatibility with Hugging Face Spaces, a
requirements.txtfile was generated from the Poetry environment using thepoetry exportcommand.
- To ensure compatibility with Hugging Face Spaces, a
4. Local Testing
- Execution: The application was run locally from the terminal using
poetry run python app.py. - Verification: The Gradio server started successfully. The application was accessed via a local URL (
http://127.0.0.1:7860) in a web browser. - Functionality Check: Tested the app with both positive and negative sentences to confirm it was working as expected.
- Shutdown: The local server was stopped gracefully using
Ctrl+Cin the terminal.
5. Deployment to Hugging Face Spaces
Git Initialization: The project was already a Git repository. New files (
app.py,pyproject.toml,poetry.lock,requirements.txt) were staged withgit addand committed withgit commit.Space Creation:
- A new "Space" was created on the Hugging Face website.
- The Space was configured with the
GradioSDK.
Connecting Local to Remote:
- The new Hugging Face Space's Git URL was added as a remote to the local repository under the name
huggingface(git remote add ...).
- The new Hugging Face Space's Git URL was added as a remote to the local repository under the name
First Push & Reconciliation:
- The initial
git push huggingface mainfailed due to the remote Space having its own initial commit (with aREADME.mdfile), causing "divergent histories". - This was resolved by pulling the remote changes first using
git pull huggingface main --allow-unrelated-histories. This merged the remote'sREADME.mdinto the local project.
- The initial
Documentation:
- The default
README.mdwas updated with a detailed description of the project, its technologies, and usage instructions. - This
PROGRESS.mdfile was created to document the project's entire lifecycle.
- The default