This project is a Generative AI Video Platform that leverages Theta Network technologies to create personalized video content. The platform uses Theta EdgeCloud for efficient model training and Theta blockchain to tokenize generated content as NFTs, ensuring content authenticity and providing new revenue streams for content creators.
- Name: Cyril
- Age: 18
- Country: Ghana
- Email Address: [email protected]
- Track: Generative AI
The AI model is built using TensorFlow and the VGG16 architecture, which is pre-trained on the ImageNet dataset. The model is fine-tuned for the specific task of generating video frames.
Key Functions:
-
Model Building:
- The model uses VGG16 as the base and adds additional layers for customization.
- The base model's weights are frozen to retain pre-trained knowledge.
-
Data Preprocessing:
- The preprocessing function reads a video file, extracts frames, resizes them, and normalizes pixel values.
-
Model Training:
- The model is trained on a dataset of video frames and labels.
The backend server is built using Flask and handles user authentication, video processing, and NFT minting.
Key Endpoints:
-
User Authentication:
- JWT is used for secure user authentication.
- Users can log in to receive a JWT token.
-
Video Generation:
- Users can upload a video file, which is processed by the AI model to generate new content.
- The generated video is concatenated with the input video.
The smart contract is written in Solidity and is used to mint NFTs for the generated videos.
Key Functions:
- NFT Creation:
- The
createNFT
function mints a new NFT with a specified token URI.
- The
The frontend is built using React and interacts with the backend and smart contract.
Key Components:
-
User Login:
- Users can log in to receive a JWT token, which is used for authenticated requests.
-
Video Upload and Generation:
- Users can upload a video, which is sent to the backend for processing.
- The processed video URI is then displayed, and users can mint it as an NFT.
-
NFT Minting:
- Users can mint the generated video as an NFT on the Theta blockchain.
-
Clone the repository:
- Clone the project repository from GitHub to your local machine:
git clone https://github.com/your-username/theta-generative-ai-video-platform.git cd theta-generative-ai-video-platform
- Clone the project repository from GitHub to your local machine:
-
Set up the backend environment:
- Create a virtual environment and install the required Python packages:
python3 -m venv env source env/bin/activate pip install -r requirements.txt
- Create a virtual environment and install the required Python packages:
-
Train the AI model:
- Prepare your dataset of video frames and labels.
- Build and train the model using the dataset:
python train_model.py
- Save the trained model to a file.
-
Run the server:
- Start the Flask server to handle API requests:
python server.py
- Start the Flask server to handle API requests:
-
Set up the smart contract environment:
- Install Foundry, a powerful toolkit for Ethereum development:
curl -L https://foundry.paradigm.xyz | bash foundryup
- Install Foundry, a powerful toolkit for Ethereum development:
-
Compile and deploy the contract:
- Navigate to the contracts directory:
cd contracts
- Compile the smart contract:
forge build
- Deploy the smart contract to the Ethereum network using a script and your private key:
forge script script/Deploy.s.sol --rpc-url https://rinkeby.infura.io/v3/YOUR_INFURA_PROJECT_ID --private-key YOUR_PRIVATE_KEY --broadcast
- Navigate to the contracts directory:
-
Set up the frontend environment:
- Navigate to the client directory and create a React application:
cd ../client npx create-react-app client cd client
- Install the necessary packages:
npm install web3 axios jwt-decode jest @testing-library/react @testing-library/jest-dom
- Navigate to the client directory and create a React application:
-
Start the React application:
- Run the React development server to start the frontend application:
npm start
- Run the React development server to start the frontend application:
-
Sign Up for Google Cloud Web3 Startup Program:
- Go to Google Cloud Web3 and sign up for the program.
-
Set Up Google Cloud SDK:
- Install Google Cloud SDK by following the installation guide.
- Initialize the SDK:
gcloud init
-
Create and Configure a Google Cloud Project:
- Create a new project in the Google Cloud Console.
- Enable necessary APIs (e.g., Cloud Storage, Compute Engine).
-
Containerize the Application:
-
Create a
Dockerfile
for the AI application.Dockerfile
FROM python:3.9-slim WORKDIR /app COPY requirements.txt requirements.txt RUN pip install -r requirements.txt COPY . . CMD ["gunicorn", "--bind", "0.0.0.0:5000", "server:app"]
-
Build the Docker image:
docker build -t video-generator-app .
-
Push the Docker image to Google Container Registry:
gcloud auth configure-docker docker tag video-generator-app gcr.io/YOUR_PROJECT_ID/video-generator-app docker push gcr.io/YOUR_PROJECT_ID/video-generator-app
-
-
Deploy the Application to Google Cloud:
-
Create a Kubernetes cluster:
gcloud container clusters create video-generator-cluster --num-nodes=3 gcloud container clusters get-credentials video-generator-cluster
-
Deploy the application using Kubernetes:
deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: video-generator spec: replicas: 3 selector: matchLabels: app: video-generator template: metadata: labels: app: video-generator spec: containers: - name: video-generator image: gcr.io/YOUR_PROJECT_ID/video-generator-app ports: - containerPort: 5000
service.yaml
apiVersion: v1 kind: Service metadata: name: video-generator-service spec: selector: app: video-generator ports: - protocol: TCP port: 80 targetPort: 5000 type: LoadBalancer
-
Apply the Kubernetes configuration:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
-
-
Access the Deployed Application:
- Get the external IP address of the service:
kubectl get services
- Open the external IP address in your browser to access the application.
- Get the external IP address of the service:
-
Run backend tests:
- Use pytest to run the backend unit tests:
pytest test_server.py
- Use pytest to run the backend unit tests:
-
Run integration tests:
- Run integration tests to ensure the backend and smart contract interactions work correctly:
python integration_test.py
- Run integration tests to ensure the backend and smart contract interactions work correctly:
-
Run frontend tests:
- Use jest to run the frontend unit tests:
npm test
- Use jest to run the frontend unit tests:
-
Access the Platform:
- Open your web browser and go to the URL where the platform is hosted.
-
Log In:
- Enter your username and password to log in to the platform.
- If you don't have an account, sign up for one.
-
Upload a Video:
- Click the "Upload Video" button.
- Select a video file from your computer and upload it.
-
Generate Personalized Content:
- After uploading the video, click the "Generate Video" button.
- The platform will process the video using the AI model to generate personalized content.
-
Mint an NFT:
- Once the video is generated, click the "Mint NFT" button to tokenize the video on the Theta blockchain.
- You will need to have a cryptocurrency wallet connected to complete this process.
-
View and Share Your Content:
- After minting the NFT, you can view your personalized video and share it with others.
By combining cutting-edge Generative AI with the decentralized power of Theta Network, this platform offers a robust solution for personalized video content creation and distribution.
Follow these detailed steps to develop, deploy, and run the Theta Generative AI Video Platform, ensuring it meets all functionality requirements and provides a seamless user experience.