File size: 1,417 Bytes
f423c92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Dash + Hugging Face Demo

This is a demo application showcasing how to use Dash with Hugging Face models deployed on Hugging Face Spaces using Docker.

## Features

- **Sentiment Analysis**: Analyze the sentiment of text using a pre-trained model
- **Text Generation**: Generate text based on prompts using GPT-2
- **Interactive Visualizations**: View sentiment analysis results with Plotly charts
- **Responsive Design**: Bootstrap-based UI that works on all devices

## Models Used

- Sentiment Analysis: `cardiffnlp/twitter-roberta-base-sentiment-latest`
- Text Generation: `gpt2`

## Local Development

1. Clone this repository
2. Install dependencies: `pip install -r requirements.txt`
3. Run the app: `python app.py`
4. Open your browser to `http://localhost:7860`

## Deployment on Hugging Face Spaces

This app is configured to run on Hugging Face Spaces using Docker:

1. The Dockerfile sets up the Python environment
2. Port 7860 is exposed (required by HF Spaces)
3. Models are loaded automatically when the container starts

## File Structure

```
β”œβ”€β”€ app.py              # Main Dash application
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ Dockerfile         # Docker configuration
└── README.md          # This file
```

## Configuration

The app automatically detects when running on Hugging Face Spaces and configures itself accordingly. No additional setup is required.