|
--- |
|
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** |