Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available:
1.45.1
metadata
title: Food Image Crowdsourcing
emoji: π½οΈ
colorFrom: green
colorTo: yellow
sdk: streamlit
sdk_version: 1.43.2
app_file: app.py
pinned: false
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
π½οΈ Food Image Crowdsourcing App
A Streamlit application that allows users to upload food images for AI model training. These images will be used to fine-tune datasets for food image recognition to annotate uploaded food pictures with caloric and nutrient values.
π Features
- User authentication via Firebase
- Image upload and processing
- Token reward system for contributors
- AWS S3 storage for images
- DynamoDB for metadata storage
π Deployment to Hugging Face Spaces
Prerequisites
- Hugging Face account
- AWS account with S3 and DynamoDB
- Firebase project for authentication
Step 1: Set up AWS Resources
- Create an S3 bucket:
food-image-crowdsourcing
- Create a DynamoDB table:
image_metadata
with primary keyimage_id
- Create an IAM user with permissions for S3 and DynamoDB
- Note your AWS Access Key and Secret Key
Step 2: Set up Firebase Authentication
- Create a new Firebase project at Firebase Console
- Enable Email/Password authentication
- Generate a new private key for your service account (Project settings > Service accounts > Generate new private key)
- Save the JSON file
Step 3: Create a New Hugging Face Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose a name for your Space
- Select "Streamlit" as the SDK
- Choose visibility (Public or Private)
- Click "Create Space"
Step 4: Upload Files to the Space
Upload the following files to your Space:
app.py
requirements.txt
PARTICIPATION_GUIDELINES.md
TOKEN_REWARDS.md
TERMS_OF_SERVICE.md
You can do this via the Hugging Face web interface or using Git.
Step 5: Configure Secrets
- Go to your Space's Settings tab
- Under "Repository secrets", add the following secrets:
AWS_ACCESS_KEY
: Your AWS access keyAWS_SECRET_KEY
: Your AWS secret keyAWS_REGION
: Your AWS region (e.g.,us-east-1
)S3_BUCKET_NAME
: Your S3 bucket name (e.g.,food-image-crowdsourcing
)DYNAMODB_TABLE
: Your DynamoDB table name (e.g.,image_metadata
)FIREBASE_CONFIG
: Paste the entire content of your Firebase service account JSON file
Step 6: Deploy and Run
- Your Space should automatically build and deploy when you push your changes
- If not, you can manually rebuild from the Settings tab
- Once deployed, you can access your app at
https://huggingface.co/spaces/your-username/your-space-name
π Important Files
app.py
: The main Streamlit applicationrequirements.txt
: Python dependenciesPARTICIPATION_GUIDELINES.md
: Rules for user participationTOKEN_REWARDS.md
: Explanation of the token reward systemTERMS_OF_SERVICE.md
: Legal terms and conditions
π Local Development
To run this application locally:
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file with the required environment variables - Run the app:
streamlit run app.py
π¦ Required Environment Variables
AWS_ACCESS_KEY=your_aws_access_key
AWS_SECRET_KEY=your_aws_secret_key
AWS_REGION=your_aws_region
S3_BUCKET_NAME=your_s3_bucket_name
DYNAMODB_TABLE=your_dynamodb_table_name
FIREBASE_CONFIG=your_firebase_json_config
π Data Model
S3 Object Structure
Images are stored in S3 with the following path pattern:
{user_id}/{timestamp}_{image_id}.jpg
DynamoDB Schema
Each image entry in DynamoDB contains:
image_id
(Primary Key): UUID for the imageuser_id
: ID of the uploading userupload_timestamp
: When the image was uploadedfood_name
: Name of the foodportion_size
: Size/weight of the portionportion_unit
: Unit of measurementcooking_method
: How the food was preparedingredients
: List of main ingredientss3_path
: Path to the image in S3tokens_awarded
: Number of tokens awarded for this upload
π οΈ Future Enhancements
- Image tagging with machine learning
- Nutritional information estimation
- Social sharing features
- Mobile app integration
- Enhanced analytics dashboard
π License
This project is licensed under the MIT License - see the LICENSE file for details.