File size: 5,740 Bytes
526ead4 0b19676 526ead4 d01886f 85cc945 d01886f |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
---
title: AI Research Hub - Complete HuggingFace Demo
emoji: ๐
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.32.0
app_file: app.py
pinned: false
license: mit
short_description: Complete HuggingFace Inference API demo platform
tags:
- nlp
- computer-vision
- text-generation
- question-answering
- text-classification
- zero-shot-classification
- named-entity-recognition
- text-to-image
- sentiment-analysis
- translation
- summarization
- feature-extraction
- huggingface
- inference-api
- gradio
- ai-demo
---
# ๐ AI Research Hub - Complete HuggingFace Demo
A comprehensive demonstration of HuggingFace's Inference API capabilities, optimized for Hugging Face Spaces.
## โจ Features
### ๐ Text Processing
- **๐ฌ Chat** - Conversational AI with advanced language models
- **๐ญ Fill Mask** - Text completion and prediction
- **โ Question Answering** - Extract answers from context
- **๐ Summarization** - Automatic text summarization
### ๐ท๏ธ Classification & Analysis
- **๐ท๏ธ Sentiment Analysis** - Emotion and sentiment detection
- **๐ฏ Zero-Shot Classification** - Classify with custom labels
- **๐ท๏ธ Named Entity Recognition** - Extract people, places, organizations
- **๐งฎ Text Similarity** - Compare semantic similarity between texts
### ๐จ Multimodal Capabilities
- **๐ Translation** - English to French translation
- **๐ผ๏ธ Image Classification** - Identify objects and scenes in images
- **๐จ Text-to-Image** - Generate images from text descriptions
## ๐ง Setup Instructions
### For Hugging Face Spaces:
1. **Fork/Duplicate this Space**
2. **Set up your HuggingFace Token:**
- Go to **Settings** โ **Repository secrets**
- Add a new secret: `HF_TOKEN`
- Value: Your HuggingFace token from [here](https://huggingface.co/settings/tokens)
3. **That's it!** The Space will automatically restart and all features will be available.
### For Local Development:
```bash
# Clone the repository
git clone <your-repo-url>
cd <repo-name>
# Install dependencies
pip install -r requirements.txt
# Set environment variable
export HF_TOKEN="your_token_here"
# Run the application
python app.py
```
## ๐ฏ Key Improvements
### โ
Fixed Issues
- **Question Answering**: Proper input format for API calls
- **Text Classification**: Working models with proper error handling
- **Zero-Shot Classification**: Correct API method usage
- **Named Entity Recognition**: Fixed entity extraction and labeling
- **Image Classification**: Better error handling for uploads
### ๐ Enhanced Features
- **Spaces Optimization**: Memory and performance optimized for HF Spaces
- **Robust Error Handling**: Clear error messages and fallback strategies
- **Modern UI**: Clean, responsive interface with organized tabs
- **Token Management**: Multiple token source detection for Spaces
- **Text Similarity**: Semantic comparison with cosine similarity scores
## ๐ Models Used
| Task | Model | Description |
|------|-------|-------------|
| Chat | `microsoft/DialoGPT-medium` | Conversational AI |
| Fill Mask | `distilbert-base-uncased` | Lightweight BERT model |
| Q&A | `distilbert-base-cased-distilled-squad` | SQuAD-trained model |
| Summarization | `facebook/bart-large-cnn` | CNN-trained BART |
| Sentiment | `cardiffnlp/twitter-roberta-base-sentiment-latest` | Twitter sentiment |
| Zero-Shot | `facebook/bart-large-mnli` | MNLI-trained BART |
| NER | `dslim/bert-base-NER` | CoNLL-trained BERT |
| Translation | `Helsinki-NLP/opus-mt-en-fr` | English-French translator |
| Embeddings | `sentence-transformers/all-MiniLM-L6-v2` | Sentence embeddings |
| Image Classification | `google/vit-base-patch16-224` | Vision Transformer |
| Text-to-Image | `runwayml/stable-diffusion-v1-5` | Stable Diffusion |
## ๐ Privacy & Security
- **No Data Storage**: All processing happens in real-time, no data is stored
- **Secure Token Handling**: Tokens are handled securely through Spaces secrets
- **API Rate Limiting**: Built-in handling for API rate limits and quotas
## ๐จ Troubleshooting
### Common Issues:
1. **"API client not available"**
- Solution: Set `HF_TOKEN` in Spaces settings
2. **"Rate limit reached"**
- Solution: Wait a moment and try again
3. **"Model loading"**
- Solution: Some models need time to load, retry after a few seconds
4. **"Service unavailable"**
- Solution: Temporary HuggingFace service issue, try again later
## ๐ ๏ธ Technical Details
### Architecture
- **Frontend**: Gradio with custom CSS
- **Backend**: HuggingFace Inference API
- **Deployment**: Optimized for HF Spaces environment
- **Error Handling**: Comprehensive error catching and user feedback
### Performance Optimizations
- **Memory Efficient**: Minimal memory footprint for Spaces
- **Fast Models**: Selected for quick response times
- **Graceful Degradation**: Features degrade gracefully if dependencies missing
- **Connection Pooling**: Efficient API client management
## ๐ Future Enhancements
- **Advanced Visualization**: Interactive embedding plots
- **Batch Processing**: Multiple text processing
- **Custom Model Support**: User-specified models
- **Audio Processing**: Speech-to-text capabilities
- **Real-time Streaming**: Live text generation
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test thoroughly
5. Submit a pull request
## ๐ License
This project is open source and available under the MIT License.
## ๐ Acknowledgments
- **HuggingFace** for the amazing Inference API and Spaces platform
- **Gradio** for the intuitive interface framework
- **Open Source Community** for the incredible model ecosystem
---
**Built with โค๏ธ for the AI research community** |