tdurzynski's picture
Update README.md
93cad02 verified

A newer version of the Streamlit SDK is available: 1.45.1

Upgrade
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

  1. Hugging Face account
  2. AWS account with S3 and DynamoDB
  3. Firebase project for authentication

Step 1: Set up AWS Resources

  1. Create an S3 bucket: food-image-crowdsourcing
  2. Create a DynamoDB table: image_metadata with primary key image_id
  3. Create an IAM user with permissions for S3 and DynamoDB
  4. Note your AWS Access Key and Secret Key

Step 2: Set up Firebase Authentication

  1. Create a new Firebase project at Firebase Console
  2. Enable Email/Password authentication
  3. Generate a new private key for your service account (Project settings > Service accounts > Generate new private key)
  4. Save the JSON file

Step 3: Create a New Hugging Face Space

  1. Go to Hugging Face Spaces
  2. Click "Create new Space"
  3. Choose a name for your Space
  4. Select "Streamlit" as the SDK
  5. Choose visibility (Public or Private)
  6. 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

  1. Go to your Space's Settings tab
  2. Under "Repository secrets", add the following secrets:
    • AWS_ACCESS_KEY: Your AWS access key
    • AWS_SECRET_KEY: Your AWS secret key
    • AWS_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

  1. Your Space should automatically build and deploy when you push your changes
  2. If not, you can manually rebuild from the Settings tab
  3. Once deployed, you can access your app at https://huggingface.co/spaces/your-username/your-space-name

πŸ“„ Important Files

  • app.py: The main Streamlit application
  • requirements.txt: Python dependencies
  • PARTICIPATION_GUIDELINES.md: Rules for user participation
  • TOKEN_REWARDS.md: Explanation of the token reward system
  • TERMS_OF_SERVICE.md: Legal terms and conditions

πŸ”„ Local Development

To run this application locally:

  1. Clone the repository
  2. Install dependencies: pip install -r requirements.txt
  3. Create a .env file with the required environment variables
  4. 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 image
  • user_id: ID of the uploading user
  • upload_timestamp: When the image was uploaded
  • food_name: Name of the food
  • portion_size: Size/weight of the portion
  • portion_unit: Unit of measurement
  • cooking_method: How the food was prepared
  • ingredients: List of main ingredients
  • s3_path: Path to the image in S3
  • tokens_awarded: Number of tokens awarded for this upload

πŸ› οΈ Future Enhancements

  1. Image tagging with machine learning
  2. Nutritional information estimation
  3. Social sharing features
  4. Mobile app integration
  5. Enhanced analytics dashboard

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.